babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328
  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. /** Associative array from JSON sprite data file */
  11559. private _cellData;
  11560. /** Array of sprite names from JSON sprite data file */
  11561. private _spriteMap;
  11562. /** True when packed cell data from JSON file is ready*/
  11563. private _packedAndReady;
  11564. /**
  11565. * An event triggered when the manager is disposed.
  11566. */
  11567. onDisposeObservable: Observable<SpriteManager>;
  11568. private _onDisposeObserver;
  11569. /**
  11570. * Callback called when the manager is disposed
  11571. */
  11572. onDispose: () => void;
  11573. private _capacity;
  11574. private _fromPacked;
  11575. private _spriteTexture;
  11576. private _epsilon;
  11577. private _scene;
  11578. private _vertexData;
  11579. private _buffer;
  11580. private _vertexBuffers;
  11581. private _indexBuffer;
  11582. private _effectBase;
  11583. private _effectFog;
  11584. /**
  11585. * Gets or sets the spritesheet texture
  11586. */
  11587. texture: Texture;
  11588. /**
  11589. * Creates a new sprite manager
  11590. * @param name defines the manager's name
  11591. * @param imgUrl defines the sprite sheet url
  11592. * @param capacity defines the maximum allowed number of sprites
  11593. * @param cellSize defines the size of a sprite cell
  11594. * @param scene defines the hosting scene
  11595. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11596. * @param samplingMode defines the smapling mode to use with spritesheet
  11597. * @param fromPacked set to false; do not alter
  11598. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11599. */
  11600. constructor(
  11601. /** defines the manager's name */
  11602. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11603. private _makePacked;
  11604. private _appendSpriteVertex;
  11605. /**
  11606. * Intersects the sprites with a ray
  11607. * @param ray defines the ray to intersect with
  11608. * @param camera defines the current active camera
  11609. * @param predicate defines a predicate used to select candidate sprites
  11610. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11611. * @returns null if no hit or a PickingInfo
  11612. */
  11613. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11614. /**
  11615. * Render all child sprites
  11616. */
  11617. render(): void;
  11618. /**
  11619. * Release associated resources
  11620. */
  11621. dispose(): void;
  11622. }
  11623. }
  11624. declare module "babylonjs/Sprites/sprite" {
  11625. import { Vector3 } from "babylonjs/Maths/math.vector";
  11626. import { Nullable } from "babylonjs/types";
  11627. import { ActionManager } from "babylonjs/Actions/actionManager";
  11628. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11629. import { Color4 } from "babylonjs/Maths/math.color";
  11630. /**
  11631. * Class used to represent a sprite
  11632. * @see http://doc.babylonjs.com/babylon101/sprites
  11633. */
  11634. export class Sprite {
  11635. /** defines the name */
  11636. name: string;
  11637. /** Gets or sets the current world position */
  11638. position: Vector3;
  11639. /** Gets or sets the main color */
  11640. color: Color4;
  11641. /** Gets or sets the width */
  11642. width: number;
  11643. /** Gets or sets the height */
  11644. height: number;
  11645. /** Gets or sets rotation angle */
  11646. angle: number;
  11647. /** Gets or sets the cell index in the sprite sheet */
  11648. cellIndex: number;
  11649. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11650. cellRef: string;
  11651. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11652. invertU: number;
  11653. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11654. invertV: number;
  11655. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11656. disposeWhenFinishedAnimating: boolean;
  11657. /** Gets the list of attached animations */
  11658. animations: Animation[];
  11659. /** Gets or sets a boolean indicating if the sprite can be picked */
  11660. isPickable: boolean;
  11661. /**
  11662. * Gets or sets the associated action manager
  11663. */
  11664. actionManager: Nullable<ActionManager>;
  11665. private _animationStarted;
  11666. private _loopAnimation;
  11667. private _fromIndex;
  11668. private _toIndex;
  11669. private _delay;
  11670. private _direction;
  11671. private _manager;
  11672. private _time;
  11673. private _onAnimationEnd;
  11674. /**
  11675. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11676. */
  11677. isVisible: boolean;
  11678. /**
  11679. * Gets or sets the sprite size
  11680. */
  11681. size: number;
  11682. /**
  11683. * Creates a new Sprite
  11684. * @param name defines the name
  11685. * @param manager defines the manager
  11686. */
  11687. constructor(
  11688. /** defines the name */
  11689. name: string, manager: ISpriteManager);
  11690. /**
  11691. * Starts an animation
  11692. * @param from defines the initial key
  11693. * @param to defines the end key
  11694. * @param loop defines if the animation must loop
  11695. * @param delay defines the start delay (in ms)
  11696. * @param onAnimationEnd defines a callback to call when animation ends
  11697. */
  11698. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11699. /** Stops current animation (if any) */
  11700. stopAnimation(): void;
  11701. /** @hidden */
  11702. _animate(deltaTime: number): void;
  11703. /** Release associated resources */
  11704. dispose(): void;
  11705. }
  11706. }
  11707. declare module "babylonjs/Collisions/pickingInfo" {
  11708. import { Nullable } from "babylonjs/types";
  11709. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11711. import { Sprite } from "babylonjs/Sprites/sprite";
  11712. import { Ray } from "babylonjs/Culling/ray";
  11713. /**
  11714. * Information about the result of picking within a scene
  11715. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11716. */
  11717. export class PickingInfo {
  11718. /** @hidden */
  11719. _pickingUnavailable: boolean;
  11720. /**
  11721. * If the pick collided with an object
  11722. */
  11723. hit: boolean;
  11724. /**
  11725. * Distance away where the pick collided
  11726. */
  11727. distance: number;
  11728. /**
  11729. * The location of pick collision
  11730. */
  11731. pickedPoint: Nullable<Vector3>;
  11732. /**
  11733. * The mesh corresponding the the pick collision
  11734. */
  11735. pickedMesh: Nullable<AbstractMesh>;
  11736. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11737. bu: number;
  11738. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11739. bv: number;
  11740. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11741. faceId: number;
  11742. /** Id of the the submesh that was picked */
  11743. subMeshId: number;
  11744. /** If a sprite was picked, this will be the sprite the pick collided with */
  11745. pickedSprite: Nullable<Sprite>;
  11746. /**
  11747. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11748. */
  11749. originMesh: Nullable<AbstractMesh>;
  11750. /**
  11751. * The ray that was used to perform the picking.
  11752. */
  11753. ray: Nullable<Ray>;
  11754. /**
  11755. * Gets the normal correspodning to the face the pick collided with
  11756. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11757. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11758. * @returns The normal correspodning to the face the pick collided with
  11759. */
  11760. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11761. /**
  11762. * Gets the texture coordinates of where the pick occured
  11763. * @returns the vector containing the coordnates of the texture
  11764. */
  11765. getTextureCoordinates(): Nullable<Vector2>;
  11766. }
  11767. }
  11768. declare module "babylonjs/Events/pointerEvents" {
  11769. import { Nullable } from "babylonjs/types";
  11770. import { Vector2 } from "babylonjs/Maths/math.vector";
  11771. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11772. import { Ray } from "babylonjs/Culling/ray";
  11773. /**
  11774. * Gather the list of pointer event types as constants.
  11775. */
  11776. export class PointerEventTypes {
  11777. /**
  11778. * 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.
  11779. */
  11780. static readonly POINTERDOWN: number;
  11781. /**
  11782. * The pointerup event is fired when a pointer is no longer active.
  11783. */
  11784. static readonly POINTERUP: number;
  11785. /**
  11786. * The pointermove event is fired when a pointer changes coordinates.
  11787. */
  11788. static readonly POINTERMOVE: number;
  11789. /**
  11790. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11791. */
  11792. static readonly POINTERWHEEL: number;
  11793. /**
  11794. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11795. */
  11796. static readonly POINTERPICK: number;
  11797. /**
  11798. * The pointertap event is fired when a the object has been touched and released without drag.
  11799. */
  11800. static readonly POINTERTAP: number;
  11801. /**
  11802. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11803. */
  11804. static readonly POINTERDOUBLETAP: number;
  11805. }
  11806. /**
  11807. * Base class of pointer info types.
  11808. */
  11809. export class PointerInfoBase {
  11810. /**
  11811. * Defines the type of event (PointerEventTypes)
  11812. */
  11813. type: number;
  11814. /**
  11815. * Defines the related dom event
  11816. */
  11817. event: PointerEvent | MouseWheelEvent;
  11818. /**
  11819. * Instantiates the base class of pointers info.
  11820. * @param type Defines the type of event (PointerEventTypes)
  11821. * @param event Defines the related dom event
  11822. */
  11823. constructor(
  11824. /**
  11825. * Defines the type of event (PointerEventTypes)
  11826. */
  11827. type: number,
  11828. /**
  11829. * Defines the related dom event
  11830. */
  11831. event: PointerEvent | MouseWheelEvent);
  11832. }
  11833. /**
  11834. * This class is used to store pointer related info for the onPrePointerObservable event.
  11835. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11836. */
  11837. export class PointerInfoPre extends PointerInfoBase {
  11838. /**
  11839. * Ray from a pointer if availible (eg. 6dof controller)
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Defines the local position of the pointer on the canvas.
  11844. */
  11845. localPosition: Vector2;
  11846. /**
  11847. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11848. */
  11849. skipOnPointerObservable: boolean;
  11850. /**
  11851. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11852. * @param type Defines the type of event (PointerEventTypes)
  11853. * @param event Defines the related dom event
  11854. * @param localX Defines the local x coordinates of the pointer when the event occured
  11855. * @param localY Defines the local y coordinates of the pointer when the event occured
  11856. */
  11857. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11858. }
  11859. /**
  11860. * This type contains all the data related to a pointer event in Babylon.js.
  11861. * 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.
  11862. */
  11863. export class PointerInfo extends PointerInfoBase {
  11864. /**
  11865. * Defines the picking info associated to the info (if any)\
  11866. */
  11867. pickInfo: Nullable<PickingInfo>;
  11868. /**
  11869. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. * @param pickInfo Defines the picking info associated to the info (if any)\
  11873. */
  11874. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11875. /**
  11876. * Defines the picking info associated to the info (if any)\
  11877. */
  11878. pickInfo: Nullable<PickingInfo>);
  11879. }
  11880. /**
  11881. * Data relating to a touch event on the screen.
  11882. */
  11883. export interface PointerTouch {
  11884. /**
  11885. * X coordinate of touch.
  11886. */
  11887. x: number;
  11888. /**
  11889. * Y coordinate of touch.
  11890. */
  11891. y: number;
  11892. /**
  11893. * Id of touch. Unique for each finger.
  11894. */
  11895. pointerId: number;
  11896. /**
  11897. * Event type passed from DOM.
  11898. */
  11899. type: any;
  11900. }
  11901. }
  11902. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11903. import { Observable } from "babylonjs/Misc/observable";
  11904. import { Nullable } from "babylonjs/types";
  11905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11907. /**
  11908. * Manage the mouse inputs to control the movement of a free camera.
  11909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11910. */
  11911. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11912. /**
  11913. * Define if touch is enabled in the mouse input
  11914. */
  11915. touchEnabled: boolean;
  11916. /**
  11917. * Defines the camera the input is attached to.
  11918. */
  11919. camera: FreeCamera;
  11920. /**
  11921. * Defines the buttons associated with the input to handle camera move.
  11922. */
  11923. buttons: number[];
  11924. /**
  11925. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11926. */
  11927. angularSensibility: number;
  11928. private _pointerInput;
  11929. private _onMouseMove;
  11930. private _observer;
  11931. private previousPosition;
  11932. /**
  11933. * Observable for when a pointer move event occurs containing the move offset
  11934. */
  11935. onPointerMovedObservable: Observable<{
  11936. offsetX: number;
  11937. offsetY: number;
  11938. }>;
  11939. /**
  11940. * @hidden
  11941. * If the camera should be rotated automatically based on pointer movement
  11942. */
  11943. _allowCameraRotation: boolean;
  11944. /**
  11945. * Manage the mouse inputs to control the movement of a free camera.
  11946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11947. * @param touchEnabled Defines if touch is enabled or not
  11948. */
  11949. constructor(
  11950. /**
  11951. * Define if touch is enabled in the mouse input
  11952. */
  11953. touchEnabled?: boolean);
  11954. /**
  11955. * Attach the input controls to a specific dom element to get the input from.
  11956. * @param element Defines the element the controls should be listened from
  11957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11958. */
  11959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11960. /**
  11961. * Called on JS contextmenu event.
  11962. * Override this method to provide functionality.
  11963. */
  11964. protected onContextMenu(evt: PointerEvent): void;
  11965. /**
  11966. * Detach the current controls from the specified dom element.
  11967. * @param element Defines the element to stop listening the inputs from
  11968. */
  11969. detachControl(element: Nullable<HTMLElement>): void;
  11970. /**
  11971. * Gets the class name of the current intput.
  11972. * @returns the class name
  11973. */
  11974. getClassName(): string;
  11975. /**
  11976. * Get the friendly name associated with the input class.
  11977. * @returns the input friendly name
  11978. */
  11979. getSimpleName(): string;
  11980. }
  11981. }
  11982. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11983. import { Nullable } from "babylonjs/types";
  11984. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11985. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11986. /**
  11987. * Manage the touch inputs to control the movement of a free camera.
  11988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11989. */
  11990. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11991. /**
  11992. * Defines the camera the input is attached to.
  11993. */
  11994. camera: FreeCamera;
  11995. /**
  11996. * Defines the touch sensibility for rotation.
  11997. * The higher the faster.
  11998. */
  11999. touchAngularSensibility: number;
  12000. /**
  12001. * Defines the touch sensibility for move.
  12002. * The higher the faster.
  12003. */
  12004. touchMoveSensibility: number;
  12005. private _offsetX;
  12006. private _offsetY;
  12007. private _pointerPressed;
  12008. private _pointerInput;
  12009. private _observer;
  12010. private _onLostFocus;
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Detach the current controls from the specified dom element.
  12019. * @param element Defines the element to stop listening the inputs from
  12020. */
  12021. detachControl(element: Nullable<HTMLElement>): void;
  12022. /**
  12023. * Update the current camera state depending on the inputs that have been used this frame.
  12024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12025. */
  12026. checkInputs(): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12041. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12043. import { Nullable } from "babylonjs/types";
  12044. /**
  12045. * Default Inputs manager for the FreeCamera.
  12046. * It groups all the default supported inputs for ease of use.
  12047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12048. */
  12049. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12050. /**
  12051. * @hidden
  12052. */
  12053. _mouseInput: Nullable<FreeCameraMouseInput>;
  12054. /**
  12055. * Instantiates a new FreeCameraInputsManager.
  12056. * @param camera Defines the camera the inputs belong to
  12057. */
  12058. constructor(camera: FreeCamera);
  12059. /**
  12060. * Add keyboard input support to the input manager.
  12061. * @returns the current input manager
  12062. */
  12063. addKeyboard(): FreeCameraInputsManager;
  12064. /**
  12065. * Add mouse input support to the input manager.
  12066. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12067. * @returns the current input manager
  12068. */
  12069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12070. /**
  12071. * Removes the mouse input support from the manager
  12072. * @returns the current input manager
  12073. */
  12074. removeMouse(): FreeCameraInputsManager;
  12075. /**
  12076. * Add touch input support to the input manager.
  12077. * @returns the current input manager
  12078. */
  12079. addTouch(): FreeCameraInputsManager;
  12080. /**
  12081. * Remove all attached input methods from a camera
  12082. */
  12083. clear(): void;
  12084. }
  12085. }
  12086. declare module "babylonjs/Cameras/freeCamera" {
  12087. import { Vector3 } from "babylonjs/Maths/math.vector";
  12088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12089. import { Scene } from "babylonjs/scene";
  12090. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12091. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12092. /**
  12093. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12094. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12096. */
  12097. export class FreeCamera extends TargetCamera {
  12098. /**
  12099. * Define the collision ellipsoid of the camera.
  12100. * This is helpful to simulate a camera body like the player body around the camera
  12101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12102. */
  12103. ellipsoid: Vector3;
  12104. /**
  12105. * Define an offset for the position of the ellipsoid around the camera.
  12106. * This can be helpful to determine the center of the body near the gravity center of the body
  12107. * instead of its head.
  12108. */
  12109. ellipsoidOffset: Vector3;
  12110. /**
  12111. * Enable or disable collisions of the camera with the rest of the scene objects.
  12112. */
  12113. checkCollisions: boolean;
  12114. /**
  12115. * Enable or disable gravity on the camera.
  12116. */
  12117. applyGravity: boolean;
  12118. /**
  12119. * Define the input manager associated to the camera.
  12120. */
  12121. inputs: FreeCameraInputsManager;
  12122. /**
  12123. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12124. * Higher values reduce sensitivity.
  12125. */
  12126. /**
  12127. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12128. * Higher values reduce sensitivity.
  12129. */
  12130. angularSensibility: number;
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12133. */
  12134. keysUp: number[];
  12135. /**
  12136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12137. */
  12138. keysDown: number[];
  12139. /**
  12140. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12141. */
  12142. keysLeft: number[];
  12143. /**
  12144. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12145. */
  12146. keysRight: number[];
  12147. /**
  12148. * Event raised when the camera collide with a mesh in the scene.
  12149. */
  12150. onCollide: (collidedMesh: AbstractMesh) => void;
  12151. private _collider;
  12152. private _needMoveForGravity;
  12153. private _oldPosition;
  12154. private _diffPosition;
  12155. private _newPosition;
  12156. /** @hidden */
  12157. _localDirection: Vector3;
  12158. /** @hidden */
  12159. _transformedDirection: Vector3;
  12160. /**
  12161. * Instantiates a Free Camera.
  12162. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12163. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12165. * @param name Define the name of the camera in the scene
  12166. * @param position Define the start position of the camera in the scene
  12167. * @param scene Define the scene the camera belongs to
  12168. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12169. */
  12170. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12171. /**
  12172. * Attached controls to the current camera.
  12173. * @param element Defines the element the controls should be listened from
  12174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12175. */
  12176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12177. /**
  12178. * Detach the current controls from the camera.
  12179. * The camera will stop reacting to inputs.
  12180. * @param element Defines the element to stop listening the inputs from
  12181. */
  12182. detachControl(element: HTMLElement): void;
  12183. private _collisionMask;
  12184. /**
  12185. * Define a collision mask to limit the list of object the camera can collide with
  12186. */
  12187. collisionMask: number;
  12188. /** @hidden */
  12189. _collideWithWorld(displacement: Vector3): void;
  12190. private _onCollisionPositionChange;
  12191. /** @hidden */
  12192. _checkInputs(): void;
  12193. /** @hidden */
  12194. _decideIfNeedsToMove(): boolean;
  12195. /** @hidden */
  12196. _updatePosition(): void;
  12197. /**
  12198. * Destroy the camera and release the current resources hold by it.
  12199. */
  12200. dispose(): void;
  12201. /**
  12202. * Gets the current object class name.
  12203. * @return the class name
  12204. */
  12205. getClassName(): string;
  12206. }
  12207. }
  12208. declare module "babylonjs/Gamepads/gamepad" {
  12209. import { Observable } from "babylonjs/Misc/observable";
  12210. /**
  12211. * Represents a gamepad control stick position
  12212. */
  12213. export class StickValues {
  12214. /**
  12215. * The x component of the control stick
  12216. */
  12217. x: number;
  12218. /**
  12219. * The y component of the control stick
  12220. */
  12221. y: number;
  12222. /**
  12223. * Initializes the gamepad x and y control stick values
  12224. * @param x The x component of the gamepad control stick value
  12225. * @param y The y component of the gamepad control stick value
  12226. */
  12227. constructor(
  12228. /**
  12229. * The x component of the control stick
  12230. */
  12231. x: number,
  12232. /**
  12233. * The y component of the control stick
  12234. */
  12235. y: number);
  12236. }
  12237. /**
  12238. * An interface which manages callbacks for gamepad button changes
  12239. */
  12240. export interface GamepadButtonChanges {
  12241. /**
  12242. * Called when a gamepad has been changed
  12243. */
  12244. changed: boolean;
  12245. /**
  12246. * Called when a gamepad press event has been triggered
  12247. */
  12248. pressChanged: boolean;
  12249. /**
  12250. * Called when a touch event has been triggered
  12251. */
  12252. touchChanged: boolean;
  12253. /**
  12254. * Called when a value has changed
  12255. */
  12256. valueChanged: boolean;
  12257. }
  12258. /**
  12259. * Represents a gamepad
  12260. */
  12261. export class Gamepad {
  12262. /**
  12263. * The id of the gamepad
  12264. */
  12265. id: string;
  12266. /**
  12267. * The index of the gamepad
  12268. */
  12269. index: number;
  12270. /**
  12271. * The browser gamepad
  12272. */
  12273. browserGamepad: any;
  12274. /**
  12275. * Specifies what type of gamepad this represents
  12276. */
  12277. type: number;
  12278. private _leftStick;
  12279. private _rightStick;
  12280. /** @hidden */
  12281. _isConnected: boolean;
  12282. private _leftStickAxisX;
  12283. private _leftStickAxisY;
  12284. private _rightStickAxisX;
  12285. private _rightStickAxisY;
  12286. /**
  12287. * Triggered when the left control stick has been changed
  12288. */
  12289. private _onleftstickchanged;
  12290. /**
  12291. * Triggered when the right control stick has been changed
  12292. */
  12293. private _onrightstickchanged;
  12294. /**
  12295. * Represents a gamepad controller
  12296. */
  12297. static GAMEPAD: number;
  12298. /**
  12299. * Represents a generic controller
  12300. */
  12301. static GENERIC: number;
  12302. /**
  12303. * Represents an XBox controller
  12304. */
  12305. static XBOX: number;
  12306. /**
  12307. * Represents a pose-enabled controller
  12308. */
  12309. static POSE_ENABLED: number;
  12310. /**
  12311. * Represents an Dual Shock controller
  12312. */
  12313. static DUALSHOCK: number;
  12314. /**
  12315. * Specifies whether the left control stick should be Y-inverted
  12316. */
  12317. protected _invertLeftStickY: boolean;
  12318. /**
  12319. * Specifies if the gamepad has been connected
  12320. */
  12321. readonly isConnected: boolean;
  12322. /**
  12323. * Initializes the gamepad
  12324. * @param id The id of the gamepad
  12325. * @param index The index of the gamepad
  12326. * @param browserGamepad The browser gamepad
  12327. * @param leftStickX The x component of the left joystick
  12328. * @param leftStickY The y component of the left joystick
  12329. * @param rightStickX The x component of the right joystick
  12330. * @param rightStickY The y component of the right joystick
  12331. */
  12332. constructor(
  12333. /**
  12334. * The id of the gamepad
  12335. */
  12336. id: string,
  12337. /**
  12338. * The index of the gamepad
  12339. */
  12340. index: number,
  12341. /**
  12342. * The browser gamepad
  12343. */
  12344. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12345. /**
  12346. * Callback triggered when the left joystick has changed
  12347. * @param callback
  12348. */
  12349. onleftstickchanged(callback: (values: StickValues) => void): void;
  12350. /**
  12351. * Callback triggered when the right joystick has changed
  12352. * @param callback
  12353. */
  12354. onrightstickchanged(callback: (values: StickValues) => void): void;
  12355. /**
  12356. * Gets the left joystick
  12357. */
  12358. /**
  12359. * Sets the left joystick values
  12360. */
  12361. leftStick: StickValues;
  12362. /**
  12363. * Gets the right joystick
  12364. */
  12365. /**
  12366. * Sets the right joystick value
  12367. */
  12368. rightStick: StickValues;
  12369. /**
  12370. * Updates the gamepad joystick positions
  12371. */
  12372. update(): void;
  12373. /**
  12374. * Disposes the gamepad
  12375. */
  12376. dispose(): void;
  12377. }
  12378. /**
  12379. * Represents a generic gamepad
  12380. */
  12381. export class GenericPad extends Gamepad {
  12382. private _buttons;
  12383. private _onbuttondown;
  12384. private _onbuttonup;
  12385. /**
  12386. * Observable triggered when a button has been pressed
  12387. */
  12388. onButtonDownObservable: Observable<number>;
  12389. /**
  12390. * Observable triggered when a button has been released
  12391. */
  12392. onButtonUpObservable: Observable<number>;
  12393. /**
  12394. * Callback triggered when a button has been pressed
  12395. * @param callback Called when a button has been pressed
  12396. */
  12397. onbuttondown(callback: (buttonPressed: number) => void): void;
  12398. /**
  12399. * Callback triggered when a button has been released
  12400. * @param callback Called when a button has been released
  12401. */
  12402. onbuttonup(callback: (buttonReleased: number) => void): void;
  12403. /**
  12404. * Initializes the generic gamepad
  12405. * @param id The id of the generic gamepad
  12406. * @param index The index of the generic gamepad
  12407. * @param browserGamepad The browser gamepad
  12408. */
  12409. constructor(id: string, index: number, browserGamepad: any);
  12410. private _setButtonValue;
  12411. /**
  12412. * Updates the generic gamepad
  12413. */
  12414. update(): void;
  12415. /**
  12416. * Disposes the generic gamepad
  12417. */
  12418. dispose(): void;
  12419. }
  12420. }
  12421. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12422. import { Nullable } from "babylonjs/types";
  12423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12424. import { Scene } from "babylonjs/scene";
  12425. module "babylonjs/Engines/engine" {
  12426. interface Engine {
  12427. /**
  12428. * Creates a raw texture
  12429. * @param data defines the data to store in the texture
  12430. * @param width defines the width of the texture
  12431. * @param height defines the height of the texture
  12432. * @param format defines the format of the data
  12433. * @param generateMipMaps defines if the engine should generate the mip levels
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12436. * @param compression defines the compression used (null by default)
  12437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12438. * @returns the raw texture inside an InternalTexture
  12439. */
  12440. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12441. /**
  12442. * Update a raw texture
  12443. * @param texture defines the texture to update
  12444. * @param data defines the data to store in the texture
  12445. * @param format defines the format of the data
  12446. * @param invertY defines if data must be stored with Y axis inverted
  12447. */
  12448. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12449. /**
  12450. * Update a raw texture
  12451. * @param texture defines the texture to update
  12452. * @param data defines the data to store in the texture
  12453. * @param format defines the format of the data
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param compression defines the compression used (null by default)
  12456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12457. */
  12458. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12459. /**
  12460. * Creates a new raw cube texture
  12461. * @param data defines the array of data to use to create each face
  12462. * @param size defines the size of the textures
  12463. * @param format defines the format of the data
  12464. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12465. * @param generateMipMaps defines if the engine should generate the mip levels
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12468. * @param compression defines the compression used (null by default)
  12469. * @returns the cube texture as an InternalTexture
  12470. */
  12471. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12472. /**
  12473. * Update a raw cube texture
  12474. * @param texture defines the texture to udpdate
  12475. * @param data defines the data to store
  12476. * @param format defines the data format
  12477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12478. * @param invertY defines if data must be stored with Y axis inverted
  12479. */
  12480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12481. /**
  12482. * Update a raw cube texture
  12483. * @param texture defines the texture to udpdate
  12484. * @param data defines the data to store
  12485. * @param format defines the data format
  12486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12487. * @param invertY defines if data must be stored with Y axis inverted
  12488. * @param compression defines the compression used (null by default)
  12489. */
  12490. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12491. /**
  12492. * Update a raw cube texture
  12493. * @param texture defines the texture to udpdate
  12494. * @param data defines the data to store
  12495. * @param format defines the data format
  12496. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12497. * @param invertY defines if data must be stored with Y axis inverted
  12498. * @param compression defines the compression used (null by default)
  12499. * @param level defines which level of the texture to update
  12500. */
  12501. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12502. /**
  12503. * Creates a new raw cube texture from a specified url
  12504. * @param url defines the url where the data is located
  12505. * @param scene defines the current scene
  12506. * @param size defines the size of the textures
  12507. * @param format defines the format of the data
  12508. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12509. * @param noMipmap defines if the engine should avoid generating the mip levels
  12510. * @param callback defines a callback used to extract texture data from loaded data
  12511. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12512. * @param onLoad defines a callback called when texture is loaded
  12513. * @param onError defines a callback called if there is an error
  12514. * @returns the cube texture as an InternalTexture
  12515. */
  12516. 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;
  12517. /**
  12518. * Creates a new raw cube texture from a specified url
  12519. * @param url defines the url where the data is located
  12520. * @param scene defines the current scene
  12521. * @param size defines the size of the textures
  12522. * @param format defines the format of the data
  12523. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12524. * @param noMipmap defines if the engine should avoid generating the mip levels
  12525. * @param callback defines a callback used to extract texture data from loaded data
  12526. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12527. * @param onLoad defines a callback called when texture is loaded
  12528. * @param onError defines a callback called if there is an error
  12529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @returns the cube texture as an InternalTexture
  12532. */
  12533. 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;
  12534. /**
  12535. * Creates a new raw 3D texture
  12536. * @param data defines the data used to create the texture
  12537. * @param width defines the width of the texture
  12538. * @param height defines the height of the texture
  12539. * @param depth defines the depth of the texture
  12540. * @param format defines the format of the texture
  12541. * @param generateMipMaps defines if the engine must generate mip levels
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12544. * @param compression defines the compressed used (can be null)
  12545. * @param textureType defines the compressed used (can be null)
  12546. * @returns a new raw 3D texture (stored in an InternalTexture)
  12547. */
  12548. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12549. /**
  12550. * Update a raw 3D texture
  12551. * @param texture defines the texture to update
  12552. * @param data defines the data to store
  12553. * @param format defines the data format
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. */
  12556. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12557. /**
  12558. * Update a raw 3D texture
  12559. * @param texture defines the texture to update
  12560. * @param data defines the data to store
  12561. * @param format defines the data format
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param compression defines the used compression (can be null)
  12564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12565. */
  12566. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12567. }
  12568. }
  12569. }
  12570. declare module "babylonjs/Materials/Textures/rawTexture" {
  12571. import { Scene } from "babylonjs/scene";
  12572. import { Texture } from "babylonjs/Materials/Textures/texture";
  12573. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12574. /**
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. */
  12579. export class RawTexture extends Texture {
  12580. /**
  12581. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. */
  12583. format: number;
  12584. private _engine;
  12585. /**
  12586. * Instantiates a new RawTexture.
  12587. * Raw texture can help creating a texture directly from an array of data.
  12588. * This can be super useful if you either get the data from an uncompressed source or
  12589. * if you wish to create your texture pixel by pixel.
  12590. * @param data define the array of data to use to create the texture
  12591. * @param width define the width of the texture
  12592. * @param height define the height of the texture
  12593. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12594. * @param scene define the scene the texture belongs to
  12595. * @param generateMipMaps define whether mip maps should be generated or not
  12596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12599. */
  12600. constructor(data: ArrayBufferView, width: number, height: number,
  12601. /**
  12602. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12603. */
  12604. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12605. /**
  12606. * Updates the texture underlying data.
  12607. * @param data Define the new data of the texture
  12608. */
  12609. update(data: ArrayBufferView): void;
  12610. /**
  12611. * Creates a luminance texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance texture
  12620. */
  12621. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates a luminance alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the luminance alpha texture
  12632. */
  12633. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates an alpha texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @returns the alpha texture
  12644. */
  12645. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12646. /**
  12647. * Creates a RGB texture from some data.
  12648. * @param data Define the texture data
  12649. * @param width Define the width of the texture
  12650. * @param height Define the height of the texture
  12651. * @param scene Define the scene the texture belongs to
  12652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. * @returns the RGB alpha texture
  12657. */
  12658. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12659. /**
  12660. * Creates a RGBA texture from some data.
  12661. * @param data Define the texture data
  12662. * @param width Define the width of the texture
  12663. * @param height Define the height of the texture
  12664. * @param scene Define the scene the texture belongs to
  12665. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12668. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12669. * @returns the RGBA texture
  12670. */
  12671. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12672. /**
  12673. * Creates a R texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12682. * @returns the R texture
  12683. */
  12684. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12685. }
  12686. }
  12687. declare module "babylonjs/Maths/math.size" {
  12688. /**
  12689. * Interface for the size containing width and height
  12690. */
  12691. export interface ISize {
  12692. /**
  12693. * Width
  12694. */
  12695. width: number;
  12696. /**
  12697. * Heighht
  12698. */
  12699. height: number;
  12700. }
  12701. /**
  12702. * Size containing widht and height
  12703. */
  12704. export class Size implements ISize {
  12705. /**
  12706. * Width
  12707. */
  12708. width: number;
  12709. /**
  12710. * Height
  12711. */
  12712. height: number;
  12713. /**
  12714. * Creates a Size object from the given width and height (floats).
  12715. * @param width width of the new size
  12716. * @param height height of the new size
  12717. */
  12718. constructor(width: number, height: number);
  12719. /**
  12720. * Returns a string with the Size width and height
  12721. * @returns a string with the Size width and height
  12722. */
  12723. toString(): string;
  12724. /**
  12725. * "Size"
  12726. * @returns the string "Size"
  12727. */
  12728. getClassName(): string;
  12729. /**
  12730. * Returns the Size hash code.
  12731. * @returns a hash code for a unique width and height
  12732. */
  12733. getHashCode(): number;
  12734. /**
  12735. * Updates the current size from the given one.
  12736. * @param src the given size
  12737. */
  12738. copyFrom(src: Size): void;
  12739. /**
  12740. * Updates in place the current Size from the given floats.
  12741. * @param width width of the new size
  12742. * @param height height of the new size
  12743. * @returns the updated Size.
  12744. */
  12745. copyFromFloats(width: number, height: number): Size;
  12746. /**
  12747. * Updates in place the current Size from the given floats.
  12748. * @param width width to set
  12749. * @param height height to set
  12750. * @returns the updated Size.
  12751. */
  12752. set(width: number, height: number): Size;
  12753. /**
  12754. * Multiplies the width and height by numbers
  12755. * @param w factor to multiple the width by
  12756. * @param h factor to multiple the height by
  12757. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12758. */
  12759. multiplyByFloats(w: number, h: number): Size;
  12760. /**
  12761. * Clones the size
  12762. * @returns a new Size copied from the given one.
  12763. */
  12764. clone(): Size;
  12765. /**
  12766. * True if the current Size and the given one width and height are strictly equal.
  12767. * @param other the other size to compare against
  12768. * @returns True if the current Size and the given one width and height are strictly equal.
  12769. */
  12770. equals(other: Size): boolean;
  12771. /**
  12772. * The surface of the Size : width * height (float).
  12773. */
  12774. readonly surface: number;
  12775. /**
  12776. * Create a new size of zero
  12777. * @returns a new Size set to (0.0, 0.0)
  12778. */
  12779. static Zero(): Size;
  12780. /**
  12781. * Sums the width and height of two sizes
  12782. * @param otherSize size to add to this size
  12783. * @returns a new Size set as the addition result of the current Size and the given one.
  12784. */
  12785. add(otherSize: Size): Size;
  12786. /**
  12787. * Subtracts the width and height of two
  12788. * @param otherSize size to subtract to this size
  12789. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12790. */
  12791. subtract(otherSize: Size): Size;
  12792. /**
  12793. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12794. * @param start starting size to lerp between
  12795. * @param end end size to lerp between
  12796. * @param amount amount to lerp between the start and end values
  12797. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12798. */
  12799. static Lerp(start: Size, end: Size, amount: number): Size;
  12800. }
  12801. }
  12802. declare module "babylonjs/Animations/runtimeAnimation" {
  12803. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12804. import { Animatable } from "babylonjs/Animations/animatable";
  12805. import { Scene } from "babylonjs/scene";
  12806. /**
  12807. * Defines a runtime animation
  12808. */
  12809. export class RuntimeAnimation {
  12810. private _events;
  12811. /**
  12812. * The current frame of the runtime animation
  12813. */
  12814. private _currentFrame;
  12815. /**
  12816. * The animation used by the runtime animation
  12817. */
  12818. private _animation;
  12819. /**
  12820. * The target of the runtime animation
  12821. */
  12822. private _target;
  12823. /**
  12824. * The initiating animatable
  12825. */
  12826. private _host;
  12827. /**
  12828. * The original value of the runtime animation
  12829. */
  12830. private _originalValue;
  12831. /**
  12832. * The original blend value of the runtime animation
  12833. */
  12834. private _originalBlendValue;
  12835. /**
  12836. * The offsets cache of the runtime animation
  12837. */
  12838. private _offsetsCache;
  12839. /**
  12840. * The high limits cache of the runtime animation
  12841. */
  12842. private _highLimitsCache;
  12843. /**
  12844. * Specifies if the runtime animation has been stopped
  12845. */
  12846. private _stopped;
  12847. /**
  12848. * The blending factor of the runtime animation
  12849. */
  12850. private _blendingFactor;
  12851. /**
  12852. * The BabylonJS scene
  12853. */
  12854. private _scene;
  12855. /**
  12856. * The current value of the runtime animation
  12857. */
  12858. private _currentValue;
  12859. /** @hidden */
  12860. _animationState: _IAnimationState;
  12861. /**
  12862. * The active target of the runtime animation
  12863. */
  12864. private _activeTargets;
  12865. private _currentActiveTarget;
  12866. private _directTarget;
  12867. /**
  12868. * The target path of the runtime animation
  12869. */
  12870. private _targetPath;
  12871. /**
  12872. * The weight of the runtime animation
  12873. */
  12874. private _weight;
  12875. /**
  12876. * The ratio offset of the runtime animation
  12877. */
  12878. private _ratioOffset;
  12879. /**
  12880. * The previous delay of the runtime animation
  12881. */
  12882. private _previousDelay;
  12883. /**
  12884. * The previous ratio of the runtime animation
  12885. */
  12886. private _previousRatio;
  12887. private _enableBlending;
  12888. private _keys;
  12889. private _minFrame;
  12890. private _maxFrame;
  12891. private _minValue;
  12892. private _maxValue;
  12893. private _targetIsArray;
  12894. /**
  12895. * Gets the current frame of the runtime animation
  12896. */
  12897. readonly currentFrame: number;
  12898. /**
  12899. * Gets the weight of the runtime animation
  12900. */
  12901. readonly weight: number;
  12902. /**
  12903. * Gets the current value of the runtime animation
  12904. */
  12905. readonly currentValue: any;
  12906. /**
  12907. * Gets the target path of the runtime animation
  12908. */
  12909. readonly targetPath: string;
  12910. /**
  12911. * Gets the actual target of the runtime animation
  12912. */
  12913. readonly target: any;
  12914. /** @hidden */
  12915. _onLoop: () => void;
  12916. /**
  12917. * Create a new RuntimeAnimation object
  12918. * @param target defines the target of the animation
  12919. * @param animation defines the source animation object
  12920. * @param scene defines the hosting scene
  12921. * @param host defines the initiating Animatable
  12922. */
  12923. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12924. private _preparePath;
  12925. /**
  12926. * Gets the animation from the runtime animation
  12927. */
  12928. readonly animation: Animation;
  12929. /**
  12930. * Resets the runtime animation to the beginning
  12931. * @param restoreOriginal defines whether to restore the target property to the original value
  12932. */
  12933. reset(restoreOriginal?: boolean): void;
  12934. /**
  12935. * Specifies if the runtime animation is stopped
  12936. * @returns Boolean specifying if the runtime animation is stopped
  12937. */
  12938. isStopped(): boolean;
  12939. /**
  12940. * Disposes of the runtime animation
  12941. */
  12942. dispose(): void;
  12943. /**
  12944. * Apply the interpolated value to the target
  12945. * @param currentValue defines the value computed by the animation
  12946. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12947. */
  12948. setValue(currentValue: any, weight: number): void;
  12949. private _getOriginalValues;
  12950. private _setValue;
  12951. /**
  12952. * Gets the loop pmode of the runtime animation
  12953. * @returns Loop Mode
  12954. */
  12955. private _getCorrectLoopMode;
  12956. /**
  12957. * Move the current animation to a given frame
  12958. * @param frame defines the frame to move to
  12959. */
  12960. goToFrame(frame: number): void;
  12961. /**
  12962. * @hidden Internal use only
  12963. */
  12964. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12965. /**
  12966. * Execute the current animation
  12967. * @param delay defines the delay to add to the current frame
  12968. * @param from defines the lower bound of the animation range
  12969. * @param to defines the upper bound of the animation range
  12970. * @param loop defines if the current animation must loop
  12971. * @param speedRatio defines the current speed ratio
  12972. * @param weight defines the weight of the animation (default is -1 so no weight)
  12973. * @param onLoop optional callback called when animation loops
  12974. * @returns a boolean indicating if the animation is running
  12975. */
  12976. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12977. }
  12978. }
  12979. declare module "babylonjs/Animations/animatable" {
  12980. import { Animation } from "babylonjs/Animations/animation";
  12981. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12982. import { Nullable } from "babylonjs/types";
  12983. import { Observable } from "babylonjs/Misc/observable";
  12984. import { Scene } from "babylonjs/scene";
  12985. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12986. import { Node } from "babylonjs/node";
  12987. /**
  12988. * Class used to store an actual running animation
  12989. */
  12990. export class Animatable {
  12991. /** defines the target object */
  12992. target: any;
  12993. /** defines the starting frame number (default is 0) */
  12994. fromFrame: number;
  12995. /** defines the ending frame number (default is 100) */
  12996. toFrame: number;
  12997. /** defines if the animation must loop (default is false) */
  12998. loopAnimation: boolean;
  12999. /** defines a callback to call when animation ends if it is not looping */
  13000. onAnimationEnd?: (() => void) | null | undefined;
  13001. /** defines a callback to call when animation loops */
  13002. onAnimationLoop?: (() => void) | null | undefined;
  13003. private _localDelayOffset;
  13004. private _pausedDelay;
  13005. private _runtimeAnimations;
  13006. private _paused;
  13007. private _scene;
  13008. private _speedRatio;
  13009. private _weight;
  13010. private _syncRoot;
  13011. /**
  13012. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13013. * This will only apply for non looping animation (default is true)
  13014. */
  13015. disposeOnEnd: boolean;
  13016. /**
  13017. * Gets a boolean indicating if the animation has started
  13018. */
  13019. animationStarted: boolean;
  13020. /**
  13021. * Observer raised when the animation ends
  13022. */
  13023. onAnimationEndObservable: Observable<Animatable>;
  13024. /**
  13025. * Observer raised when the animation loops
  13026. */
  13027. onAnimationLoopObservable: Observable<Animatable>;
  13028. /**
  13029. * Gets the root Animatable used to synchronize and normalize animations
  13030. */
  13031. readonly syncRoot: Nullable<Animatable>;
  13032. /**
  13033. * Gets the current frame of the first RuntimeAnimation
  13034. * Used to synchronize Animatables
  13035. */
  13036. readonly masterFrame: number;
  13037. /**
  13038. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13039. */
  13040. weight: number;
  13041. /**
  13042. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13043. */
  13044. speedRatio: number;
  13045. /**
  13046. * Creates a new Animatable
  13047. * @param scene defines the hosting scene
  13048. * @param target defines the target object
  13049. * @param fromFrame defines the starting frame number (default is 0)
  13050. * @param toFrame defines the ending frame number (default is 100)
  13051. * @param loopAnimation defines if the animation must loop (default is false)
  13052. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13053. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13054. * @param animations defines a group of animation to add to the new Animatable
  13055. * @param onAnimationLoop defines a callback to call when animation loops
  13056. */
  13057. constructor(scene: Scene,
  13058. /** defines the target object */
  13059. target: any,
  13060. /** defines the starting frame number (default is 0) */
  13061. fromFrame?: number,
  13062. /** defines the ending frame number (default is 100) */
  13063. toFrame?: number,
  13064. /** defines if the animation must loop (default is false) */
  13065. loopAnimation?: boolean, speedRatio?: number,
  13066. /** defines a callback to call when animation ends if it is not looping */
  13067. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13068. /** defines a callback to call when animation loops */
  13069. onAnimationLoop?: (() => void) | null | undefined);
  13070. /**
  13071. * Synchronize and normalize current Animatable with a source Animatable
  13072. * This is useful when using animation weights and when animations are not of the same length
  13073. * @param root defines the root Animatable to synchronize with
  13074. * @returns the current Animatable
  13075. */
  13076. syncWith(root: Animatable): Animatable;
  13077. /**
  13078. * Gets the list of runtime animations
  13079. * @returns an array of RuntimeAnimation
  13080. */
  13081. getAnimations(): RuntimeAnimation[];
  13082. /**
  13083. * Adds more animations to the current animatable
  13084. * @param target defines the target of the animations
  13085. * @param animations defines the new animations to add
  13086. */
  13087. appendAnimations(target: any, animations: Animation[]): void;
  13088. /**
  13089. * Gets the source animation for a specific property
  13090. * @param property defines the propertyu to look for
  13091. * @returns null or the source animation for the given property
  13092. */
  13093. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13094. /**
  13095. * Gets the runtime animation for a specific property
  13096. * @param property defines the propertyu to look for
  13097. * @returns null or the runtime animation for the given property
  13098. */
  13099. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13100. /**
  13101. * Resets the animatable to its original state
  13102. */
  13103. reset(): void;
  13104. /**
  13105. * Allows the animatable to blend with current running animations
  13106. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13107. * @param blendingSpeed defines the blending speed to use
  13108. */
  13109. enableBlending(blendingSpeed: number): void;
  13110. /**
  13111. * Disable animation blending
  13112. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13113. */
  13114. disableBlending(): void;
  13115. /**
  13116. * Jump directly to a given frame
  13117. * @param frame defines the frame to jump to
  13118. */
  13119. goToFrame(frame: number): void;
  13120. /**
  13121. * Pause the animation
  13122. */
  13123. pause(): void;
  13124. /**
  13125. * Restart the animation
  13126. */
  13127. restart(): void;
  13128. private _raiseOnAnimationEnd;
  13129. /**
  13130. * Stop and delete the current animation
  13131. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13132. * @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)
  13133. */
  13134. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13135. /**
  13136. * Wait asynchronously for the animation to end
  13137. * @returns a promise which will be fullfilled when the animation ends
  13138. */
  13139. waitAsync(): Promise<Animatable>;
  13140. /** @hidden */
  13141. _animate(delay: number): boolean;
  13142. }
  13143. module "babylonjs/scene" {
  13144. interface Scene {
  13145. /** @hidden */
  13146. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13147. /** @hidden */
  13148. _processLateAnimationBindingsForMatrices(holder: {
  13149. totalWeight: number;
  13150. animations: RuntimeAnimation[];
  13151. originalValue: Matrix;
  13152. }): any;
  13153. /** @hidden */
  13154. _processLateAnimationBindingsForQuaternions(holder: {
  13155. totalWeight: number;
  13156. animations: RuntimeAnimation[];
  13157. originalValue: Quaternion;
  13158. }, refQuaternion: Quaternion): Quaternion;
  13159. /** @hidden */
  13160. _processLateAnimationBindings(): void;
  13161. /**
  13162. * Will start the animation sequence of a given target
  13163. * @param target defines the target
  13164. * @param from defines from which frame should animation start
  13165. * @param to defines until which frame should animation run.
  13166. * @param weight defines the weight to apply to the animation (1.0 by default)
  13167. * @param loop defines if the animation loops
  13168. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13169. * @param onAnimationEnd defines the function to be executed when the animation ends
  13170. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13171. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13172. * @param onAnimationLoop defines the callback to call when an animation loops
  13173. * @returns the animatable object created for this animation
  13174. */
  13175. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13176. /**
  13177. * Will start the animation sequence of a given target
  13178. * @param target defines the target
  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 animate 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 animatable object created for this animation
  13189. */
  13190. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13191. /**
  13192. * Will start the animation sequence of a given target and its hierarchy
  13193. * @param target defines the target
  13194. * @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.
  13195. * @param from defines from which frame should animation start
  13196. * @param to defines until which frame should animation run.
  13197. * @param loop defines if the animation loops
  13198. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13199. * @param onAnimationEnd defines the function to be executed when the animation ends
  13200. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13201. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13202. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13203. * @param onAnimationLoop defines the callback to call when an animation loops
  13204. * @returns the list of created animatables
  13205. */
  13206. 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[];
  13207. /**
  13208. * Begin a new animation on a given node
  13209. * @param target defines the target where the animation will take place
  13210. * @param animations defines the list of animations to start
  13211. * @param from defines the initial value
  13212. * @param to defines the final value
  13213. * @param loop defines if you want animation to loop (off by default)
  13214. * @param speedRatio defines the speed ratio to apply to all animations
  13215. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13216. * @param onAnimationLoop defines the callback to call when an animation loops
  13217. * @returns the list of created animatables
  13218. */
  13219. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13220. /**
  13221. * Begin a new animation on a given node and its hierarchy
  13222. * @param target defines the root node where the animation will take place
  13223. * @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.
  13224. * @param animations defines the list of animations to start
  13225. * @param from defines the initial value
  13226. * @param to defines the final value
  13227. * @param loop defines if you want animation to loop (off by default)
  13228. * @param speedRatio defines the speed ratio to apply to all animations
  13229. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13230. * @param onAnimationLoop defines the callback to call when an animation loops
  13231. * @returns the list of animatables created for all nodes
  13232. */
  13233. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13234. /**
  13235. * Gets the animatable associated with a specific target
  13236. * @param target defines the target of the animatable
  13237. * @returns the required animatable if found
  13238. */
  13239. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13240. /**
  13241. * Gets all animatables associated with a given target
  13242. * @param target defines the target to look animatables for
  13243. * @returns an array of Animatables
  13244. */
  13245. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13246. /**
  13247. * Stops and removes all animations that have been applied to the scene
  13248. */
  13249. stopAllAnimations(): void;
  13250. }
  13251. }
  13252. module "babylonjs/Bones/bone" {
  13253. interface Bone {
  13254. /**
  13255. * Copy an animation range from another bone
  13256. * @param source defines the source bone
  13257. * @param rangeName defines the range name to copy
  13258. * @param frameOffset defines the frame offset
  13259. * @param rescaleAsRequired defines if rescaling must be applied if required
  13260. * @param skelDimensionsRatio defines the scaling ratio
  13261. * @returns true if operation was successful
  13262. */
  13263. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13264. }
  13265. }
  13266. }
  13267. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13268. /**
  13269. * Class used to override all child animations of a given target
  13270. */
  13271. export class AnimationPropertiesOverride {
  13272. /**
  13273. * Gets or sets a value indicating if animation blending must be used
  13274. */
  13275. enableBlending: boolean;
  13276. /**
  13277. * Gets or sets the blending speed to use when enableBlending is true
  13278. */
  13279. blendingSpeed: number;
  13280. /**
  13281. * Gets or sets the default loop mode to use
  13282. */
  13283. loopMode: number;
  13284. }
  13285. }
  13286. declare module "babylonjs/Bones/skeleton" {
  13287. import { Bone } from "babylonjs/Bones/bone";
  13288. import { Observable } from "babylonjs/Misc/observable";
  13289. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Nullable } from "babylonjs/types";
  13292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13293. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13294. import { Animatable } from "babylonjs/Animations/animatable";
  13295. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13296. import { Animation } from "babylonjs/Animations/animation";
  13297. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13298. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13300. /**
  13301. * Class used to handle skinning animations
  13302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13303. */
  13304. export class Skeleton implements IAnimatable {
  13305. /** defines the skeleton name */
  13306. name: string;
  13307. /** defines the skeleton Id */
  13308. id: string;
  13309. /**
  13310. * Defines the list of child bones
  13311. */
  13312. bones: Bone[];
  13313. /**
  13314. * Defines an estimate of the dimension of the skeleton at rest
  13315. */
  13316. dimensionsAtRest: Vector3;
  13317. /**
  13318. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13319. */
  13320. needInitialSkinMatrix: boolean;
  13321. /**
  13322. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13323. */
  13324. overrideMesh: Nullable<AbstractMesh>;
  13325. /**
  13326. * Gets the list of animations attached to this skeleton
  13327. */
  13328. animations: Array<Animation>;
  13329. private _scene;
  13330. private _isDirty;
  13331. private _transformMatrices;
  13332. private _transformMatrixTexture;
  13333. private _meshesWithPoseMatrix;
  13334. private _animatables;
  13335. private _identity;
  13336. private _synchronizedWithMesh;
  13337. private _ranges;
  13338. private _lastAbsoluteTransformsUpdateId;
  13339. private _canUseTextureForBones;
  13340. private _uniqueId;
  13341. /** @hidden */
  13342. _numBonesWithLinkedTransformNode: number;
  13343. /** @hidden */
  13344. _hasWaitingData: Nullable<boolean>;
  13345. /**
  13346. * Specifies if the skeleton should be serialized
  13347. */
  13348. doNotSerialize: boolean;
  13349. private _useTextureToStoreBoneMatrices;
  13350. /**
  13351. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13352. * Please note that this option is not available if the hardware does not support it
  13353. */
  13354. useTextureToStoreBoneMatrices: boolean;
  13355. private _animationPropertiesOverride;
  13356. /**
  13357. * Gets or sets the animation properties override
  13358. */
  13359. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13360. /**
  13361. * List of inspectable custom properties (used by the Inspector)
  13362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13363. */
  13364. inspectableCustomProperties: IInspectable[];
  13365. /**
  13366. * An observable triggered before computing the skeleton's matrices
  13367. */
  13368. onBeforeComputeObservable: Observable<Skeleton>;
  13369. /**
  13370. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13371. */
  13372. readonly isUsingTextureForMatrices: boolean;
  13373. /**
  13374. * Gets the unique ID of this skeleton
  13375. */
  13376. readonly uniqueId: number;
  13377. /**
  13378. * Creates a new skeleton
  13379. * @param name defines the skeleton name
  13380. * @param id defines the skeleton Id
  13381. * @param scene defines the hosting scene
  13382. */
  13383. constructor(
  13384. /** defines the skeleton name */
  13385. name: string,
  13386. /** defines the skeleton Id */
  13387. id: string, scene: Scene);
  13388. /**
  13389. * Gets the current object class name.
  13390. * @return the class name
  13391. */
  13392. getClassName(): string;
  13393. /**
  13394. * Returns an array containing the root bones
  13395. * @returns an array containing the root bones
  13396. */
  13397. getChildren(): Array<Bone>;
  13398. /**
  13399. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13400. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13401. * @returns a Float32Array containing matrices data
  13402. */
  13403. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13404. /**
  13405. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13406. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13407. * @returns a raw texture containing the data
  13408. */
  13409. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13410. /**
  13411. * Gets the current hosting scene
  13412. * @returns a scene object
  13413. */
  13414. getScene(): Scene;
  13415. /**
  13416. * Gets a string representing the current skeleton data
  13417. * @param fullDetails defines a boolean indicating if we want a verbose version
  13418. * @returns a string representing the current skeleton data
  13419. */
  13420. toString(fullDetails?: boolean): string;
  13421. /**
  13422. * Get bone's index searching by name
  13423. * @param name defines bone's name to search for
  13424. * @return the indice of the bone. Returns -1 if not found
  13425. */
  13426. getBoneIndexByName(name: string): number;
  13427. /**
  13428. * Creater a new animation range
  13429. * @param name defines the name of the range
  13430. * @param from defines the start key
  13431. * @param to defines the end key
  13432. */
  13433. createAnimationRange(name: string, from: number, to: number): void;
  13434. /**
  13435. * Delete a specific animation range
  13436. * @param name defines the name of the range
  13437. * @param deleteFrames defines if frames must be removed as well
  13438. */
  13439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13440. /**
  13441. * Gets a specific animation range
  13442. * @param name defines the name of the range to look for
  13443. * @returns the requested animation range or null if not found
  13444. */
  13445. getAnimationRange(name: string): Nullable<AnimationRange>;
  13446. /**
  13447. * Gets the list of all animation ranges defined on this skeleton
  13448. * @returns an array
  13449. */
  13450. getAnimationRanges(): Nullable<AnimationRange>[];
  13451. /**
  13452. * Copy animation range from a source skeleton.
  13453. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13454. * @param source defines the source skeleton
  13455. * @param name defines the name of the range to copy
  13456. * @param rescaleAsRequired defines if rescaling must be applied if required
  13457. * @returns true if operation was successful
  13458. */
  13459. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13460. /**
  13461. * Forces the skeleton to go to rest pose
  13462. */
  13463. returnToRest(): void;
  13464. private _getHighestAnimationFrame;
  13465. /**
  13466. * Begin a specific animation range
  13467. * @param name defines the name of the range to start
  13468. * @param loop defines if looping must be turned on (false by default)
  13469. * @param speedRatio defines the speed ratio to apply (1 by default)
  13470. * @param onAnimationEnd defines a callback which will be called when animation will end
  13471. * @returns a new animatable
  13472. */
  13473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13474. /** @hidden */
  13475. _markAsDirty(): void;
  13476. /** @hidden */
  13477. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13478. /** @hidden */
  13479. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13480. private _computeTransformMatrices;
  13481. /**
  13482. * Build all resources required to render a skeleton
  13483. */
  13484. prepare(): void;
  13485. /**
  13486. * Gets the list of animatables currently running for this skeleton
  13487. * @returns an array of animatables
  13488. */
  13489. getAnimatables(): IAnimatable[];
  13490. /**
  13491. * Clone the current skeleton
  13492. * @param name defines the name of the new skeleton
  13493. * @param id defines the id of the new skeleton
  13494. * @returns the new skeleton
  13495. */
  13496. clone(name: string, id: string): Skeleton;
  13497. /**
  13498. * Enable animation blending for this skeleton
  13499. * @param blendingSpeed defines the blending speed to apply
  13500. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13501. */
  13502. enableBlending(blendingSpeed?: number): void;
  13503. /**
  13504. * Releases all resources associated with the current skeleton
  13505. */
  13506. dispose(): void;
  13507. /**
  13508. * Serialize the skeleton in a JSON object
  13509. * @returns a JSON object
  13510. */
  13511. serialize(): any;
  13512. /**
  13513. * Creates a new skeleton from serialized data
  13514. * @param parsedSkeleton defines the serialized data
  13515. * @param scene defines the hosting scene
  13516. * @returns a new skeleton
  13517. */
  13518. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13519. /**
  13520. * Compute all node absolute transforms
  13521. * @param forceUpdate defines if computation must be done even if cache is up to date
  13522. */
  13523. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13524. /**
  13525. * Gets the root pose matrix
  13526. * @returns a matrix
  13527. */
  13528. getPoseMatrix(): Nullable<Matrix>;
  13529. /**
  13530. * Sorts bones per internal index
  13531. */
  13532. sortBones(): void;
  13533. private _sortBones;
  13534. }
  13535. }
  13536. declare module "babylonjs/Bones/bone" {
  13537. import { Skeleton } from "babylonjs/Bones/skeleton";
  13538. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13539. import { Nullable } from "babylonjs/types";
  13540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13542. import { Node } from "babylonjs/node";
  13543. import { Space } from "babylonjs/Maths/math.axis";
  13544. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13545. /**
  13546. * Class used to store bone information
  13547. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13548. */
  13549. export class Bone extends Node {
  13550. /**
  13551. * defines the bone name
  13552. */
  13553. name: string;
  13554. private static _tmpVecs;
  13555. private static _tmpQuat;
  13556. private static _tmpMats;
  13557. /**
  13558. * Gets the list of child bones
  13559. */
  13560. children: Bone[];
  13561. /** Gets the animations associated with this bone */
  13562. animations: import("babylonjs/Animations/animation").Animation[];
  13563. /**
  13564. * Gets or sets bone length
  13565. */
  13566. length: number;
  13567. /**
  13568. * @hidden Internal only
  13569. * Set this value to map this bone to a different index in the transform matrices
  13570. * Set this value to -1 to exclude the bone from the transform matrices
  13571. */
  13572. _index: Nullable<number>;
  13573. private _skeleton;
  13574. private _localMatrix;
  13575. private _restPose;
  13576. private _baseMatrix;
  13577. private _absoluteTransform;
  13578. private _invertedAbsoluteTransform;
  13579. private _parent;
  13580. private _scalingDeterminant;
  13581. private _worldTransform;
  13582. private _localScaling;
  13583. private _localRotation;
  13584. private _localPosition;
  13585. private _needToDecompose;
  13586. private _needToCompose;
  13587. /** @hidden */
  13588. _linkedTransformNode: Nullable<TransformNode>;
  13589. /** @hidden */
  13590. _waitingTransformNodeId: Nullable<string>;
  13591. /** @hidden */
  13592. /** @hidden */
  13593. _matrix: Matrix;
  13594. /**
  13595. * Create a new bone
  13596. * @param name defines the bone name
  13597. * @param skeleton defines the parent skeleton
  13598. * @param parentBone defines the parent (can be null if the bone is the root)
  13599. * @param localMatrix defines the local matrix
  13600. * @param restPose defines the rest pose matrix
  13601. * @param baseMatrix defines the base matrix
  13602. * @param index defines index of the bone in the hiearchy
  13603. */
  13604. constructor(
  13605. /**
  13606. * defines the bone name
  13607. */
  13608. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13609. /**
  13610. * Gets the current object class name.
  13611. * @return the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Gets the parent skeleton
  13616. * @returns a skeleton
  13617. */
  13618. getSkeleton(): Skeleton;
  13619. /**
  13620. * Gets parent bone
  13621. * @returns a bone or null if the bone is the root of the bone hierarchy
  13622. */
  13623. getParent(): Nullable<Bone>;
  13624. /**
  13625. * Returns an array containing the root bones
  13626. * @returns an array containing the root bones
  13627. */
  13628. getChildren(): Array<Bone>;
  13629. /**
  13630. * Sets the parent bone
  13631. * @param parent defines the parent (can be null if the bone is the root)
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. */
  13634. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13635. /**
  13636. * Gets the local matrix
  13637. * @returns a matrix
  13638. */
  13639. getLocalMatrix(): Matrix;
  13640. /**
  13641. * Gets the base matrix (initial matrix which remains unchanged)
  13642. * @returns a matrix
  13643. */
  13644. getBaseMatrix(): Matrix;
  13645. /**
  13646. * Gets the rest pose matrix
  13647. * @returns a matrix
  13648. */
  13649. getRestPose(): Matrix;
  13650. /**
  13651. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13652. */
  13653. getWorldMatrix(): Matrix;
  13654. /**
  13655. * Sets the local matrix to rest pose matrix
  13656. */
  13657. returnToRest(): void;
  13658. /**
  13659. * Gets the inverse of the absolute transform matrix.
  13660. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13661. * @returns a matrix
  13662. */
  13663. getInvertedAbsoluteTransform(): Matrix;
  13664. /**
  13665. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13666. * @returns a matrix
  13667. */
  13668. getAbsoluteTransform(): Matrix;
  13669. /**
  13670. * Links with the given transform node.
  13671. * The local matrix of this bone is copied from the transform node every frame.
  13672. * @param transformNode defines the transform node to link to
  13673. */
  13674. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13675. /**
  13676. * Gets the node used to drive the bone's transformation
  13677. * @returns a transform node or null
  13678. */
  13679. getTransformNode(): Nullable<TransformNode>;
  13680. /** Gets or sets current position (in local space) */
  13681. position: Vector3;
  13682. /** Gets or sets current rotation (in local space) */
  13683. rotation: Vector3;
  13684. /** Gets or sets current rotation quaternion (in local space) */
  13685. rotationQuaternion: Quaternion;
  13686. /** Gets or sets current scaling (in local space) */
  13687. scaling: Vector3;
  13688. /**
  13689. * Gets the animation properties override
  13690. */
  13691. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. private _decompose;
  13693. private _compose;
  13694. /**
  13695. * Update the base and local matrices
  13696. * @param matrix defines the new base or local matrix
  13697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13698. * @param updateLocalMatrix defines if the local matrix should be updated
  13699. */
  13700. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13701. /** @hidden */
  13702. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13703. /**
  13704. * Flag the bone as dirty (Forcing it to update everything)
  13705. */
  13706. markAsDirty(): void;
  13707. /** @hidden */
  13708. _markAsDirtyAndCompose(): void;
  13709. private _markAsDirtyAndDecompose;
  13710. /**
  13711. * Translate the bone in local or world space
  13712. * @param vec The amount to translate the bone
  13713. * @param space The space that the translation is in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Set the postion of the bone in local or world space
  13719. * @param position The position to set the bone
  13720. * @param space The space that the position is in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. */
  13723. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13724. /**
  13725. * Set the absolute position of the bone (world space)
  13726. * @param position The position to set the bone
  13727. * @param mesh The mesh that this bone is attached to
  13728. */
  13729. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13730. /**
  13731. * Scale the bone on the x, y and z axes (in local space)
  13732. * @param x The amount to scale the bone on the x axis
  13733. * @param y The amount to scale the bone on the y axis
  13734. * @param z The amount to scale the bone on the z axis
  13735. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13736. */
  13737. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13738. /**
  13739. * Set the bone scaling in local space
  13740. * @param scale defines the scaling vector
  13741. */
  13742. setScale(scale: Vector3): void;
  13743. /**
  13744. * Gets the current scaling in local space
  13745. * @returns the current scaling vector
  13746. */
  13747. getScale(): Vector3;
  13748. /**
  13749. * Gets the current scaling in local space and stores it in a target vector
  13750. * @param result defines the target vector
  13751. */
  13752. getScaleToRef(result: Vector3): void;
  13753. /**
  13754. * Set the yaw, pitch, and roll of the bone in local or world space
  13755. * @param yaw The rotation of the bone on the y axis
  13756. * @param pitch The rotation of the bone on the x axis
  13757. * @param roll The rotation of the bone on the z axis
  13758. * @param space The space that the axes of rotation are in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Add a rotation to the bone on an axis in local or world space
  13764. * @param axis The axis to rotate the bone on
  13765. * @param amount The amount to rotate the bone
  13766. * @param space The space that the axis is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the rotation of the bone to a particular axis angle in local or world space
  13772. * @param axis The axis to rotate the bone on
  13773. * @param angle The angle that the bone should be rotated to
  13774. * @param space The space that the axis is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13778. /**
  13779. * Set the euler rotation of the bone in local of world space
  13780. * @param rotation The euler rotation that the bone should be set to
  13781. * @param space The space that the rotation is in
  13782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13783. */
  13784. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13785. /**
  13786. * Set the quaternion rotation of the bone in local of world space
  13787. * @param quat The quaternion rotation that the bone should be set to
  13788. * @param space The space that the rotation is in
  13789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13790. */
  13791. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13792. /**
  13793. * Set the rotation matrix of the bone in local of world space
  13794. * @param rotMat The rotation matrix that the bone should be set to
  13795. * @param space The space that the rotation is in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13799. private _rotateWithMatrix;
  13800. private _getNegativeRotationToRef;
  13801. /**
  13802. * Get the position of the bone in local or world space
  13803. * @param space The space that the returned position is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @returns The position of the bone
  13806. */
  13807. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13808. /**
  13809. * Copy the position of the bone to a vector3 in local or world space
  13810. * @param space The space that the returned position is in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @param result The vector3 to copy the position to
  13813. */
  13814. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13815. /**
  13816. * Get the absolute position of the bone (world space)
  13817. * @param mesh The mesh that this bone is attached to
  13818. * @returns The absolute position of the bone
  13819. */
  13820. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13821. /**
  13822. * Copy the absolute position of the bone (world space) to the result param
  13823. * @param mesh The mesh that this bone is attached to
  13824. * @param result The vector3 to copy the absolute position to
  13825. */
  13826. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13827. /**
  13828. * Compute the absolute transforms of this bone and its children
  13829. */
  13830. computeAbsoluteTransforms(): void;
  13831. /**
  13832. * Get the world direction from an axis that is in the local space of the bone
  13833. * @param localAxis The local direction that is used to compute the world direction
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The world direction
  13836. */
  13837. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13840. * @param localAxis The local direction that is used to compute the world direction
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the world direction will be copied to
  13843. */
  13844. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. /**
  13846. * Get the euler rotation of the bone in local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @returns The euler rotation
  13850. */
  13851. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13852. /**
  13853. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @param result The vector3 that the rotation should be copied to
  13857. */
  13858. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13859. /**
  13860. * Get the quaternion rotation of the bone in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @returns The quaternion rotation
  13864. */
  13865. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13866. /**
  13867. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13868. * @param space The space that the rotation should be in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. * @param result The quaternion that the rotation should be copied to
  13871. */
  13872. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13873. /**
  13874. * Get the rotation matrix of the bone in local or world space
  13875. * @param space The space that the rotation should be in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. * @returns The rotation matrix
  13878. */
  13879. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13880. /**
  13881. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13882. * @param space The space that the rotation should be in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. * @param result The quaternion that the rotation should be copied to
  13885. */
  13886. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13887. /**
  13888. * Get the world position of a point that is in the local space of the bone
  13889. * @param position The local position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @returns The world position
  13892. */
  13893. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13896. * @param position The local position
  13897. * @param mesh The mesh that this bone is attached to
  13898. * @param result The vector3 that the world position should be copied to
  13899. */
  13900. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the local position of a point that is in world space
  13903. * @param position The world position
  13904. * @param mesh The mesh that this bone is attached to
  13905. * @returns The local position
  13906. */
  13907. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13908. /**
  13909. * Get the local position of a point that is in world space and copy it to the result param
  13910. * @param position The world position
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 that the local position should be copied to
  13913. */
  13914. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13915. }
  13916. }
  13917. declare module "babylonjs/Meshes/transformNode" {
  13918. import { DeepImmutable } from "babylonjs/types";
  13919. import { Observable } from "babylonjs/Misc/observable";
  13920. import { Nullable } from "babylonjs/types";
  13921. import { Camera } from "babylonjs/Cameras/camera";
  13922. import { Scene } from "babylonjs/scene";
  13923. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13924. import { Node } from "babylonjs/node";
  13925. import { Bone } from "babylonjs/Bones/bone";
  13926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13927. import { Space } from "babylonjs/Maths/math.axis";
  13928. /**
  13929. * 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.
  13930. * @see https://doc.babylonjs.com/how_to/transformnode
  13931. */
  13932. export class TransformNode extends Node {
  13933. /**
  13934. * Object will not rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_NONE: number;
  13937. /**
  13938. * Object will rotate to face the camera but only on the x axis
  13939. */
  13940. static BILLBOARDMODE_X: number;
  13941. /**
  13942. * Object will rotate to face the camera but only on the y axis
  13943. */
  13944. static BILLBOARDMODE_Y: number;
  13945. /**
  13946. * Object will rotate to face the camera but only on the z axis
  13947. */
  13948. static BILLBOARDMODE_Z: number;
  13949. /**
  13950. * Object will rotate to face the camera
  13951. */
  13952. static BILLBOARDMODE_ALL: number;
  13953. /**
  13954. * Object will rotate to face the camera's position instead of orientation
  13955. */
  13956. static BILLBOARDMODE_USE_POSITION: number;
  13957. private _forward;
  13958. private _forwardInverted;
  13959. private _up;
  13960. private _right;
  13961. private _rightInverted;
  13962. private _position;
  13963. private _rotation;
  13964. private _rotationQuaternion;
  13965. protected _scaling: Vector3;
  13966. protected _isDirty: boolean;
  13967. private _transformToBoneReferal;
  13968. private _isAbsoluteSynced;
  13969. private _billboardMode;
  13970. /**
  13971. * Gets or sets the billboard mode. Default is 0.
  13972. *
  13973. * | Value | Type | Description |
  13974. * | --- | --- | --- |
  13975. * | 0 | BILLBOARDMODE_NONE | |
  13976. * | 1 | BILLBOARDMODE_X | |
  13977. * | 2 | BILLBOARDMODE_Y | |
  13978. * | 4 | BILLBOARDMODE_Z | |
  13979. * | 7 | BILLBOARDMODE_ALL | |
  13980. *
  13981. */
  13982. billboardMode: number;
  13983. private _preserveParentRotationForBillboard;
  13984. /**
  13985. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13986. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13987. */
  13988. preserveParentRotationForBillboard: boolean;
  13989. /**
  13990. * 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
  13991. */
  13992. scalingDeterminant: number;
  13993. private _infiniteDistance;
  13994. /**
  13995. * Gets or sets the distance of the object to max, often used by skybox
  13996. */
  13997. infiniteDistance: boolean;
  13998. /**
  13999. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14000. * By default the system will update normals to compensate
  14001. */
  14002. ignoreNonUniformScaling: boolean;
  14003. /**
  14004. * 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
  14005. */
  14006. reIntegrateRotationIntoRotationQuaternion: boolean;
  14007. /** @hidden */
  14008. _poseMatrix: Nullable<Matrix>;
  14009. /** @hidden */
  14010. _localMatrix: Matrix;
  14011. private _usePivotMatrix;
  14012. private _absolutePosition;
  14013. private _absoluteScaling;
  14014. private _absoluteRotationQuaternion;
  14015. private _pivotMatrix;
  14016. private _pivotMatrixInverse;
  14017. protected _postMultiplyPivotMatrix: boolean;
  14018. protected _isWorldMatrixFrozen: boolean;
  14019. /** @hidden */
  14020. _indexInSceneTransformNodesArray: number;
  14021. /**
  14022. * An event triggered after the world matrix is updated
  14023. */
  14024. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14025. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14026. /**
  14027. * Gets a string identifying the name of the class
  14028. * @returns "TransformNode" string
  14029. */
  14030. getClassName(): string;
  14031. /**
  14032. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14033. */
  14034. position: Vector3;
  14035. /**
  14036. * 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)).
  14037. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14038. */
  14039. rotation: Vector3;
  14040. /**
  14041. * 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)).
  14042. */
  14043. scaling: Vector3;
  14044. /**
  14045. * 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).
  14046. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14047. */
  14048. rotationQuaternion: Nullable<Quaternion>;
  14049. /**
  14050. * The forward direction of that transform in world space.
  14051. */
  14052. readonly forward: Vector3;
  14053. /**
  14054. * The up direction of that transform in world space.
  14055. */
  14056. readonly up: Vector3;
  14057. /**
  14058. * The right direction of that transform in world space.
  14059. */
  14060. readonly right: Vector3;
  14061. /**
  14062. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14063. * @param matrix the matrix to copy the pose from
  14064. * @returns this TransformNode.
  14065. */
  14066. updatePoseMatrix(matrix: Matrix): TransformNode;
  14067. /**
  14068. * Returns the mesh Pose matrix.
  14069. * @returns the pose matrix
  14070. */
  14071. getPoseMatrix(): Matrix;
  14072. /** @hidden */
  14073. _isSynchronized(): boolean;
  14074. /** @hidden */
  14075. _initCache(): void;
  14076. /**
  14077. * Flag the transform node as dirty (Forcing it to update everything)
  14078. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14079. * @returns this transform node
  14080. */
  14081. markAsDirty(property: string): TransformNode;
  14082. /**
  14083. * Returns the current mesh absolute position.
  14084. * Returns a Vector3.
  14085. */
  14086. readonly absolutePosition: Vector3;
  14087. /**
  14088. * Returns the current mesh absolute scaling.
  14089. * Returns a Vector3.
  14090. */
  14091. readonly absoluteScaling: Vector3;
  14092. /**
  14093. * Returns the current mesh absolute rotation.
  14094. * Returns a Quaternion.
  14095. */
  14096. readonly absoluteRotationQuaternion: Quaternion;
  14097. /**
  14098. * Sets a new matrix to apply before all other transformation
  14099. * @param matrix defines the transform matrix
  14100. * @returns the current TransformNode
  14101. */
  14102. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14103. /**
  14104. * Sets a new pivot matrix to the current node
  14105. * @param matrix defines the new pivot matrix to use
  14106. * @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
  14107. * @returns the current TransformNode
  14108. */
  14109. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14110. /**
  14111. * Returns the mesh pivot matrix.
  14112. * Default : Identity.
  14113. * @returns the matrix
  14114. */
  14115. getPivotMatrix(): Matrix;
  14116. /**
  14117. * Prevents the World matrix to be computed any longer.
  14118. * @returns the TransformNode.
  14119. */
  14120. freezeWorldMatrix(): TransformNode;
  14121. /**
  14122. * Allows back the World matrix computation.
  14123. * @returns the TransformNode.
  14124. */
  14125. unfreezeWorldMatrix(): this;
  14126. /**
  14127. * True if the World matrix has been frozen.
  14128. */
  14129. readonly isWorldMatrixFrozen: boolean;
  14130. /**
  14131. * Retuns the mesh absolute position in the World.
  14132. * @returns a Vector3.
  14133. */
  14134. getAbsolutePosition(): Vector3;
  14135. /**
  14136. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14137. * @param absolutePosition the absolute position to set
  14138. * @returns the TransformNode.
  14139. */
  14140. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14141. /**
  14142. * Sets the mesh position in its local space.
  14143. * @param vector3 the position to set in localspace
  14144. * @returns the TransformNode.
  14145. */
  14146. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14147. /**
  14148. * Returns the mesh position in the local space from the current World matrix values.
  14149. * @returns a new Vector3.
  14150. */
  14151. getPositionExpressedInLocalSpace(): Vector3;
  14152. /**
  14153. * Translates the mesh along the passed Vector3 in its local space.
  14154. * @param vector3 the distance to translate in localspace
  14155. * @returns the TransformNode.
  14156. */
  14157. locallyTranslate(vector3: Vector3): TransformNode;
  14158. private static _lookAtVectorCache;
  14159. /**
  14160. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14161. * @param targetPoint the position (must be in same space as current mesh) to look at
  14162. * @param yawCor optional yaw (y-axis) correction in radians
  14163. * @param pitchCor optional pitch (x-axis) correction in radians
  14164. * @param rollCor optional roll (z-axis) correction in radians
  14165. * @param space the choosen space of the target
  14166. * @returns the TransformNode.
  14167. */
  14168. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14169. /**
  14170. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14171. * This Vector3 is expressed in the World space.
  14172. * @param localAxis axis to rotate
  14173. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14174. */
  14175. getDirection(localAxis: Vector3): Vector3;
  14176. /**
  14177. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14178. * localAxis is expressed in the mesh local space.
  14179. * result is computed in the Wordl space from the mesh World matrix.
  14180. * @param localAxis axis to rotate
  14181. * @param result the resulting transformnode
  14182. * @returns this TransformNode.
  14183. */
  14184. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14185. /**
  14186. * Sets this transform node rotation to the given local axis.
  14187. * @param localAxis the axis in local space
  14188. * @param yawCor optional yaw (y-axis) correction in radians
  14189. * @param pitchCor optional pitch (x-axis) correction in radians
  14190. * @param rollCor optional roll (z-axis) correction in radians
  14191. * @returns this TransformNode
  14192. */
  14193. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14194. /**
  14195. * Sets a new pivot point to the current node
  14196. * @param point defines the new pivot point to use
  14197. * @param space defines if the point is in world or local space (local by default)
  14198. * @returns the current TransformNode
  14199. */
  14200. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14201. /**
  14202. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14203. * @returns the pivot point
  14204. */
  14205. getPivotPoint(): Vector3;
  14206. /**
  14207. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14208. * @param result the vector3 to store the result
  14209. * @returns this TransformNode.
  14210. */
  14211. getPivotPointToRef(result: Vector3): TransformNode;
  14212. /**
  14213. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14214. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14215. */
  14216. getAbsolutePivotPoint(): Vector3;
  14217. /**
  14218. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14219. * @param result vector3 to store the result
  14220. * @returns this TransformNode.
  14221. */
  14222. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14223. /**
  14224. * Defines the passed node as the parent of the current node.
  14225. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14226. * @see https://doc.babylonjs.com/how_to/parenting
  14227. * @param node the node ot set as the parent
  14228. * @returns this TransformNode.
  14229. */
  14230. setParent(node: Nullable<Node>): TransformNode;
  14231. private _nonUniformScaling;
  14232. /**
  14233. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14234. */
  14235. readonly nonUniformScaling: boolean;
  14236. /** @hidden */
  14237. _updateNonUniformScalingState(value: boolean): boolean;
  14238. /**
  14239. * Attach the current TransformNode to another TransformNode associated with a bone
  14240. * @param bone Bone affecting the TransformNode
  14241. * @param affectedTransformNode TransformNode associated with the bone
  14242. * @returns this object
  14243. */
  14244. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14245. /**
  14246. * Detach the transform node if its associated with a bone
  14247. * @returns this object
  14248. */
  14249. detachFromBone(): TransformNode;
  14250. private static _rotationAxisCache;
  14251. /**
  14252. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14254. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14255. * The passed axis is also normalized.
  14256. * @param axis the axis to rotate around
  14257. * @param amount the amount to rotate in radians
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14262. /**
  14263. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14264. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14265. * The passed axis is also normalized. .
  14266. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14267. * @param point the point to rotate around
  14268. * @param axis the axis to rotate around
  14269. * @param amount the amount to rotate in radians
  14270. * @returns the TransformNode
  14271. */
  14272. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14273. /**
  14274. * Translates the mesh along the axis vector for the passed distance in the given space.
  14275. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14276. * @param axis the axis to translate in
  14277. * @param distance the distance to translate
  14278. * @param space Space to rotate in (Default: local)
  14279. * @returns the TransformNode.
  14280. */
  14281. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14282. /**
  14283. * Adds a rotation step to the mesh current rotation.
  14284. * x, y, z are Euler angles expressed in radians.
  14285. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14286. * This means this rotation is made in the mesh local space only.
  14287. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14288. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14289. * ```javascript
  14290. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14291. * ```
  14292. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14293. * 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.
  14294. * @param x Rotation to add
  14295. * @param y Rotation to add
  14296. * @param z Rotation to add
  14297. * @returns the TransformNode.
  14298. */
  14299. addRotation(x: number, y: number, z: number): TransformNode;
  14300. /**
  14301. * @hidden
  14302. */
  14303. protected _getEffectiveParent(): Nullable<Node>;
  14304. /**
  14305. * Computes the world matrix of the node
  14306. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14307. * @returns the world matrix
  14308. */
  14309. computeWorldMatrix(force?: boolean): Matrix;
  14310. protected _afterComputeWorldMatrix(): void;
  14311. /**
  14312. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14313. * @param func callback function to add
  14314. *
  14315. * @returns the TransformNode.
  14316. */
  14317. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14318. /**
  14319. * Removes a registered callback function.
  14320. * @param func callback function to remove
  14321. * @returns the TransformNode.
  14322. */
  14323. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14324. /**
  14325. * Gets the position of the current mesh in camera space
  14326. * @param camera defines the camera to use
  14327. * @returns a position
  14328. */
  14329. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14330. /**
  14331. * Returns the distance from the mesh to the active camera
  14332. * @param camera defines the camera to use
  14333. * @returns the distance
  14334. */
  14335. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14336. /**
  14337. * Clone the current transform node
  14338. * @param name Name of the new clone
  14339. * @param newParent New parent for the clone
  14340. * @param doNotCloneChildren Do not clone children hierarchy
  14341. * @returns the new transform node
  14342. */
  14343. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14344. /**
  14345. * Serializes the objects information.
  14346. * @param currentSerializationObject defines the object to serialize in
  14347. * @returns the serialized object
  14348. */
  14349. serialize(currentSerializationObject?: any): any;
  14350. /**
  14351. * Returns a new TransformNode object parsed from the source provided.
  14352. * @param parsedTransformNode is the source.
  14353. * @param scene the scne the object belongs to
  14354. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14355. * @returns a new TransformNode object parsed from the source provided.
  14356. */
  14357. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14358. /**
  14359. * Get all child-transformNodes of this node
  14360. * @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
  14361. * @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
  14362. * @returns an array of TransformNode
  14363. */
  14364. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14365. /**
  14366. * Releases resources associated with this transform node.
  14367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14369. */
  14370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14371. /**
  14372. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14373. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14374. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14375. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14376. * @returns the current mesh
  14377. */
  14378. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14379. private _syncAbsoluteScalingAndRotation;
  14380. }
  14381. }
  14382. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14383. import { Observable } from "babylonjs/Misc/observable";
  14384. import { Nullable } from "babylonjs/types";
  14385. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14388. import { Ray } from "babylonjs/Culling/ray";
  14389. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14390. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14391. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14392. /**
  14393. * Defines the types of pose enabled controllers that are supported
  14394. */
  14395. export enum PoseEnabledControllerType {
  14396. /**
  14397. * HTC Vive
  14398. */
  14399. VIVE = 0,
  14400. /**
  14401. * Oculus Rift
  14402. */
  14403. OCULUS = 1,
  14404. /**
  14405. * Windows mixed reality
  14406. */
  14407. WINDOWS = 2,
  14408. /**
  14409. * Samsung gear VR
  14410. */
  14411. GEAR_VR = 3,
  14412. /**
  14413. * Google Daydream
  14414. */
  14415. DAYDREAM = 4,
  14416. /**
  14417. * Generic
  14418. */
  14419. GENERIC = 5
  14420. }
  14421. /**
  14422. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14423. */
  14424. export interface MutableGamepadButton {
  14425. /**
  14426. * Value of the button/trigger
  14427. */
  14428. value: number;
  14429. /**
  14430. * If the button/trigger is currently touched
  14431. */
  14432. touched: boolean;
  14433. /**
  14434. * If the button/trigger is currently pressed
  14435. */
  14436. pressed: boolean;
  14437. }
  14438. /**
  14439. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14440. * @hidden
  14441. */
  14442. export interface ExtendedGamepadButton extends GamepadButton {
  14443. /**
  14444. * If the button/trigger is currently pressed
  14445. */
  14446. readonly pressed: boolean;
  14447. /**
  14448. * If the button/trigger is currently touched
  14449. */
  14450. readonly touched: boolean;
  14451. /**
  14452. * Value of the button/trigger
  14453. */
  14454. readonly value: number;
  14455. }
  14456. /** @hidden */
  14457. export interface _GamePadFactory {
  14458. /**
  14459. * Returns wether or not the current gamepad can be created for this type of controller.
  14460. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14461. * @returns true if it can be created, otherwise false
  14462. */
  14463. canCreate(gamepadInfo: any): boolean;
  14464. /**
  14465. * Creates a new instance of the Gamepad.
  14466. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14467. * @returns the new gamepad instance
  14468. */
  14469. create(gamepadInfo: any): Gamepad;
  14470. }
  14471. /**
  14472. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14473. */
  14474. export class PoseEnabledControllerHelper {
  14475. /** @hidden */
  14476. static _ControllerFactories: _GamePadFactory[];
  14477. /** @hidden */
  14478. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14479. /**
  14480. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14481. * @param vrGamepad the gamepad to initialized
  14482. * @returns a vr controller of the type the gamepad identified as
  14483. */
  14484. static InitiateController(vrGamepad: any): Gamepad;
  14485. }
  14486. /**
  14487. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14488. */
  14489. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14490. /**
  14491. * If the controller is used in a webXR session
  14492. */
  14493. isXR: boolean;
  14494. private _deviceRoomPosition;
  14495. private _deviceRoomRotationQuaternion;
  14496. /**
  14497. * The device position in babylon space
  14498. */
  14499. devicePosition: Vector3;
  14500. /**
  14501. * The device rotation in babylon space
  14502. */
  14503. deviceRotationQuaternion: Quaternion;
  14504. /**
  14505. * The scale factor of the device in babylon space
  14506. */
  14507. deviceScaleFactor: number;
  14508. /**
  14509. * (Likely devicePosition should be used instead) The device position in its room space
  14510. */
  14511. position: Vector3;
  14512. /**
  14513. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14514. */
  14515. rotationQuaternion: Quaternion;
  14516. /**
  14517. * The type of controller (Eg. Windows mixed reality)
  14518. */
  14519. controllerType: PoseEnabledControllerType;
  14520. protected _calculatedPosition: Vector3;
  14521. private _calculatedRotation;
  14522. /**
  14523. * The raw pose from the device
  14524. */
  14525. rawPose: DevicePose;
  14526. private _trackPosition;
  14527. private _maxRotationDistFromHeadset;
  14528. private _draggedRoomRotation;
  14529. /**
  14530. * @hidden
  14531. */
  14532. _disableTrackPosition(fixedPosition: Vector3): void;
  14533. /**
  14534. * Internal, the mesh attached to the controller
  14535. * @hidden
  14536. */
  14537. _mesh: Nullable<AbstractMesh>;
  14538. private _poseControlledCamera;
  14539. private _leftHandSystemQuaternion;
  14540. /**
  14541. * Internal, matrix used to convert room space to babylon space
  14542. * @hidden
  14543. */
  14544. _deviceToWorld: Matrix;
  14545. /**
  14546. * Node to be used when casting a ray from the controller
  14547. * @hidden
  14548. */
  14549. _pointingPoseNode: Nullable<TransformNode>;
  14550. /**
  14551. * Name of the child mesh that can be used to cast a ray from the controller
  14552. */
  14553. static readonly POINTING_POSE: string;
  14554. /**
  14555. * Creates a new PoseEnabledController from a gamepad
  14556. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14557. */
  14558. constructor(browserGamepad: any);
  14559. private _workingMatrix;
  14560. /**
  14561. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14562. */
  14563. update(): void;
  14564. /**
  14565. * Updates only the pose device and mesh without doing any button event checking
  14566. */
  14567. protected _updatePoseAndMesh(): void;
  14568. /**
  14569. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14570. * @param poseData raw pose fromthe device
  14571. */
  14572. updateFromDevice(poseData: DevicePose): void;
  14573. /**
  14574. * @hidden
  14575. */
  14576. _meshAttachedObservable: Observable<AbstractMesh>;
  14577. /**
  14578. * Attaches a mesh to the controller
  14579. * @param mesh the mesh to be attached
  14580. */
  14581. attachToMesh(mesh: AbstractMesh): void;
  14582. /**
  14583. * Attaches the controllers mesh to a camera
  14584. * @param camera the camera the mesh should be attached to
  14585. */
  14586. attachToPoseControlledCamera(camera: TargetCamera): void;
  14587. /**
  14588. * Disposes of the controller
  14589. */
  14590. dispose(): void;
  14591. /**
  14592. * The mesh that is attached to the controller
  14593. */
  14594. readonly mesh: Nullable<AbstractMesh>;
  14595. /**
  14596. * Gets the ray of the controller in the direction the controller is pointing
  14597. * @param length the length the resulting ray should be
  14598. * @returns a ray in the direction the controller is pointing
  14599. */
  14600. getForwardRay(length?: number): Ray;
  14601. }
  14602. }
  14603. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14604. import { Observable } from "babylonjs/Misc/observable";
  14605. import { Scene } from "babylonjs/scene";
  14606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14607. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14608. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14609. /**
  14610. * Defines the WebVRController object that represents controllers tracked in 3D space
  14611. */
  14612. export abstract class WebVRController extends PoseEnabledController {
  14613. /**
  14614. * Internal, the default controller model for the controller
  14615. */
  14616. protected _defaultModel: AbstractMesh;
  14617. /**
  14618. * Fired when the trigger state has changed
  14619. */
  14620. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14621. /**
  14622. * Fired when the main button state has changed
  14623. */
  14624. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14625. /**
  14626. * Fired when the secondary button state has changed
  14627. */
  14628. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14629. /**
  14630. * Fired when the pad state has changed
  14631. */
  14632. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14633. /**
  14634. * Fired when controllers stick values have changed
  14635. */
  14636. onPadValuesChangedObservable: Observable<StickValues>;
  14637. /**
  14638. * Array of button availible on the controller
  14639. */
  14640. protected _buttons: Array<MutableGamepadButton>;
  14641. private _onButtonStateChange;
  14642. /**
  14643. * Fired when a controller button's state has changed
  14644. * @param callback the callback containing the button that was modified
  14645. */
  14646. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14647. /**
  14648. * X and Y axis corresponding to the controllers joystick
  14649. */
  14650. pad: StickValues;
  14651. /**
  14652. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14653. */
  14654. hand: string;
  14655. /**
  14656. * The default controller model for the controller
  14657. */
  14658. readonly defaultModel: AbstractMesh;
  14659. /**
  14660. * Creates a new WebVRController from a gamepad
  14661. * @param vrGamepad the gamepad that the WebVRController should be created from
  14662. */
  14663. constructor(vrGamepad: any);
  14664. /**
  14665. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14666. */
  14667. update(): void;
  14668. /**
  14669. * Function to be called when a button is modified
  14670. */
  14671. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14672. /**
  14673. * Loads a mesh and attaches it to the controller
  14674. * @param scene the scene the mesh should be added to
  14675. * @param meshLoaded callback for when the mesh has been loaded
  14676. */
  14677. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14678. private _setButtonValue;
  14679. private _changes;
  14680. private _checkChanges;
  14681. /**
  14682. * Disposes of th webVRCOntroller
  14683. */
  14684. dispose(): void;
  14685. }
  14686. }
  14687. declare module "babylonjs/Lights/hemisphericLight" {
  14688. import { Nullable } from "babylonjs/types";
  14689. import { Scene } from "babylonjs/scene";
  14690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14691. import { Color3 } from "babylonjs/Maths/math.color";
  14692. import { Effect } from "babylonjs/Materials/effect";
  14693. import { Light } from "babylonjs/Lights/light";
  14694. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14695. /**
  14696. * The HemisphericLight simulates the ambient environment light,
  14697. * so the passed direction is the light reflection direction, not the incoming direction.
  14698. */
  14699. export class HemisphericLight extends Light {
  14700. /**
  14701. * The groundColor is the light in the opposite direction to the one specified during creation.
  14702. * 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.
  14703. */
  14704. groundColor: Color3;
  14705. /**
  14706. * The light reflection direction, not the incoming direction.
  14707. */
  14708. direction: Vector3;
  14709. /**
  14710. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14711. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14712. * The HemisphericLight can't cast shadows.
  14713. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14714. * @param name The friendly name of the light
  14715. * @param direction The direction of the light reflection
  14716. * @param scene The scene the light belongs to
  14717. */
  14718. constructor(name: string, direction: Vector3, scene: Scene);
  14719. protected _buildUniformLayout(): void;
  14720. /**
  14721. * Returns the string "HemisphericLight".
  14722. * @return The class name
  14723. */
  14724. getClassName(): string;
  14725. /**
  14726. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14727. * Returns the updated direction.
  14728. * @param target The target the direction should point to
  14729. * @return The computed direction
  14730. */
  14731. setDirectionToTarget(target: Vector3): Vector3;
  14732. /**
  14733. * Returns the shadow generator associated to the light.
  14734. * @returns Always null for hemispheric lights because it does not support shadows.
  14735. */
  14736. getShadowGenerator(): Nullable<IShadowGenerator>;
  14737. /**
  14738. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14739. * @param effect The effect to update
  14740. * @param lightIndex The index of the light in the effect to update
  14741. * @returns The hemispheric light
  14742. */
  14743. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14744. /**
  14745. * Computes the world matrix of the node
  14746. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14747. * @param useWasUpdatedFlag defines a reserved property
  14748. * @returns the world matrix
  14749. */
  14750. computeWorldMatrix(): Matrix;
  14751. /**
  14752. * Returns the integer 3.
  14753. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14754. */
  14755. getTypeID(): number;
  14756. /**
  14757. * Prepares the list of defines specific to the light type.
  14758. * @param defines the list of defines
  14759. * @param lightIndex defines the index of the light for the effect
  14760. */
  14761. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14762. }
  14763. }
  14764. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14765. /** @hidden */
  14766. export var vrMultiviewToSingleviewPixelShader: {
  14767. name: string;
  14768. shader: string;
  14769. };
  14770. }
  14771. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14773. import { Scene } from "babylonjs/scene";
  14774. /**
  14775. * Renders to multiple views with a single draw call
  14776. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14777. */
  14778. export class MultiviewRenderTarget extends RenderTargetTexture {
  14779. /**
  14780. * Creates a multiview render target
  14781. * @param scene scene used with the render target
  14782. * @param size the size of the render target (used for each view)
  14783. */
  14784. constructor(scene: Scene, size?: number | {
  14785. width: number;
  14786. height: number;
  14787. } | {
  14788. ratio: number;
  14789. });
  14790. /**
  14791. * @hidden
  14792. * @param faceIndex the face index, if its a cube texture
  14793. */
  14794. _bindFrameBuffer(faceIndex?: number): void;
  14795. /**
  14796. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14797. * @returns the view count
  14798. */
  14799. getViewCount(): number;
  14800. }
  14801. }
  14802. declare module "babylonjs/Maths/math.frustum" {
  14803. import { Matrix } from "babylonjs/Maths/math.vector";
  14804. import { DeepImmutable } from "babylonjs/types";
  14805. import { Plane } from "babylonjs/Maths/math.plane";
  14806. /**
  14807. * Reprasents a camera frustum
  14808. */
  14809. export class Frustum {
  14810. /**
  14811. * Gets the planes representing the frustum
  14812. * @param transform matrix to be applied to the returned planes
  14813. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14814. */
  14815. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14816. /**
  14817. * Gets the near frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the far frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Gets the left frustum plane transformed by the transform matrix
  14830. * @param transform transformation matrix to be applied to the resulting frustum plane
  14831. * @param frustumPlane the resuling frustum plane
  14832. */
  14833. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14834. /**
  14835. * Gets the right frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Gets the top frustum plane transformed by the transform matrix
  14842. * @param transform transformation matrix to be applied to the resulting frustum plane
  14843. * @param frustumPlane the resuling frustum plane
  14844. */
  14845. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14846. /**
  14847. * Gets the bottom frustum plane transformed by the transform matrix
  14848. * @param transform transformation matrix to be applied to the resulting frustum plane
  14849. * @param frustumPlane the resuling frustum plane
  14850. */
  14851. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14852. /**
  14853. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14854. * @param transform transformation matrix to be applied to the resulting frustum planes
  14855. * @param frustumPlanes the resuling frustum planes
  14856. */
  14857. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14858. }
  14859. }
  14860. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14861. import { Camera } from "babylonjs/Cameras/camera";
  14862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14863. import { Nullable } from "babylonjs/types";
  14864. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14865. import { Matrix } from "babylonjs/Maths/math.vector";
  14866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14867. module "babylonjs/Engines/engine" {
  14868. interface Engine {
  14869. /**
  14870. * Creates a new multiview render target
  14871. * @param width defines the width of the texture
  14872. * @param height defines the height of the texture
  14873. * @returns the created multiview texture
  14874. */
  14875. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14876. /**
  14877. * Binds a multiview framebuffer to be drawn to
  14878. * @param multiviewTexture texture to bind
  14879. */
  14880. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14881. }
  14882. }
  14883. module "babylonjs/Cameras/camera" {
  14884. interface Camera {
  14885. /**
  14886. * @hidden
  14887. * 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)
  14888. */
  14889. _useMultiviewToSingleView: boolean;
  14890. /**
  14891. * @hidden
  14892. * 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)
  14893. */
  14894. _multiviewTexture: Nullable<RenderTargetTexture>;
  14895. /**
  14896. * @hidden
  14897. * ensures the multiview texture of the camera exists and has the specified width/height
  14898. * @param width height to set on the multiview texture
  14899. * @param height width to set on the multiview texture
  14900. */
  14901. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14902. }
  14903. }
  14904. module "babylonjs/scene" {
  14905. interface Scene {
  14906. /** @hidden */
  14907. _transformMatrixR: Matrix;
  14908. /** @hidden */
  14909. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14910. /** @hidden */
  14911. _createMultiviewUbo(): void;
  14912. /** @hidden */
  14913. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14914. /** @hidden */
  14915. _renderMultiviewToSingleView(camera: Camera): void;
  14916. }
  14917. }
  14918. }
  14919. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14920. import { Camera } from "babylonjs/Cameras/camera";
  14921. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14922. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14923. import "babylonjs/Engines/Extensions/engine.multiview";
  14924. /**
  14925. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14926. * This will not be used for webXR as it supports displaying texture arrays directly
  14927. */
  14928. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14929. /**
  14930. * Initializes a VRMultiviewToSingleview
  14931. * @param name name of the post process
  14932. * @param camera camera to be applied to
  14933. * @param scaleFactor scaling factor to the size of the output texture
  14934. */
  14935. constructor(name: string, camera: Camera, scaleFactor: number);
  14936. }
  14937. }
  14938. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14939. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14940. import { Nullable } from "babylonjs/types";
  14941. import { Size } from "babylonjs/Maths/math.size";
  14942. import { Observable } from "babylonjs/Misc/observable";
  14943. module "babylonjs/Engines/engine" {
  14944. interface Engine {
  14945. /** @hidden */
  14946. _vrDisplay: any;
  14947. /** @hidden */
  14948. _vrSupported: boolean;
  14949. /** @hidden */
  14950. _oldSize: Size;
  14951. /** @hidden */
  14952. _oldHardwareScaleFactor: number;
  14953. /** @hidden */
  14954. _vrExclusivePointerMode: boolean;
  14955. /** @hidden */
  14956. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14957. /** @hidden */
  14958. _onVRDisplayPointerRestricted: () => void;
  14959. /** @hidden */
  14960. _onVRDisplayPointerUnrestricted: () => void;
  14961. /** @hidden */
  14962. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14963. /** @hidden */
  14964. _onVrDisplayDisconnect: Nullable<() => void>;
  14965. /** @hidden */
  14966. _onVrDisplayPresentChange: Nullable<() => void>;
  14967. /**
  14968. * Observable signaled when VR display mode changes
  14969. */
  14970. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14971. /**
  14972. * Observable signaled when VR request present is complete
  14973. */
  14974. onVRRequestPresentComplete: Observable<boolean>;
  14975. /**
  14976. * Observable signaled when VR request present starts
  14977. */
  14978. onVRRequestPresentStart: Observable<Engine>;
  14979. /**
  14980. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14981. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14982. */
  14983. isInVRExclusivePointerMode: boolean;
  14984. /**
  14985. * Gets a boolean indicating if a webVR device was detected
  14986. * @returns true if a webVR device was detected
  14987. */
  14988. isVRDevicePresent(): boolean;
  14989. /**
  14990. * Gets the current webVR device
  14991. * @returns the current webVR device (or null)
  14992. */
  14993. getVRDevice(): any;
  14994. /**
  14995. * Initializes a webVR display and starts listening to display change events
  14996. * The onVRDisplayChangedObservable will be notified upon these changes
  14997. * @returns A promise containing a VRDisplay and if vr is supported
  14998. */
  14999. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15000. /** @hidden */
  15001. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15002. /**
  15003. * Call this function to switch to webVR mode
  15004. * Will do nothing if webVR is not supported or if there is no webVR device
  15005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15006. */
  15007. enableVR(): void;
  15008. /** @hidden */
  15009. _onVRFullScreenTriggered(): void;
  15010. }
  15011. }
  15012. }
  15013. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15014. import { Nullable } from "babylonjs/types";
  15015. import { Observable } from "babylonjs/Misc/observable";
  15016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15017. import { Scene } from "babylonjs/scene";
  15018. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15019. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15020. import { Node } from "babylonjs/node";
  15021. import { Ray } from "babylonjs/Culling/ray";
  15022. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15023. import "babylonjs/Engines/Extensions/engine.webVR";
  15024. /**
  15025. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15026. * IMPORTANT!! The data is right-hand data.
  15027. * @export
  15028. * @interface DevicePose
  15029. */
  15030. export interface DevicePose {
  15031. /**
  15032. * The position of the device, values in array are [x,y,z].
  15033. */
  15034. readonly position: Nullable<Float32Array>;
  15035. /**
  15036. * The linearVelocity of the device, values in array are [x,y,z].
  15037. */
  15038. readonly linearVelocity: Nullable<Float32Array>;
  15039. /**
  15040. * The linearAcceleration of the device, values in array are [x,y,z].
  15041. */
  15042. readonly linearAcceleration: Nullable<Float32Array>;
  15043. /**
  15044. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15045. */
  15046. readonly orientation: Nullable<Float32Array>;
  15047. /**
  15048. * The angularVelocity of the device, values in array are [x,y,z].
  15049. */
  15050. readonly angularVelocity: Nullable<Float32Array>;
  15051. /**
  15052. * The angularAcceleration of the device, values in array are [x,y,z].
  15053. */
  15054. readonly angularAcceleration: Nullable<Float32Array>;
  15055. }
  15056. /**
  15057. * Interface representing a pose controlled object in Babylon.
  15058. * A pose controlled object has both regular pose values as well as pose values
  15059. * from an external device such as a VR head mounted display
  15060. */
  15061. export interface PoseControlled {
  15062. /**
  15063. * The position of the object in babylon space.
  15064. */
  15065. position: Vector3;
  15066. /**
  15067. * The rotation quaternion of the object in babylon space.
  15068. */
  15069. rotationQuaternion: Quaternion;
  15070. /**
  15071. * The position of the device in babylon space.
  15072. */
  15073. devicePosition?: Vector3;
  15074. /**
  15075. * The rotation quaternion of the device in babylon space.
  15076. */
  15077. deviceRotationQuaternion: Quaternion;
  15078. /**
  15079. * The raw pose coming from the device.
  15080. */
  15081. rawPose: Nullable<DevicePose>;
  15082. /**
  15083. * The scale of the device to be used when translating from device space to babylon space.
  15084. */
  15085. deviceScaleFactor: number;
  15086. /**
  15087. * Updates the poseControlled values based on the input device pose.
  15088. * @param poseData the pose data to update the object with
  15089. */
  15090. updateFromDevice(poseData: DevicePose): void;
  15091. }
  15092. /**
  15093. * Set of options to customize the webVRCamera
  15094. */
  15095. export interface WebVROptions {
  15096. /**
  15097. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15098. */
  15099. trackPosition?: boolean;
  15100. /**
  15101. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15102. */
  15103. positionScale?: number;
  15104. /**
  15105. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15106. */
  15107. displayName?: string;
  15108. /**
  15109. * Should the native controller meshes be initialized. (default: true)
  15110. */
  15111. controllerMeshes?: boolean;
  15112. /**
  15113. * Creating a default HemiLight only on controllers. (default: true)
  15114. */
  15115. defaultLightingOnControllers?: boolean;
  15116. /**
  15117. * If you don't want to use the default VR button of the helper. (default: false)
  15118. */
  15119. useCustomVRButton?: boolean;
  15120. /**
  15121. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15122. */
  15123. customVRButton?: HTMLButtonElement;
  15124. /**
  15125. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15126. */
  15127. rayLength?: number;
  15128. /**
  15129. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15130. */
  15131. defaultHeight?: number;
  15132. /**
  15133. * If multiview should be used if availible (default: false)
  15134. */
  15135. useMultiview?: boolean;
  15136. }
  15137. /**
  15138. * This represents a WebVR camera.
  15139. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15140. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15141. */
  15142. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15143. private webVROptions;
  15144. /**
  15145. * @hidden
  15146. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15147. */
  15148. _vrDevice: any;
  15149. /**
  15150. * The rawPose of the vrDevice.
  15151. */
  15152. rawPose: Nullable<DevicePose>;
  15153. private _onVREnabled;
  15154. private _specsVersion;
  15155. private _attached;
  15156. private _frameData;
  15157. protected _descendants: Array<Node>;
  15158. private _deviceRoomPosition;
  15159. /** @hidden */
  15160. _deviceRoomRotationQuaternion: Quaternion;
  15161. private _standingMatrix;
  15162. /**
  15163. * Represents device position in babylon space.
  15164. */
  15165. devicePosition: Vector3;
  15166. /**
  15167. * Represents device rotation in babylon space.
  15168. */
  15169. deviceRotationQuaternion: Quaternion;
  15170. /**
  15171. * The scale of the device to be used when translating from device space to babylon space.
  15172. */
  15173. deviceScaleFactor: number;
  15174. private _deviceToWorld;
  15175. private _worldToDevice;
  15176. /**
  15177. * References to the webVR controllers for the vrDevice.
  15178. */
  15179. controllers: Array<WebVRController>;
  15180. /**
  15181. * Emits an event when a controller is attached.
  15182. */
  15183. onControllersAttachedObservable: Observable<WebVRController[]>;
  15184. /**
  15185. * Emits an event when a controller's mesh has been loaded;
  15186. */
  15187. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15188. /**
  15189. * Emits an event when the HMD's pose has been updated.
  15190. */
  15191. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15192. private _poseSet;
  15193. /**
  15194. * If the rig cameras be used as parent instead of this camera.
  15195. */
  15196. rigParenting: boolean;
  15197. private _lightOnControllers;
  15198. private _defaultHeight?;
  15199. /**
  15200. * Instantiates a WebVRFreeCamera.
  15201. * @param name The name of the WebVRFreeCamera
  15202. * @param position The starting anchor position for the camera
  15203. * @param scene The scene the camera belongs to
  15204. * @param webVROptions a set of customizable options for the webVRCamera
  15205. */
  15206. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15207. /**
  15208. * Gets the device distance from the ground in meters.
  15209. * @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.
  15210. */
  15211. deviceDistanceToRoomGround(): number;
  15212. /**
  15213. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15214. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15215. */
  15216. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15217. /**
  15218. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15219. * @returns A promise with a boolean set to if the standing matrix is supported.
  15220. */
  15221. useStandingMatrixAsync(): Promise<boolean>;
  15222. /**
  15223. * Disposes the camera
  15224. */
  15225. dispose(): void;
  15226. /**
  15227. * Gets a vrController by name.
  15228. * @param name The name of the controller to retreive
  15229. * @returns the controller matching the name specified or null if not found
  15230. */
  15231. getControllerByName(name: string): Nullable<WebVRController>;
  15232. private _leftController;
  15233. /**
  15234. * The controller corresponding to the users left hand.
  15235. */
  15236. readonly leftController: Nullable<WebVRController>;
  15237. private _rightController;
  15238. /**
  15239. * The controller corresponding to the users right hand.
  15240. */
  15241. readonly rightController: Nullable<WebVRController>;
  15242. /**
  15243. * Casts a ray forward from the vrCamera's gaze.
  15244. * @param length Length of the ray (default: 100)
  15245. * @returns the ray corresponding to the gaze
  15246. */
  15247. getForwardRay(length?: number): Ray;
  15248. /**
  15249. * @hidden
  15250. * Updates the camera based on device's frame data
  15251. */
  15252. _checkInputs(): void;
  15253. /**
  15254. * Updates the poseControlled values based on the input device pose.
  15255. * @param poseData Pose coming from the device
  15256. */
  15257. updateFromDevice(poseData: DevicePose): void;
  15258. private _htmlElementAttached;
  15259. private _detachIfAttached;
  15260. /**
  15261. * WebVR's attach control will start broadcasting frames to the device.
  15262. * Note that in certain browsers (chrome for example) this function must be called
  15263. * within a user-interaction callback. Example:
  15264. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15265. *
  15266. * @param element html element to attach the vrDevice to
  15267. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15268. */
  15269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15270. /**
  15271. * Detaches the camera from the html element and disables VR
  15272. *
  15273. * @param element html element to detach from
  15274. */
  15275. detachControl(element: HTMLElement): void;
  15276. /**
  15277. * @returns the name of this class
  15278. */
  15279. getClassName(): string;
  15280. /**
  15281. * Calls resetPose on the vrDisplay
  15282. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15283. */
  15284. resetToCurrentRotation(): void;
  15285. /**
  15286. * @hidden
  15287. * Updates the rig cameras (left and right eye)
  15288. */
  15289. _updateRigCameras(): void;
  15290. private _workingVector;
  15291. private _oneVector;
  15292. private _workingMatrix;
  15293. private updateCacheCalled;
  15294. private _correctPositionIfNotTrackPosition;
  15295. /**
  15296. * @hidden
  15297. * Updates the cached values of the camera
  15298. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15299. */
  15300. _updateCache(ignoreParentClass?: boolean): void;
  15301. /**
  15302. * @hidden
  15303. * Get current device position in babylon world
  15304. */
  15305. _computeDevicePosition(): void;
  15306. /**
  15307. * Updates the current device position and rotation in the babylon world
  15308. */
  15309. update(): void;
  15310. /**
  15311. * @hidden
  15312. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15313. * @returns an identity matrix
  15314. */
  15315. _getViewMatrix(): Matrix;
  15316. private _tmpMatrix;
  15317. /**
  15318. * This function is called by the two RIG cameras.
  15319. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15320. * @hidden
  15321. */
  15322. _getWebVRViewMatrix(): Matrix;
  15323. /** @hidden */
  15324. _getWebVRProjectionMatrix(): Matrix;
  15325. private _onGamepadConnectedObserver;
  15326. private _onGamepadDisconnectedObserver;
  15327. private _updateCacheWhenTrackingDisabledObserver;
  15328. /**
  15329. * Initializes the controllers and their meshes
  15330. */
  15331. initControllers(): void;
  15332. }
  15333. }
  15334. declare module "babylonjs/PostProcesses/postProcess" {
  15335. import { Nullable } from "babylonjs/types";
  15336. import { SmartArray } from "babylonjs/Misc/smartArray";
  15337. import { Observable } from "babylonjs/Misc/observable";
  15338. import { Vector2 } from "babylonjs/Maths/math.vector";
  15339. import { Camera } from "babylonjs/Cameras/camera";
  15340. import { Effect } from "babylonjs/Materials/effect";
  15341. import "babylonjs/Shaders/postprocess.vertex";
  15342. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15343. import { Engine } from "babylonjs/Engines/engine";
  15344. import { Color4 } from "babylonjs/Maths/math.color";
  15345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15346. /**
  15347. * Size options for a post process
  15348. */
  15349. export type PostProcessOptions = {
  15350. width: number;
  15351. height: number;
  15352. };
  15353. /**
  15354. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15356. */
  15357. export class PostProcess {
  15358. /** Name of the PostProcess. */
  15359. name: string;
  15360. /**
  15361. * Gets or sets the unique id of the post process
  15362. */
  15363. uniqueId: number;
  15364. /**
  15365. * Width of the texture to apply the post process on
  15366. */
  15367. width: number;
  15368. /**
  15369. * Height of the texture to apply the post process on
  15370. */
  15371. height: number;
  15372. /**
  15373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15374. * @hidden
  15375. */
  15376. _outputTexture: Nullable<InternalTexture>;
  15377. /**
  15378. * Sampling mode used by the shader
  15379. * See https://doc.babylonjs.com/classes/3.1/texture
  15380. */
  15381. renderTargetSamplingMode: number;
  15382. /**
  15383. * Clear color to use when screen clearing
  15384. */
  15385. clearColor: Color4;
  15386. /**
  15387. * If the buffer needs to be cleared before applying the post process. (default: true)
  15388. * Should be set to false if shader will overwrite all previous pixels.
  15389. */
  15390. autoClear: boolean;
  15391. /**
  15392. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15393. */
  15394. alphaMode: number;
  15395. /**
  15396. * Sets the setAlphaBlendConstants of the babylon engine
  15397. */
  15398. alphaConstants: Color4;
  15399. /**
  15400. * Animations to be used for the post processing
  15401. */
  15402. animations: import("babylonjs/Animations/animation").Animation[];
  15403. /**
  15404. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15405. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15406. */
  15407. enablePixelPerfectMode: boolean;
  15408. /**
  15409. * Force the postprocess to be applied without taking in account viewport
  15410. */
  15411. forceFullscreenViewport: boolean;
  15412. /**
  15413. * List of inspectable custom properties (used by the Inspector)
  15414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15415. */
  15416. inspectableCustomProperties: IInspectable[];
  15417. /**
  15418. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15419. *
  15420. * | Value | Type | Description |
  15421. * | ----- | ----------------------------------- | ----------- |
  15422. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15423. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15424. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15425. *
  15426. */
  15427. scaleMode: number;
  15428. /**
  15429. * Force textures to be a power of two (default: false)
  15430. */
  15431. alwaysForcePOT: boolean;
  15432. private _samples;
  15433. /**
  15434. * Number of sample textures (default: 1)
  15435. */
  15436. samples: number;
  15437. /**
  15438. * Modify the scale of the post process to be the same as the viewport (default: false)
  15439. */
  15440. adaptScaleToCurrentViewport: boolean;
  15441. private _camera;
  15442. private _scene;
  15443. private _engine;
  15444. private _options;
  15445. private _reusable;
  15446. private _textureType;
  15447. /**
  15448. * Smart array of input and output textures for the post process.
  15449. * @hidden
  15450. */
  15451. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15452. /**
  15453. * The index in _textures that corresponds to the output texture.
  15454. * @hidden
  15455. */
  15456. _currentRenderTextureInd: number;
  15457. private _effect;
  15458. private _samplers;
  15459. private _fragmentUrl;
  15460. private _vertexUrl;
  15461. private _parameters;
  15462. private _scaleRatio;
  15463. protected _indexParameters: any;
  15464. private _shareOutputWithPostProcess;
  15465. private _texelSize;
  15466. private _forcedOutputTexture;
  15467. /**
  15468. * Returns the fragment url or shader name used in the post process.
  15469. * @returns the fragment url or name in the shader store.
  15470. */
  15471. getEffectName(): string;
  15472. /**
  15473. * An event triggered when the postprocess is activated.
  15474. */
  15475. onActivateObservable: Observable<Camera>;
  15476. private _onActivateObserver;
  15477. /**
  15478. * A function that is added to the onActivateObservable
  15479. */
  15480. onActivate: Nullable<(camera: Camera) => void>;
  15481. /**
  15482. * An event triggered when the postprocess changes its size.
  15483. */
  15484. onSizeChangedObservable: Observable<PostProcess>;
  15485. private _onSizeChangedObserver;
  15486. /**
  15487. * A function that is added to the onSizeChangedObservable
  15488. */
  15489. onSizeChanged: (postProcess: PostProcess) => void;
  15490. /**
  15491. * An event triggered when the postprocess applies its effect.
  15492. */
  15493. onApplyObservable: Observable<Effect>;
  15494. private _onApplyObserver;
  15495. /**
  15496. * A function that is added to the onApplyObservable
  15497. */
  15498. onApply: (effect: Effect) => void;
  15499. /**
  15500. * An event triggered before rendering the postprocess
  15501. */
  15502. onBeforeRenderObservable: Observable<Effect>;
  15503. private _onBeforeRenderObserver;
  15504. /**
  15505. * A function that is added to the onBeforeRenderObservable
  15506. */
  15507. onBeforeRender: (effect: Effect) => void;
  15508. /**
  15509. * An event triggered after rendering the postprocess
  15510. */
  15511. onAfterRenderObservable: Observable<Effect>;
  15512. private _onAfterRenderObserver;
  15513. /**
  15514. * A function that is added to the onAfterRenderObservable
  15515. */
  15516. onAfterRender: (efect: Effect) => void;
  15517. /**
  15518. * 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
  15519. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15520. */
  15521. inputTexture: InternalTexture;
  15522. /**
  15523. * Gets the camera which post process is applied to.
  15524. * @returns The camera the post process is applied to.
  15525. */
  15526. getCamera(): Camera;
  15527. /**
  15528. * Gets the texel size of the postprocess.
  15529. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15530. */
  15531. readonly texelSize: Vector2;
  15532. /**
  15533. * Creates a new instance PostProcess
  15534. * @param name The name of the PostProcess.
  15535. * @param fragmentUrl The url of the fragment shader to be used.
  15536. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15537. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15538. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15539. * @param camera The camera to apply the render pass to.
  15540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15541. * @param engine The engine which the post process will be applied. (default: current engine)
  15542. * @param reusable If the post process can be reused on the same frame. (default: false)
  15543. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15544. * @param textureType Type of textures used when performing the post process. (default: 0)
  15545. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15546. * @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
  15547. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15548. */
  15549. constructor(
  15550. /** Name of the PostProcess. */
  15551. 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);
  15552. /**
  15553. * Gets a string idenfifying the name of the class
  15554. * @returns "PostProcess" string
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Gets the engine which this post process belongs to.
  15559. * @returns The engine the post process was enabled with.
  15560. */
  15561. getEngine(): Engine;
  15562. /**
  15563. * The effect that is created when initializing the post process.
  15564. * @returns The created effect corresponding the the postprocess.
  15565. */
  15566. getEffect(): Effect;
  15567. /**
  15568. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15569. * @param postProcess The post process to share the output with.
  15570. * @returns This post process.
  15571. */
  15572. shareOutputWith(postProcess: PostProcess): PostProcess;
  15573. /**
  15574. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15575. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15576. */
  15577. useOwnOutput(): void;
  15578. /**
  15579. * Updates the effect with the current post process compile time values and recompiles the shader.
  15580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15583. * @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
  15584. * @param onCompiled Called when the shader has been compiled.
  15585. * @param onError Called if there is an error when compiling a shader.
  15586. */
  15587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15588. /**
  15589. * The post process is reusable if it can be used multiple times within one frame.
  15590. * @returns If the post process is reusable
  15591. */
  15592. isReusable(): boolean;
  15593. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15594. markTextureDirty(): void;
  15595. /**
  15596. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15597. * 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.
  15598. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15599. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15600. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15601. * @returns The target texture that was bound to be written to.
  15602. */
  15603. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15604. /**
  15605. * If the post process is supported.
  15606. */
  15607. readonly isSupported: boolean;
  15608. /**
  15609. * The aspect ratio of the output texture.
  15610. */
  15611. readonly aspectRatio: number;
  15612. /**
  15613. * Get a value indicating if the post-process is ready to be used
  15614. * @returns true if the post-process is ready (shader is compiled)
  15615. */
  15616. isReady(): boolean;
  15617. /**
  15618. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15619. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15620. */
  15621. apply(): Nullable<Effect>;
  15622. private _disposeTextures;
  15623. /**
  15624. * Disposes the post process.
  15625. * @param camera The camera to dispose the post process on.
  15626. */
  15627. dispose(camera?: Camera): void;
  15628. }
  15629. }
  15630. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15631. /** @hidden */
  15632. export var kernelBlurVaryingDeclaration: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15638. /** @hidden */
  15639. export var kernelBlurFragment: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15645. /** @hidden */
  15646. export var kernelBlurFragment2: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15652. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15653. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15654. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15655. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15656. /** @hidden */
  15657. export var kernelBlurPixelShader: {
  15658. name: string;
  15659. shader: string;
  15660. };
  15661. }
  15662. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15663. /** @hidden */
  15664. export var kernelBlurVertex: {
  15665. name: string;
  15666. shader: string;
  15667. };
  15668. }
  15669. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15670. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15671. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15672. /** @hidden */
  15673. export var kernelBlurVertexShader: {
  15674. name: string;
  15675. shader: string;
  15676. };
  15677. }
  15678. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15679. import { Vector2 } from "babylonjs/Maths/math.vector";
  15680. import { Nullable } from "babylonjs/types";
  15681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15682. import { Camera } from "babylonjs/Cameras/camera";
  15683. import { Effect } from "babylonjs/Materials/effect";
  15684. import { Engine } from "babylonjs/Engines/engine";
  15685. import "babylonjs/Shaders/kernelBlur.fragment";
  15686. import "babylonjs/Shaders/kernelBlur.vertex";
  15687. /**
  15688. * The Blur Post Process which blurs an image based on a kernel and direction.
  15689. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15690. */
  15691. export class BlurPostProcess extends PostProcess {
  15692. /** The direction in which to blur the image. */
  15693. direction: Vector2;
  15694. private blockCompilation;
  15695. protected _kernel: number;
  15696. protected _idealKernel: number;
  15697. protected _packedFloat: boolean;
  15698. private _staticDefines;
  15699. /**
  15700. * Sets the length in pixels of the blur sample region
  15701. */
  15702. /**
  15703. * Gets the length in pixels of the blur sample region
  15704. */
  15705. kernel: number;
  15706. /**
  15707. * Sets wether or not the blur needs to unpack/repack floats
  15708. */
  15709. /**
  15710. * Gets wether or not the blur is unpacking/repacking floats
  15711. */
  15712. packedFloat: boolean;
  15713. /**
  15714. * Creates a new instance BlurPostProcess
  15715. * @param name The name of the effect.
  15716. * @param direction The direction in which to blur the image.
  15717. * @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.
  15718. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15719. * @param camera The camera to apply the render pass to.
  15720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15721. * @param engine The engine which the post process will be applied. (default: current engine)
  15722. * @param reusable If the post process can be reused on the same frame. (default: false)
  15723. * @param textureType Type of textures used when performing the post process. (default: 0)
  15724. * @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)
  15725. */
  15726. constructor(name: string,
  15727. /** The direction in which to blur the image. */
  15728. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15729. /**
  15730. * Updates the effect with the current post process compile time values and recompiles the shader.
  15731. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15732. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15733. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15734. * @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
  15735. * @param onCompiled Called when the shader has been compiled.
  15736. * @param onError Called if there is an error when compiling a shader.
  15737. */
  15738. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15739. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15740. /**
  15741. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15742. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15743. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15744. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15745. * The gaps between physical kernels are compensated for in the weighting of the samples
  15746. * @param idealKernel Ideal blur kernel.
  15747. * @return Nearest best kernel.
  15748. */
  15749. protected _nearestBestKernel(idealKernel: number): number;
  15750. /**
  15751. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15752. * @param x The point on the Gaussian distribution to sample.
  15753. * @return the value of the Gaussian function at x.
  15754. */
  15755. protected _gaussianWeight(x: number): number;
  15756. /**
  15757. * Generates a string that can be used as a floating point number in GLSL.
  15758. * @param x Value to print.
  15759. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15760. * @return GLSL float string.
  15761. */
  15762. protected _glslFloat(x: number, decimalFigures?: number): string;
  15763. }
  15764. }
  15765. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15766. import { Scene } from "babylonjs/scene";
  15767. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15768. import { Plane } from "babylonjs/Maths/math.plane";
  15769. /**
  15770. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15771. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15772. * You can then easily use it as a reflectionTexture on a flat surface.
  15773. * In case the surface is not a plane, please consider relying on reflection probes.
  15774. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15775. */
  15776. export class MirrorTexture extends RenderTargetTexture {
  15777. private scene;
  15778. /**
  15779. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15780. * 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.
  15781. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15782. */
  15783. mirrorPlane: Plane;
  15784. /**
  15785. * Define the blur ratio used to blur the reflection if needed.
  15786. */
  15787. blurRatio: number;
  15788. /**
  15789. * Define the adaptive blur kernel used to blur the reflection if needed.
  15790. * This will autocompute the closest best match for the `blurKernel`
  15791. */
  15792. adaptiveBlurKernel: number;
  15793. /**
  15794. * Define the blur kernel used to blur the reflection if needed.
  15795. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15796. */
  15797. blurKernel: number;
  15798. /**
  15799. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15801. */
  15802. blurKernelX: number;
  15803. /**
  15804. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15805. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15806. */
  15807. blurKernelY: number;
  15808. private _autoComputeBlurKernel;
  15809. protected _onRatioRescale(): void;
  15810. private _updateGammaSpace;
  15811. private _imageProcessingConfigChangeObserver;
  15812. private _transformMatrix;
  15813. private _mirrorMatrix;
  15814. private _savedViewMatrix;
  15815. private _blurX;
  15816. private _blurY;
  15817. private _adaptiveBlurKernel;
  15818. private _blurKernelX;
  15819. private _blurKernelY;
  15820. private _blurRatio;
  15821. /**
  15822. * Instantiates a Mirror Texture.
  15823. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15824. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15825. * You can then easily use it as a reflectionTexture on a flat surface.
  15826. * In case the surface is not a plane, please consider relying on reflection probes.
  15827. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15828. * @param name
  15829. * @param size
  15830. * @param scene
  15831. * @param generateMipMaps
  15832. * @param type
  15833. * @param samplingMode
  15834. * @param generateDepthBuffer
  15835. */
  15836. constructor(name: string, size: number | {
  15837. width: number;
  15838. height: number;
  15839. } | {
  15840. ratio: number;
  15841. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15842. private _preparePostProcesses;
  15843. /**
  15844. * Clone the mirror texture.
  15845. * @returns the cloned texture
  15846. */
  15847. clone(): MirrorTexture;
  15848. /**
  15849. * Serialize the texture to a JSON representation you could use in Parse later on
  15850. * @returns the serialized JSON representation
  15851. */
  15852. serialize(): any;
  15853. /**
  15854. * Dispose the texture and release its associated resources.
  15855. */
  15856. dispose(): void;
  15857. }
  15858. }
  15859. declare module "babylonjs/Materials/Textures/texture" {
  15860. import { Observable } from "babylonjs/Misc/observable";
  15861. import { Nullable } from "babylonjs/types";
  15862. import { Scene } from "babylonjs/scene";
  15863. import { Matrix } from "babylonjs/Maths/math.vector";
  15864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15865. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15866. import { Engine } from "babylonjs/Engines/engine";
  15867. /**
  15868. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15869. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15870. */
  15871. export class Texture extends BaseTexture {
  15872. /** @hidden */
  15873. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15874. /** @hidden */
  15875. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15876. /** @hidden */
  15877. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15878. /** nearest is mag = nearest and min = nearest and mip = linear */
  15879. static readonly NEAREST_SAMPLINGMODE: number;
  15880. /** nearest is mag = nearest and min = nearest and mip = linear */
  15881. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15882. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15883. static readonly BILINEAR_SAMPLINGMODE: number;
  15884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15885. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15886. /** Trilinear is mag = linear and min = linear and mip = linear */
  15887. static readonly TRILINEAR_SAMPLINGMODE: number;
  15888. /** Trilinear is mag = linear and min = linear and mip = linear */
  15889. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15890. /** mag = nearest and min = nearest and mip = nearest */
  15891. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15892. /** mag = nearest and min = linear and mip = nearest */
  15893. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15894. /** mag = nearest and min = linear and mip = linear */
  15895. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15896. /** mag = nearest and min = linear and mip = none */
  15897. static readonly NEAREST_LINEAR: number;
  15898. /** mag = nearest and min = nearest and mip = none */
  15899. static readonly NEAREST_NEAREST: number;
  15900. /** mag = linear and min = nearest and mip = nearest */
  15901. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15902. /** mag = linear and min = nearest and mip = linear */
  15903. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15904. /** mag = linear and min = linear and mip = none */
  15905. static readonly LINEAR_LINEAR: number;
  15906. /** mag = linear and min = nearest and mip = none */
  15907. static readonly LINEAR_NEAREST: number;
  15908. /** Explicit coordinates mode */
  15909. static readonly EXPLICIT_MODE: number;
  15910. /** Spherical coordinates mode */
  15911. static readonly SPHERICAL_MODE: number;
  15912. /** Planar coordinates mode */
  15913. static readonly PLANAR_MODE: number;
  15914. /** Cubic coordinates mode */
  15915. static readonly CUBIC_MODE: number;
  15916. /** Projection coordinates mode */
  15917. static readonly PROJECTION_MODE: number;
  15918. /** Inverse Cubic coordinates mode */
  15919. static readonly SKYBOX_MODE: number;
  15920. /** Inverse Cubic coordinates mode */
  15921. static readonly INVCUBIC_MODE: number;
  15922. /** Equirectangular coordinates mode */
  15923. static readonly EQUIRECTANGULAR_MODE: number;
  15924. /** Equirectangular Fixed coordinates mode */
  15925. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15926. /** Equirectangular Fixed Mirrored coordinates mode */
  15927. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15928. /** Texture is not repeating outside of 0..1 UVs */
  15929. static readonly CLAMP_ADDRESSMODE: number;
  15930. /** Texture is repeating outside of 0..1 UVs */
  15931. static readonly WRAP_ADDRESSMODE: number;
  15932. /** Texture is repeating and mirrored */
  15933. static readonly MIRROR_ADDRESSMODE: number;
  15934. /**
  15935. * 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
  15936. */
  15937. static UseSerializedUrlIfAny: boolean;
  15938. /**
  15939. * Define the url of the texture.
  15940. */
  15941. url: Nullable<string>;
  15942. /**
  15943. * Define an offset on the texture to offset the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15945. */
  15946. uOffset: number;
  15947. /**
  15948. * Define an offset on the texture to offset the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15950. */
  15951. vOffset: number;
  15952. /**
  15953. * Define an offset on the texture to scale the u coordinates of the UVs
  15954. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15955. */
  15956. uScale: number;
  15957. /**
  15958. * Define an offset on the texture to scale the v coordinates of the UVs
  15959. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15960. */
  15961. vScale: number;
  15962. /**
  15963. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15964. * @see http://doc.babylonjs.com/how_to/more_materials
  15965. */
  15966. uAng: number;
  15967. /**
  15968. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15969. * @see http://doc.babylonjs.com/how_to/more_materials
  15970. */
  15971. vAng: number;
  15972. /**
  15973. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15974. * @see http://doc.babylonjs.com/how_to/more_materials
  15975. */
  15976. wAng: number;
  15977. /**
  15978. * Defines the center of rotation (U)
  15979. */
  15980. uRotationCenter: number;
  15981. /**
  15982. * Defines the center of rotation (V)
  15983. */
  15984. vRotationCenter: number;
  15985. /**
  15986. * Defines the center of rotation (W)
  15987. */
  15988. wRotationCenter: number;
  15989. /**
  15990. * Are mip maps generated for this texture or not.
  15991. */
  15992. readonly noMipmap: boolean;
  15993. /**
  15994. * List of inspectable custom properties (used by the Inspector)
  15995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15996. */
  15997. inspectableCustomProperties: Nullable<IInspectable[]>;
  15998. private _noMipmap;
  15999. /** @hidden */
  16000. _invertY: boolean;
  16001. private _rowGenerationMatrix;
  16002. private _cachedTextureMatrix;
  16003. private _projectionModeMatrix;
  16004. private _t0;
  16005. private _t1;
  16006. private _t2;
  16007. private _cachedUOffset;
  16008. private _cachedVOffset;
  16009. private _cachedUScale;
  16010. private _cachedVScale;
  16011. private _cachedUAng;
  16012. private _cachedVAng;
  16013. private _cachedWAng;
  16014. private _cachedProjectionMatrixId;
  16015. private _cachedCoordinatesMode;
  16016. /** @hidden */
  16017. protected _initialSamplingMode: number;
  16018. /** @hidden */
  16019. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16020. private _deleteBuffer;
  16021. protected _format: Nullable<number>;
  16022. private _delayedOnLoad;
  16023. private _delayedOnError;
  16024. /**
  16025. * Observable triggered once the texture has been loaded.
  16026. */
  16027. onLoadObservable: Observable<Texture>;
  16028. protected _isBlocking: boolean;
  16029. /**
  16030. * Is the texture preventing material to render while loading.
  16031. * If false, a default texture will be used instead of the loading one during the preparation step.
  16032. */
  16033. isBlocking: boolean;
  16034. /**
  16035. * Get the current sampling mode associated with the texture.
  16036. */
  16037. readonly samplingMode: number;
  16038. /**
  16039. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16040. */
  16041. readonly invertY: boolean;
  16042. /**
  16043. * Instantiates a new texture.
  16044. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16045. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16046. * @param url define the url of the picture to load as a texture
  16047. * @param scene define the scene or engine the texture will belong to
  16048. * @param noMipmap define if the texture will require mip maps or not
  16049. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16050. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16051. * @param onLoad define a callback triggered when the texture has been loaded
  16052. * @param onError define a callback triggered when an error occurred during the loading session
  16053. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16054. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16055. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16056. */
  16057. 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);
  16058. /**
  16059. * Update the url (and optional buffer) of this texture if url was null during construction.
  16060. * @param url the url of the texture
  16061. * @param buffer the buffer of the texture (defaults to null)
  16062. * @param onLoad callback called when the texture is loaded (defaults to null)
  16063. */
  16064. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16065. /**
  16066. * Finish the loading sequence of a texture flagged as delayed load.
  16067. * @hidden
  16068. */
  16069. delayLoad(): void;
  16070. private _prepareRowForTextureGeneration;
  16071. /**
  16072. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16073. * @returns the transform matrix of the texture.
  16074. */
  16075. getTextureMatrix(): Matrix;
  16076. /**
  16077. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16078. * @returns The reflection texture transform
  16079. */
  16080. getReflectionTextureMatrix(): Matrix;
  16081. /**
  16082. * Clones the texture.
  16083. * @returns the cloned texture
  16084. */
  16085. clone(): Texture;
  16086. /**
  16087. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16088. * @returns The JSON representation of the texture
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Get the current class name of the texture useful for serialization or dynamic coding.
  16093. * @returns "Texture"
  16094. */
  16095. getClassName(): string;
  16096. /**
  16097. * Dispose the texture and release its associated resources.
  16098. */
  16099. dispose(): void;
  16100. /**
  16101. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16102. * @param parsedTexture Define the JSON representation of the texture
  16103. * @param scene Define the scene the parsed texture should be instantiated in
  16104. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16105. * @returns The parsed texture if successful
  16106. */
  16107. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16108. /**
  16109. * Creates a texture from its base 64 representation.
  16110. * @param data Define the base64 payload without the data: prefix
  16111. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16112. * @param scene Define the scene the texture should belong to
  16113. * @param noMipmap Forces the texture to not create mip map information if true
  16114. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16115. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16116. * @param onLoad define a callback triggered when the texture has been loaded
  16117. * @param onError define a callback triggered when an error occurred during the loading session
  16118. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16119. * @returns the created texture
  16120. */
  16121. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16122. /**
  16123. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16124. * @param data Define the base64 payload without the data: prefix
  16125. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16126. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16127. * @param scene Define the scene the texture should belong to
  16128. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16129. * @param noMipmap Forces the texture to not create mip map information if true
  16130. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16131. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16132. * @param onLoad define a callback triggered when the texture has been loaded
  16133. * @param onError define a callback triggered when an error occurred during the loading session
  16134. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16135. * @returns the created texture
  16136. */
  16137. 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;
  16138. }
  16139. }
  16140. declare module "babylonjs/PostProcesses/postProcessManager" {
  16141. import { Nullable } from "babylonjs/types";
  16142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16144. import { Scene } from "babylonjs/scene";
  16145. /**
  16146. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16147. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16148. */
  16149. export class PostProcessManager {
  16150. private _scene;
  16151. private _indexBuffer;
  16152. private _vertexBuffers;
  16153. /**
  16154. * Creates a new instance PostProcess
  16155. * @param scene The scene that the post process is associated with.
  16156. */
  16157. constructor(scene: Scene);
  16158. private _prepareBuffers;
  16159. private _buildIndexBuffer;
  16160. /**
  16161. * Rebuilds the vertex buffers of the manager.
  16162. * @hidden
  16163. */
  16164. _rebuild(): void;
  16165. /**
  16166. * Prepares a frame to be run through a post process.
  16167. * @param sourceTexture The input texture to the post procesess. (default: null)
  16168. * @param postProcesses An array of post processes to be run. (default: null)
  16169. * @returns True if the post processes were able to be run.
  16170. * @hidden
  16171. */
  16172. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16173. /**
  16174. * Manually render a set of post processes to a texture.
  16175. * @param postProcesses An array of post processes to be run.
  16176. * @param targetTexture The target texture to render to.
  16177. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16178. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16179. * @param lodLevel defines which lod of the texture to render to
  16180. */
  16181. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16182. /**
  16183. * Finalize the result of the output of the postprocesses.
  16184. * @param doNotPresent If true the result will not be displayed to the screen.
  16185. * @param targetTexture The target texture to render to.
  16186. * @param faceIndex The index of the face to bind the target texture to.
  16187. * @param postProcesses The array of post processes to render.
  16188. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16189. * @hidden
  16190. */
  16191. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16192. /**
  16193. * Disposes of the post process manager.
  16194. */
  16195. dispose(): void;
  16196. }
  16197. }
  16198. declare module "babylonjs/Misc/gradients" {
  16199. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16200. /** Interface used by value gradients (color, factor, ...) */
  16201. export interface IValueGradient {
  16202. /**
  16203. * Gets or sets the gradient value (between 0 and 1)
  16204. */
  16205. gradient: number;
  16206. }
  16207. /** Class used to store color4 gradient */
  16208. export class ColorGradient implements IValueGradient {
  16209. /**
  16210. * Gets or sets the gradient value (between 0 and 1)
  16211. */
  16212. gradient: number;
  16213. /**
  16214. * Gets or sets first associated color
  16215. */
  16216. color1: Color4;
  16217. /**
  16218. * Gets or sets second associated color
  16219. */
  16220. color2?: Color4;
  16221. /**
  16222. * Will get a color picked randomly between color1 and color2.
  16223. * If color2 is undefined then color1 will be used
  16224. * @param result defines the target Color4 to store the result in
  16225. */
  16226. getColorToRef(result: Color4): void;
  16227. }
  16228. /** Class used to store color 3 gradient */
  16229. export class Color3Gradient implements IValueGradient {
  16230. /**
  16231. * Gets or sets the gradient value (between 0 and 1)
  16232. */
  16233. gradient: number;
  16234. /**
  16235. * Gets or sets the associated color
  16236. */
  16237. color: Color3;
  16238. }
  16239. /** Class used to store factor gradient */
  16240. export class FactorGradient implements IValueGradient {
  16241. /**
  16242. * Gets or sets the gradient value (between 0 and 1)
  16243. */
  16244. gradient: number;
  16245. /**
  16246. * Gets or sets first associated factor
  16247. */
  16248. factor1: number;
  16249. /**
  16250. * Gets or sets second associated factor
  16251. */
  16252. factor2?: number;
  16253. /**
  16254. * Will get a number picked randomly between factor1 and factor2.
  16255. * If factor2 is undefined then factor1 will be used
  16256. * @returns the picked number
  16257. */
  16258. getFactor(): number;
  16259. }
  16260. /**
  16261. * Helper used to simplify some generic gradient tasks
  16262. */
  16263. export class GradientHelper {
  16264. /**
  16265. * Gets the current gradient from an array of IValueGradient
  16266. * @param ratio defines the current ratio to get
  16267. * @param gradients defines the array of IValueGradient
  16268. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16269. */
  16270. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16271. }
  16272. }
  16273. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16274. import { Scene } from "babylonjs/scene";
  16275. import { ISceneComponent } from "babylonjs/sceneComponent";
  16276. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16277. module "babylonjs/abstractScene" {
  16278. interface AbstractScene {
  16279. /**
  16280. * The list of procedural textures added to the scene
  16281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16282. */
  16283. proceduralTextures: Array<ProceduralTexture>;
  16284. }
  16285. }
  16286. /**
  16287. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16288. * in a given scene.
  16289. */
  16290. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16291. /**
  16292. * The component name helpfull to identify the component in the list of scene components.
  16293. */
  16294. readonly name: string;
  16295. /**
  16296. * The scene the component belongs to.
  16297. */
  16298. scene: Scene;
  16299. /**
  16300. * Creates a new instance of the component for the given scene
  16301. * @param scene Defines the scene to register the component in
  16302. */
  16303. constructor(scene: Scene);
  16304. /**
  16305. * Registers the component in a given scene
  16306. */
  16307. register(): void;
  16308. /**
  16309. * Rebuilds the elements related to this component in case of
  16310. * context lost for instance.
  16311. */
  16312. rebuild(): void;
  16313. /**
  16314. * Disposes the component and the associated ressources.
  16315. */
  16316. dispose(): void;
  16317. private _beforeClear;
  16318. }
  16319. }
  16320. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16321. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16323. module "babylonjs/Engines/engine" {
  16324. interface Engine {
  16325. /**
  16326. * Creates a new render target cube texture
  16327. * @param size defines the size of the texture
  16328. * @param options defines the options used to create the texture
  16329. * @returns a new render target cube texture stored in an InternalTexture
  16330. */
  16331. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16332. }
  16333. }
  16334. }
  16335. declare module "babylonjs/Shaders/procedural.vertex" {
  16336. /** @hidden */
  16337. export var proceduralVertexShader: {
  16338. name: string;
  16339. shader: string;
  16340. };
  16341. }
  16342. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16343. import { Observable } from "babylonjs/Misc/observable";
  16344. import { Nullable } from "babylonjs/types";
  16345. import { Scene } from "babylonjs/scene";
  16346. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16347. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16348. import { Effect } from "babylonjs/Materials/effect";
  16349. import { Texture } from "babylonjs/Materials/Textures/texture";
  16350. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16351. import "babylonjs/Shaders/procedural.vertex";
  16352. /**
  16353. * 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.
  16354. * This is the base class of any Procedural texture and contains most of the shareable code.
  16355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16356. */
  16357. export class ProceduralTexture extends Texture {
  16358. isCube: boolean;
  16359. /**
  16360. * Define if the texture is enabled or not (disabled texture will not render)
  16361. */
  16362. isEnabled: boolean;
  16363. /**
  16364. * Define if the texture must be cleared before rendering (default is true)
  16365. */
  16366. autoClear: boolean;
  16367. /**
  16368. * Callback called when the texture is generated
  16369. */
  16370. onGenerated: () => void;
  16371. /**
  16372. * Event raised when the texture is generated
  16373. */
  16374. onGeneratedObservable: Observable<ProceduralTexture>;
  16375. /** @hidden */
  16376. _generateMipMaps: boolean;
  16377. /** @hidden **/
  16378. _effect: Effect;
  16379. /** @hidden */
  16380. _textures: {
  16381. [key: string]: Texture;
  16382. };
  16383. private _size;
  16384. private _currentRefreshId;
  16385. private _refreshRate;
  16386. private _vertexBuffers;
  16387. private _indexBuffer;
  16388. private _uniforms;
  16389. private _samplers;
  16390. private _fragment;
  16391. private _floats;
  16392. private _ints;
  16393. private _floatsArrays;
  16394. private _colors3;
  16395. private _colors4;
  16396. private _vectors2;
  16397. private _vectors3;
  16398. private _matrices;
  16399. private _fallbackTexture;
  16400. private _fallbackTextureUsed;
  16401. private _engine;
  16402. private _cachedDefines;
  16403. private _contentUpdateId;
  16404. private _contentData;
  16405. /**
  16406. * Instantiates a new procedural texture.
  16407. * 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.
  16408. * This is the base class of any Procedural texture and contains most of the shareable code.
  16409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16410. * @param name Define the name of the texture
  16411. * @param size Define the size of the texture to create
  16412. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16413. * @param scene Define the scene the texture belongs to
  16414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16415. * @param generateMipMaps Define if the texture should creates mip maps or not
  16416. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16417. */
  16418. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16419. /**
  16420. * The effect that is created when initializing the post process.
  16421. * @returns The created effect corresponding the the postprocess.
  16422. */
  16423. getEffect(): Effect;
  16424. /**
  16425. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16426. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16427. */
  16428. getContent(): Nullable<ArrayBufferView>;
  16429. private _createIndexBuffer;
  16430. /** @hidden */
  16431. _rebuild(): void;
  16432. /**
  16433. * Resets the texture in order to recreate its associated resources.
  16434. * This can be called in case of context loss
  16435. */
  16436. reset(): void;
  16437. protected _getDefines(): string;
  16438. /**
  16439. * Is the texture ready to be used ? (rendered at least once)
  16440. * @returns true if ready, otherwise, false.
  16441. */
  16442. isReady(): boolean;
  16443. /**
  16444. * Resets the refresh counter of the texture and start bak from scratch.
  16445. * Could be useful to regenerate the texture if it is setup to render only once.
  16446. */
  16447. resetRefreshCounter(): void;
  16448. /**
  16449. * Set the fragment shader to use in order to render the texture.
  16450. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16451. */
  16452. setFragment(fragment: any): void;
  16453. /**
  16454. * Define the refresh rate of the texture or the rendering frequency.
  16455. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16456. */
  16457. refreshRate: number;
  16458. /** @hidden */
  16459. _shouldRender(): boolean;
  16460. /**
  16461. * Get the size the texture is rendering at.
  16462. * @returns the size (texture is always squared)
  16463. */
  16464. getRenderSize(): number;
  16465. /**
  16466. * Resize the texture to new value.
  16467. * @param size Define the new size the texture should have
  16468. * @param generateMipMaps Define whether the new texture should create mip maps
  16469. */
  16470. resize(size: number, generateMipMaps: boolean): void;
  16471. private _checkUniform;
  16472. /**
  16473. * Set a texture in the shader program used to render.
  16474. * @param name Define the name of the uniform samplers as defined in the shader
  16475. * @param texture Define the texture to bind to this sampler
  16476. * @return the texture itself allowing "fluent" like uniform updates
  16477. */
  16478. setTexture(name: string, texture: Texture): ProceduralTexture;
  16479. /**
  16480. * Set a float in the shader.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the texture itself allowing "fluent" like uniform updates
  16484. */
  16485. setFloat(name: string, value: number): ProceduralTexture;
  16486. /**
  16487. * Set a int in the shader.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the texture itself allowing "fluent" like uniform updates
  16491. */
  16492. setInt(name: string, value: number): ProceduralTexture;
  16493. /**
  16494. * Set an array of floats in the shader.
  16495. * @param name Define the name of the uniform as defined in the shader
  16496. * @param value Define the value to give to the uniform
  16497. * @return the texture itself allowing "fluent" like uniform updates
  16498. */
  16499. setFloats(name: string, value: number[]): ProceduralTexture;
  16500. /**
  16501. * Set a vec3 in the shader from a Color3.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the texture itself allowing "fluent" like uniform updates
  16505. */
  16506. setColor3(name: string, value: Color3): ProceduralTexture;
  16507. /**
  16508. * Set a vec4 in the shader from a Color4.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the texture itself allowing "fluent" like uniform updates
  16512. */
  16513. setColor4(name: string, value: Color4): ProceduralTexture;
  16514. /**
  16515. * Set a vec2 in the shader from a Vector2.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the texture itself allowing "fluent" like uniform updates
  16519. */
  16520. setVector2(name: string, value: Vector2): ProceduralTexture;
  16521. /**
  16522. * Set a vec3 in the shader from a Vector3.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the texture itself allowing "fluent" like uniform updates
  16526. */
  16527. setVector3(name: string, value: Vector3): ProceduralTexture;
  16528. /**
  16529. * Set a mat4 in the shader from a MAtrix.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the texture itself allowing "fluent" like uniform updates
  16533. */
  16534. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16535. /**
  16536. * Render the texture to its associated render target.
  16537. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16538. */
  16539. render(useCameraPostProcess?: boolean): void;
  16540. /**
  16541. * Clone the texture.
  16542. * @returns the cloned texture
  16543. */
  16544. clone(): ProceduralTexture;
  16545. /**
  16546. * Dispose the texture and release its asoociated resources.
  16547. */
  16548. dispose(): void;
  16549. }
  16550. }
  16551. declare module "babylonjs/Particles/baseParticleSystem" {
  16552. import { Nullable } from "babylonjs/types";
  16553. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16555. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16556. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16557. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16558. import { Scene } from "babylonjs/scene";
  16559. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16560. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16561. import { Texture } from "babylonjs/Materials/Textures/texture";
  16562. import { Color4 } from "babylonjs/Maths/math.color";
  16563. import { Animation } from "babylonjs/Animations/animation";
  16564. /**
  16565. * This represents the base class for particle system in Babylon.
  16566. * 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.
  16567. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16568. * @example https://doc.babylonjs.com/babylon101/particles
  16569. */
  16570. export class BaseParticleSystem {
  16571. /**
  16572. * Source color is added to the destination color without alpha affecting the result
  16573. */
  16574. static BLENDMODE_ONEONE: number;
  16575. /**
  16576. * Blend current color and particle color using particle’s alpha
  16577. */
  16578. static BLENDMODE_STANDARD: number;
  16579. /**
  16580. * Add current color and particle color multiplied by particle’s alpha
  16581. */
  16582. static BLENDMODE_ADD: number;
  16583. /**
  16584. * Multiply current color with particle color
  16585. */
  16586. static BLENDMODE_MULTIPLY: number;
  16587. /**
  16588. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16589. */
  16590. static BLENDMODE_MULTIPLYADD: number;
  16591. /**
  16592. * List of animations used by the particle system.
  16593. */
  16594. animations: Animation[];
  16595. /**
  16596. * The id of the Particle system.
  16597. */
  16598. id: string;
  16599. /**
  16600. * The friendly name of the Particle system.
  16601. */
  16602. name: string;
  16603. /**
  16604. * The rendering group used by the Particle system to chose when to render.
  16605. */
  16606. renderingGroupId: number;
  16607. /**
  16608. * The emitter represents the Mesh or position we are attaching the particle system to.
  16609. */
  16610. emitter: Nullable<AbstractMesh | Vector3>;
  16611. /**
  16612. * The maximum number of particles to emit per frame
  16613. */
  16614. emitRate: number;
  16615. /**
  16616. * If you want to launch only a few particles at once, that can be done, as well.
  16617. */
  16618. manualEmitCount: number;
  16619. /**
  16620. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16621. */
  16622. updateSpeed: number;
  16623. /**
  16624. * The amount of time the particle system is running (depends of the overall update speed).
  16625. */
  16626. targetStopDuration: number;
  16627. /**
  16628. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16629. */
  16630. disposeOnStop: boolean;
  16631. /**
  16632. * Minimum power of emitting particles.
  16633. */
  16634. minEmitPower: number;
  16635. /**
  16636. * Maximum power of emitting particles.
  16637. */
  16638. maxEmitPower: number;
  16639. /**
  16640. * Minimum life time of emitting particles.
  16641. */
  16642. minLifeTime: number;
  16643. /**
  16644. * Maximum life time of emitting particles.
  16645. */
  16646. maxLifeTime: number;
  16647. /**
  16648. * Minimum Size of emitting particles.
  16649. */
  16650. minSize: number;
  16651. /**
  16652. * Maximum Size of emitting particles.
  16653. */
  16654. maxSize: number;
  16655. /**
  16656. * Minimum scale of emitting particles on X axis.
  16657. */
  16658. minScaleX: number;
  16659. /**
  16660. * Maximum scale of emitting particles on X axis.
  16661. */
  16662. maxScaleX: number;
  16663. /**
  16664. * Minimum scale of emitting particles on Y axis.
  16665. */
  16666. minScaleY: number;
  16667. /**
  16668. * Maximum scale of emitting particles on Y axis.
  16669. */
  16670. maxScaleY: number;
  16671. /**
  16672. * Gets or sets the minimal initial rotation in radians.
  16673. */
  16674. minInitialRotation: number;
  16675. /**
  16676. * Gets or sets the maximal initial rotation in radians.
  16677. */
  16678. maxInitialRotation: number;
  16679. /**
  16680. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16681. */
  16682. minAngularSpeed: number;
  16683. /**
  16684. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16685. */
  16686. maxAngularSpeed: number;
  16687. /**
  16688. * The texture used to render each particle. (this can be a spritesheet)
  16689. */
  16690. particleTexture: Nullable<Texture>;
  16691. /**
  16692. * The layer mask we are rendering the particles through.
  16693. */
  16694. layerMask: number;
  16695. /**
  16696. * This can help using your own shader to render the particle system.
  16697. * The according effect will be created
  16698. */
  16699. customShader: any;
  16700. /**
  16701. * By default particle system starts as soon as they are created. This prevents the
  16702. * automatic start to happen and let you decide when to start emitting particles.
  16703. */
  16704. preventAutoStart: boolean;
  16705. private _noiseTexture;
  16706. /**
  16707. * Gets or sets a texture used to add random noise to particle positions
  16708. */
  16709. noiseTexture: Nullable<ProceduralTexture>;
  16710. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16711. noiseStrength: Vector3;
  16712. /**
  16713. * Callback triggered when the particle animation is ending.
  16714. */
  16715. onAnimationEnd: Nullable<() => void>;
  16716. /**
  16717. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16718. */
  16719. blendMode: number;
  16720. /**
  16721. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16722. * to override the particles.
  16723. */
  16724. forceDepthWrite: boolean;
  16725. /** 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 */
  16726. preWarmCycles: number;
  16727. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16728. preWarmStepOffset: number;
  16729. /**
  16730. * 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)
  16731. */
  16732. spriteCellChangeSpeed: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16735. */
  16736. startSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16739. */
  16740. endSpriteCellID: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16743. */
  16744. spriteCellWidth: number;
  16745. /**
  16746. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16747. */
  16748. spriteCellHeight: number;
  16749. /**
  16750. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16751. */
  16752. spriteRandomStartCell: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /** @hidden */
  16756. protected _isAnimationSheetEnabled: boolean;
  16757. /**
  16758. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16759. */
  16760. beginAnimationOnStart: boolean;
  16761. /**
  16762. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16763. */
  16764. beginAnimationFrom: number;
  16765. /**
  16766. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16767. */
  16768. beginAnimationTo: number;
  16769. /**
  16770. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16771. */
  16772. beginAnimationLoop: boolean;
  16773. /**
  16774. * Gets or sets a world offset applied to all particles
  16775. */
  16776. worldOffset: Vector3;
  16777. /**
  16778. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16779. */
  16780. isAnimationSheetEnabled: boolean;
  16781. /**
  16782. * Get hosting scene
  16783. * @returns the scene
  16784. */
  16785. getScene(): Scene;
  16786. /**
  16787. * You can use gravity if you want to give an orientation to your particles.
  16788. */
  16789. gravity: Vector3;
  16790. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16791. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16792. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16793. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16794. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16795. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16796. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16797. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16798. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16799. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16800. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16801. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16802. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16803. /**
  16804. * Defines the delay in milliseconds before starting the system (0 by default)
  16805. */
  16806. startDelay: number;
  16807. /**
  16808. * Gets the current list of drag gradients.
  16809. * You must use addDragGradient and removeDragGradient to udpate this list
  16810. * @returns the list of drag gradients
  16811. */
  16812. getDragGradients(): Nullable<Array<FactorGradient>>;
  16813. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16814. limitVelocityDamping: number;
  16815. /**
  16816. * Gets the current list of limit velocity gradients.
  16817. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16818. * @returns the list of limit velocity gradients
  16819. */
  16820. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16821. /**
  16822. * Gets the current list of color gradients.
  16823. * You must use addColorGradient and removeColorGradient to udpate this list
  16824. * @returns the list of color gradients
  16825. */
  16826. getColorGradients(): Nullable<Array<ColorGradient>>;
  16827. /**
  16828. * Gets the current list of size gradients.
  16829. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16830. * @returns the list of size gradients
  16831. */
  16832. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of color remap gradients.
  16835. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16836. * @returns the list of color remap gradients
  16837. */
  16838. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Gets the current list of alpha remap gradients.
  16841. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16842. * @returns the list of alpha remap gradients
  16843. */
  16844. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16845. /**
  16846. * Gets the current list of life time gradients.
  16847. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16848. * @returns the list of life time gradients
  16849. */
  16850. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Gets the current list of angular speed gradients.
  16853. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16854. * @returns the list of angular speed gradients
  16855. */
  16856. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Gets the current list of velocity gradients.
  16859. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16860. * @returns the list of velocity gradients
  16861. */
  16862. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16863. /**
  16864. * Gets the current list of start size gradients.
  16865. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16866. * @returns the list of start size gradients
  16867. */
  16868. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16869. /**
  16870. * Gets the current list of emit rate gradients.
  16871. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16872. * @returns the list of emit rate gradients
  16873. */
  16874. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16875. /**
  16876. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16877. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16878. */
  16879. direction1: Vector3;
  16880. /**
  16881. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16882. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16883. */
  16884. direction2: Vector3;
  16885. /**
  16886. * 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.
  16887. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16888. */
  16889. minEmitBox: Vector3;
  16890. /**
  16891. * 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.
  16892. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16893. */
  16894. maxEmitBox: Vector3;
  16895. /**
  16896. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16897. */
  16898. color1: Color4;
  16899. /**
  16900. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16901. */
  16902. color2: Color4;
  16903. /**
  16904. * Color the particle will have at the end of its lifetime
  16905. */
  16906. colorDead: Color4;
  16907. /**
  16908. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16909. */
  16910. textureMask: Color4;
  16911. /**
  16912. * The particle emitter type defines the emitter used by the particle system.
  16913. * It can be for example box, sphere, or cone...
  16914. */
  16915. particleEmitterType: IParticleEmitterType;
  16916. /** @hidden */
  16917. _isSubEmitter: boolean;
  16918. /**
  16919. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16920. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16921. */
  16922. billboardMode: number;
  16923. protected _isBillboardBased: boolean;
  16924. /**
  16925. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16926. */
  16927. isBillboardBased: boolean;
  16928. /**
  16929. * The scene the particle system belongs to.
  16930. */
  16931. protected _scene: Scene;
  16932. /**
  16933. * Local cache of defines for image processing.
  16934. */
  16935. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16936. /**
  16937. * Default configuration related to image processing available in the standard Material.
  16938. */
  16939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16940. /**
  16941. * Gets the image processing configuration used either in this material.
  16942. */
  16943. /**
  16944. * Sets the Default image processing configuration used either in the this material.
  16945. *
  16946. * If sets to null, the scene one is in use.
  16947. */
  16948. imageProcessingConfiguration: ImageProcessingConfiguration;
  16949. /**
  16950. * Attaches a new image processing configuration to the Standard Material.
  16951. * @param configuration
  16952. */
  16953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16954. /** @hidden */
  16955. protected _reset(): void;
  16956. /** @hidden */
  16957. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16958. /**
  16959. * Instantiates a particle system.
  16960. * 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.
  16961. * @param name The name of the particle system
  16962. */
  16963. constructor(name: string);
  16964. /**
  16965. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16966. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16967. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16968. * @returns the emitter
  16969. */
  16970. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16971. /**
  16972. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16973. * @param radius The radius of the hemisphere to emit from
  16974. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16975. * @returns the emitter
  16976. */
  16977. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16978. /**
  16979. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16980. * @param radius The radius of the sphere to emit from
  16981. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16982. * @returns the emitter
  16983. */
  16984. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16985. /**
  16986. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16987. * @param radius The radius of the sphere to emit from
  16988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16990. * @returns the emitter
  16991. */
  16992. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16993. /**
  16994. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16995. * @param radius The radius of the emission cylinder
  16996. * @param height The height of the emission cylinder
  16997. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16998. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16999. * @returns the emitter
  17000. */
  17001. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17002. /**
  17003. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17004. * @param radius The radius of the cylinder to emit from
  17005. * @param height The height of the emission cylinder
  17006. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17009. * @returns the emitter
  17010. */
  17011. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17012. /**
  17013. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17014. * @param radius The radius of the cone to emit from
  17015. * @param angle The base angle of the cone
  17016. * @returns the emitter
  17017. */
  17018. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17019. /**
  17020. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17023. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17024. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17025. * @returns the emitter
  17026. */
  17027. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17028. }
  17029. }
  17030. declare module "babylonjs/Particles/subEmitter" {
  17031. import { Scene } from "babylonjs/scene";
  17032. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17033. /**
  17034. * Type of sub emitter
  17035. */
  17036. export enum SubEmitterType {
  17037. /**
  17038. * Attached to the particle over it's lifetime
  17039. */
  17040. ATTACHED = 0,
  17041. /**
  17042. * Created when the particle dies
  17043. */
  17044. END = 1
  17045. }
  17046. /**
  17047. * Sub emitter class used to emit particles from an existing particle
  17048. */
  17049. export class SubEmitter {
  17050. /**
  17051. * the particle system to be used by the sub emitter
  17052. */
  17053. particleSystem: ParticleSystem;
  17054. /**
  17055. * Type of the submitter (Default: END)
  17056. */
  17057. type: SubEmitterType;
  17058. /**
  17059. * 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)
  17060. * Note: This only is supported when using an emitter of type Mesh
  17061. */
  17062. inheritDirection: boolean;
  17063. /**
  17064. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17065. */
  17066. inheritedVelocityAmount: number;
  17067. /**
  17068. * Creates a sub emitter
  17069. * @param particleSystem the particle system to be used by the sub emitter
  17070. */
  17071. constructor(
  17072. /**
  17073. * the particle system to be used by the sub emitter
  17074. */
  17075. particleSystem: ParticleSystem);
  17076. /**
  17077. * Clones the sub emitter
  17078. * @returns the cloned sub emitter
  17079. */
  17080. clone(): SubEmitter;
  17081. /**
  17082. * Serialize current object to a JSON object
  17083. * @returns the serialized object
  17084. */
  17085. serialize(): any;
  17086. /** @hidden */
  17087. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17088. /**
  17089. * Creates a new SubEmitter from a serialized JSON version
  17090. * @param serializationObject defines the JSON object to read from
  17091. * @param scene defines the hosting scene
  17092. * @param rootUrl defines the rootUrl for data loading
  17093. * @returns a new SubEmitter
  17094. */
  17095. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17096. /** Release associated resources */
  17097. dispose(): void;
  17098. }
  17099. }
  17100. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17101. /** @hidden */
  17102. export var clipPlaneFragmentDeclaration: {
  17103. name: string;
  17104. shader: string;
  17105. };
  17106. }
  17107. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17108. /** @hidden */
  17109. export var imageProcessingDeclaration: {
  17110. name: string;
  17111. shader: string;
  17112. };
  17113. }
  17114. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17115. /** @hidden */
  17116. export var imageProcessingFunctions: {
  17117. name: string;
  17118. shader: string;
  17119. };
  17120. }
  17121. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17122. /** @hidden */
  17123. export var clipPlaneFragment: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/particles.fragment" {
  17129. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17130. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17131. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17132. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17134. /** @hidden */
  17135. export var particlesPixelShader: {
  17136. name: string;
  17137. shader: string;
  17138. };
  17139. }
  17140. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17141. /** @hidden */
  17142. export var clipPlaneVertexDeclaration: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17148. /** @hidden */
  17149. export var clipPlaneVertex: {
  17150. name: string;
  17151. shader: string;
  17152. };
  17153. }
  17154. declare module "babylonjs/Shaders/particles.vertex" {
  17155. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17157. /** @hidden */
  17158. export var particlesVertexShader: {
  17159. name: string;
  17160. shader: string;
  17161. };
  17162. }
  17163. declare module "babylonjs/Particles/particleSystem" {
  17164. import { Nullable } from "babylonjs/types";
  17165. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17166. import { Observable } from "babylonjs/Misc/observable";
  17167. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17168. import { Effect } from "babylonjs/Materials/effect";
  17169. import { Scene, IDisposable } from "babylonjs/scene";
  17170. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17171. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17172. import { Particle } from "babylonjs/Particles/particle";
  17173. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17174. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17175. import "babylonjs/Shaders/particles.fragment";
  17176. import "babylonjs/Shaders/particles.vertex";
  17177. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17178. /**
  17179. * This represents a particle system in Babylon.
  17180. * 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.
  17181. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17182. * @example https://doc.babylonjs.com/babylon101/particles
  17183. */
  17184. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17185. /**
  17186. * Billboard mode will only apply to Y axis
  17187. */
  17188. static readonly BILLBOARDMODE_Y: number;
  17189. /**
  17190. * Billboard mode will apply to all axes
  17191. */
  17192. static readonly BILLBOARDMODE_ALL: number;
  17193. /**
  17194. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17195. */
  17196. static readonly BILLBOARDMODE_STRETCHED: number;
  17197. /**
  17198. * This function can be defined to provide custom update for active particles.
  17199. * This function will be called instead of regular update (age, position, color, etc.).
  17200. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17201. */
  17202. updateFunction: (particles: Particle[]) => void;
  17203. private _emitterWorldMatrix;
  17204. /**
  17205. * This function can be defined to specify initial direction for every new particle.
  17206. * It by default use the emitterType defined function
  17207. */
  17208. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17209. /**
  17210. * This function can be defined to specify initial position for every new particle.
  17211. * It by default use the emitterType defined function
  17212. */
  17213. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17214. /**
  17215. * @hidden
  17216. */
  17217. _inheritedVelocityOffset: Vector3;
  17218. /**
  17219. * An event triggered when the system is disposed
  17220. */
  17221. onDisposeObservable: Observable<ParticleSystem>;
  17222. private _onDisposeObserver;
  17223. /**
  17224. * Sets a callback that will be triggered when the system is disposed
  17225. */
  17226. onDispose: () => void;
  17227. private _particles;
  17228. private _epsilon;
  17229. private _capacity;
  17230. private _stockParticles;
  17231. private _newPartsExcess;
  17232. private _vertexData;
  17233. private _vertexBuffer;
  17234. private _vertexBuffers;
  17235. private _spriteBuffer;
  17236. private _indexBuffer;
  17237. private _effect;
  17238. private _customEffect;
  17239. private _cachedDefines;
  17240. private _scaledColorStep;
  17241. private _colorDiff;
  17242. private _scaledDirection;
  17243. private _scaledGravity;
  17244. private _currentRenderId;
  17245. private _alive;
  17246. private _useInstancing;
  17247. private _started;
  17248. private _stopped;
  17249. private _actualFrame;
  17250. private _scaledUpdateSpeed;
  17251. private _vertexBufferSize;
  17252. /** @hidden */
  17253. _currentEmitRateGradient: Nullable<FactorGradient>;
  17254. /** @hidden */
  17255. _currentEmitRate1: number;
  17256. /** @hidden */
  17257. _currentEmitRate2: number;
  17258. /** @hidden */
  17259. _currentStartSizeGradient: Nullable<FactorGradient>;
  17260. /** @hidden */
  17261. _currentStartSize1: number;
  17262. /** @hidden */
  17263. _currentStartSize2: number;
  17264. private readonly _rawTextureWidth;
  17265. private _rampGradientsTexture;
  17266. private _useRampGradients;
  17267. /** Gets or sets a boolean indicating that ramp gradients must be used
  17268. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17269. */
  17270. useRampGradients: boolean;
  17271. /**
  17272. * 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.
  17273. * 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: [])
  17274. */
  17275. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17276. private _subEmitters;
  17277. /**
  17278. * @hidden
  17279. * If the particle systems emitter should be disposed when the particle system is disposed
  17280. */
  17281. _disposeEmitterOnDispose: boolean;
  17282. /**
  17283. * The current active Sub-systems, this property is used by the root particle system only.
  17284. */
  17285. activeSubSystems: Array<ParticleSystem>;
  17286. private _rootParticleSystem;
  17287. /**
  17288. * Gets the current list of active particles
  17289. */
  17290. readonly particles: Particle[];
  17291. /**
  17292. * Returns the string "ParticleSystem"
  17293. * @returns a string containing the class name
  17294. */
  17295. getClassName(): string;
  17296. /**
  17297. * Instantiates a particle system.
  17298. * 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.
  17299. * @param name The name of the particle system
  17300. * @param capacity The max number of particles alive at the same time
  17301. * @param scene The scene the particle system belongs to
  17302. * @param customEffect a custom effect used to change the way particles are rendered by default
  17303. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17304. * @param epsilon Offset used to render the particles
  17305. */
  17306. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17307. private _addFactorGradient;
  17308. private _removeFactorGradient;
  17309. /**
  17310. * Adds a new life time gradient
  17311. * @param gradient defines the gradient to use (between 0 and 1)
  17312. * @param factor defines the life time factor to affect to the specified gradient
  17313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17314. * @returns the current particle system
  17315. */
  17316. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17317. /**
  17318. * Remove a specific life time gradient
  17319. * @param gradient defines the gradient to remove
  17320. * @returns the current particle system
  17321. */
  17322. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17323. /**
  17324. * Adds a new size gradient
  17325. * @param gradient defines the gradient to use (between 0 and 1)
  17326. * @param factor defines the size factor to affect to the specified gradient
  17327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17328. * @returns the current particle system
  17329. */
  17330. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17331. /**
  17332. * Remove a specific size gradient
  17333. * @param gradient defines the gradient to remove
  17334. * @returns the current particle system
  17335. */
  17336. removeSizeGradient(gradient: number): IParticleSystem;
  17337. /**
  17338. * Adds a new color remap gradient
  17339. * @param gradient defines the gradient to use (between 0 and 1)
  17340. * @param min defines the color remap minimal range
  17341. * @param max defines the color remap maximal range
  17342. * @returns the current particle system
  17343. */
  17344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17345. /**
  17346. * Remove a specific color remap gradient
  17347. * @param gradient defines the gradient to remove
  17348. * @returns the current particle system
  17349. */
  17350. removeColorRemapGradient(gradient: number): IParticleSystem;
  17351. /**
  17352. * Adds a new alpha remap gradient
  17353. * @param gradient defines the gradient to use (between 0 and 1)
  17354. * @param min defines the alpha remap minimal range
  17355. * @param max defines the alpha remap maximal range
  17356. * @returns the current particle system
  17357. */
  17358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17359. /**
  17360. * Remove a specific alpha remap gradient
  17361. * @param gradient defines the gradient to remove
  17362. * @returns the current particle system
  17363. */
  17364. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17365. /**
  17366. * Adds a new angular speed gradient
  17367. * @param gradient defines the gradient to use (between 0 and 1)
  17368. * @param factor defines the angular speed to affect to the specified gradient
  17369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17370. * @returns the current particle system
  17371. */
  17372. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17373. /**
  17374. * Remove a specific angular speed gradient
  17375. * @param gradient defines the gradient to remove
  17376. * @returns the current particle system
  17377. */
  17378. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17379. /**
  17380. * Adds a new velocity gradient
  17381. * @param gradient defines the gradient to use (between 0 and 1)
  17382. * @param factor defines the velocity to affect to the specified gradient
  17383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17384. * @returns the current particle system
  17385. */
  17386. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17387. /**
  17388. * Remove a specific velocity gradient
  17389. * @param gradient defines the gradient to remove
  17390. * @returns the current particle system
  17391. */
  17392. removeVelocityGradient(gradient: number): IParticleSystem;
  17393. /**
  17394. * Adds a new limit velocity gradient
  17395. * @param gradient defines the gradient to use (between 0 and 1)
  17396. * @param factor defines the limit velocity value to affect to the specified gradient
  17397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17398. * @returns the current particle system
  17399. */
  17400. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17401. /**
  17402. * Remove a specific limit velocity gradient
  17403. * @param gradient defines the gradient to remove
  17404. * @returns the current particle system
  17405. */
  17406. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17407. /**
  17408. * Adds a new drag gradient
  17409. * @param gradient defines the gradient to use (between 0 and 1)
  17410. * @param factor defines the drag value to affect to the specified gradient
  17411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17412. * @returns the current particle system
  17413. */
  17414. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17415. /**
  17416. * Remove a specific drag gradient
  17417. * @param gradient defines the gradient to remove
  17418. * @returns the current particle system
  17419. */
  17420. removeDragGradient(gradient: number): IParticleSystem;
  17421. /**
  17422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17423. * @param gradient defines the gradient to use (between 0 and 1)
  17424. * @param factor defines the emit rate value to affect to the specified gradient
  17425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17426. * @returns the current particle system
  17427. */
  17428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17429. /**
  17430. * Remove a specific emit rate gradient
  17431. * @param gradient defines the gradient to remove
  17432. * @returns the current particle system
  17433. */
  17434. removeEmitRateGradient(gradient: number): IParticleSystem;
  17435. /**
  17436. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17437. * @param gradient defines the gradient to use (between 0 and 1)
  17438. * @param factor defines the start size value to affect to the specified gradient
  17439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17440. * @returns the current particle system
  17441. */
  17442. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17443. /**
  17444. * Remove a specific start size gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeStartSizeGradient(gradient: number): IParticleSystem;
  17449. private _createRampGradientTexture;
  17450. /**
  17451. * Gets the current list of ramp gradients.
  17452. * You must use addRampGradient and removeRampGradient to udpate this list
  17453. * @returns the list of ramp gradients
  17454. */
  17455. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17456. /**
  17457. * Adds a new ramp gradient used to remap particle colors
  17458. * @param gradient defines the gradient to use (between 0 and 1)
  17459. * @param color defines the color to affect to the specified gradient
  17460. * @returns the current particle system
  17461. */
  17462. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17463. /**
  17464. * Remove a specific ramp gradient
  17465. * @param gradient defines the gradient to remove
  17466. * @returns the current particle system
  17467. */
  17468. removeRampGradient(gradient: number): ParticleSystem;
  17469. /**
  17470. * Adds a new color gradient
  17471. * @param gradient defines the gradient to use (between 0 and 1)
  17472. * @param color1 defines the color to affect to the specified gradient
  17473. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17474. * @returns this particle system
  17475. */
  17476. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17477. /**
  17478. * Remove a specific color gradient
  17479. * @param gradient defines the gradient to remove
  17480. * @returns this particle system
  17481. */
  17482. removeColorGradient(gradient: number): IParticleSystem;
  17483. private _fetchR;
  17484. protected _reset(): void;
  17485. private _resetEffect;
  17486. private _createVertexBuffers;
  17487. private _createIndexBuffer;
  17488. /**
  17489. * Gets the maximum number of particles active at the same time.
  17490. * @returns The max number of active particles.
  17491. */
  17492. getCapacity(): number;
  17493. /**
  17494. * Gets whether there are still active particles in the system.
  17495. * @returns True if it is alive, otherwise false.
  17496. */
  17497. isAlive(): boolean;
  17498. /**
  17499. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17500. * @returns True if it has been started, otherwise false.
  17501. */
  17502. isStarted(): boolean;
  17503. private _prepareSubEmitterInternalArray;
  17504. /**
  17505. * Starts the particle system and begins to emit
  17506. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17507. */
  17508. start(delay?: number): void;
  17509. /**
  17510. * Stops the particle system.
  17511. * @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.
  17512. */
  17513. stop(stopSubEmitters?: boolean): void;
  17514. /**
  17515. * Remove all active particles
  17516. */
  17517. reset(): void;
  17518. /**
  17519. * @hidden (for internal use only)
  17520. */
  17521. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17522. /**
  17523. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17524. * Its lifetime will start back at 0.
  17525. */
  17526. recycleParticle: (particle: Particle) => void;
  17527. private _stopSubEmitters;
  17528. private _createParticle;
  17529. private _removeFromRoot;
  17530. private _emitFromParticle;
  17531. private _update;
  17532. /** @hidden */
  17533. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17534. /** @hidden */
  17535. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17536. /** @hidden */
  17537. private _getEffect;
  17538. /**
  17539. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17540. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17541. */
  17542. animate(preWarmOnly?: boolean): void;
  17543. private _appendParticleVertices;
  17544. /**
  17545. * Rebuilds the particle system.
  17546. */
  17547. rebuild(): void;
  17548. /**
  17549. * Is this system ready to be used/rendered
  17550. * @return true if the system is ready
  17551. */
  17552. isReady(): boolean;
  17553. private _render;
  17554. /**
  17555. * Renders the particle system in its current state.
  17556. * @returns the current number of particles
  17557. */
  17558. render(): number;
  17559. /**
  17560. * Disposes the particle system and free the associated resources
  17561. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17562. */
  17563. dispose(disposeTexture?: boolean): void;
  17564. /**
  17565. * Clones the particle system.
  17566. * @param name The name of the cloned object
  17567. * @param newEmitter The new emitter to use
  17568. * @returns the cloned particle system
  17569. */
  17570. clone(name: string, newEmitter: any): ParticleSystem;
  17571. /**
  17572. * Serializes the particle system to a JSON object.
  17573. * @returns the JSON object
  17574. */
  17575. serialize(): any;
  17576. /** @hidden */
  17577. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17578. /** @hidden */
  17579. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17580. /**
  17581. * Parses a JSON object to create a particle system.
  17582. * @param parsedParticleSystem The JSON object to parse
  17583. * @param scene The scene to create the particle system in
  17584. * @param rootUrl The root url to use to load external dependencies like texture
  17585. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17586. * @returns the Parsed particle system
  17587. */
  17588. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17589. }
  17590. }
  17591. declare module "babylonjs/Particles/particle" {
  17592. import { Nullable } from "babylonjs/types";
  17593. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17594. import { Color4 } from "babylonjs/Maths/math.color";
  17595. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17596. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17597. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17598. /**
  17599. * A particle represents one of the element emitted by a particle system.
  17600. * This is mainly define by its coordinates, direction, velocity and age.
  17601. */
  17602. export class Particle {
  17603. /**
  17604. * The particle system the particle belongs to.
  17605. */
  17606. particleSystem: ParticleSystem;
  17607. private static _Count;
  17608. /**
  17609. * Unique ID of the particle
  17610. */
  17611. id: number;
  17612. /**
  17613. * The world position of the particle in the scene.
  17614. */
  17615. position: Vector3;
  17616. /**
  17617. * The world direction of the particle in the scene.
  17618. */
  17619. direction: Vector3;
  17620. /**
  17621. * The color of the particle.
  17622. */
  17623. color: Color4;
  17624. /**
  17625. * The color change of the particle per step.
  17626. */
  17627. colorStep: Color4;
  17628. /**
  17629. * Defines how long will the life of the particle be.
  17630. */
  17631. lifeTime: number;
  17632. /**
  17633. * The current age of the particle.
  17634. */
  17635. age: number;
  17636. /**
  17637. * The current size of the particle.
  17638. */
  17639. size: number;
  17640. /**
  17641. * The current scale of the particle.
  17642. */
  17643. scale: Vector2;
  17644. /**
  17645. * The current angle of the particle.
  17646. */
  17647. angle: number;
  17648. /**
  17649. * Defines how fast is the angle changing.
  17650. */
  17651. angularSpeed: number;
  17652. /**
  17653. * Defines the cell index used by the particle to be rendered from a sprite.
  17654. */
  17655. cellIndex: number;
  17656. /**
  17657. * The information required to support color remapping
  17658. */
  17659. remapData: Vector4;
  17660. /** @hidden */
  17661. _randomCellOffset?: number;
  17662. /** @hidden */
  17663. _initialDirection: Nullable<Vector3>;
  17664. /** @hidden */
  17665. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17666. /** @hidden */
  17667. _initialStartSpriteCellID: number;
  17668. /** @hidden */
  17669. _initialEndSpriteCellID: number;
  17670. /** @hidden */
  17671. _currentColorGradient: Nullable<ColorGradient>;
  17672. /** @hidden */
  17673. _currentColor1: Color4;
  17674. /** @hidden */
  17675. _currentColor2: Color4;
  17676. /** @hidden */
  17677. _currentSizeGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentSize1: number;
  17680. /** @hidden */
  17681. _currentSize2: number;
  17682. /** @hidden */
  17683. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentAngularSpeed1: number;
  17686. /** @hidden */
  17687. _currentAngularSpeed2: number;
  17688. /** @hidden */
  17689. _currentVelocityGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentVelocity1: number;
  17692. /** @hidden */
  17693. _currentVelocity2: number;
  17694. /** @hidden */
  17695. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17696. /** @hidden */
  17697. _currentLimitVelocity1: number;
  17698. /** @hidden */
  17699. _currentLimitVelocity2: number;
  17700. /** @hidden */
  17701. _currentDragGradient: Nullable<FactorGradient>;
  17702. /** @hidden */
  17703. _currentDrag1: number;
  17704. /** @hidden */
  17705. _currentDrag2: number;
  17706. /** @hidden */
  17707. _randomNoiseCoordinates1: Vector3;
  17708. /** @hidden */
  17709. _randomNoiseCoordinates2: Vector3;
  17710. /**
  17711. * Creates a new instance Particle
  17712. * @param particleSystem the particle system the particle belongs to
  17713. */
  17714. constructor(
  17715. /**
  17716. * The particle system the particle belongs to.
  17717. */
  17718. particleSystem: ParticleSystem);
  17719. private updateCellInfoFromSystem;
  17720. /**
  17721. * Defines how the sprite cell index is updated for the particle
  17722. */
  17723. updateCellIndex(): void;
  17724. /** @hidden */
  17725. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17726. /** @hidden */
  17727. _inheritParticleInfoToSubEmitters(): void;
  17728. /** @hidden */
  17729. _reset(): void;
  17730. /**
  17731. * Copy the properties of particle to another one.
  17732. * @param other the particle to copy the information to.
  17733. */
  17734. copyTo(other: Particle): void;
  17735. }
  17736. }
  17737. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17739. import { Effect } from "babylonjs/Materials/effect";
  17740. import { Particle } from "babylonjs/Particles/particle";
  17741. /**
  17742. * Particle emitter represents a volume emitting particles.
  17743. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17744. */
  17745. export interface IParticleEmitterType {
  17746. /**
  17747. * Called by the particle System when the direction is computed for the created particle.
  17748. * @param worldMatrix is the world matrix of the particle system
  17749. * @param directionToUpdate is the direction vector to update with the result
  17750. * @param particle is the particle we are computed the direction for
  17751. */
  17752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17753. /**
  17754. * Called by the particle System when the position is computed for the created particle.
  17755. * @param worldMatrix is the world matrix of the particle system
  17756. * @param positionToUpdate is the position vector to update with the result
  17757. * @param particle is the particle we are computed the position for
  17758. */
  17759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17760. /**
  17761. * Clones the current emitter and returns a copy of it
  17762. * @returns the new emitter
  17763. */
  17764. clone(): IParticleEmitterType;
  17765. /**
  17766. * Called by the GPUParticleSystem to setup the update shader
  17767. * @param effect defines the update shader
  17768. */
  17769. applyToShader(effect: Effect): void;
  17770. /**
  17771. * Returns a string to use to update the GPU particles update shader
  17772. * @returns the effect defines string
  17773. */
  17774. getEffectDefines(): string;
  17775. /**
  17776. * Returns a string representing the class name
  17777. * @returns a string containing the class name
  17778. */
  17779. getClassName(): string;
  17780. /**
  17781. * Serializes the particle system to a JSON object.
  17782. * @returns the JSON object
  17783. */
  17784. serialize(): any;
  17785. /**
  17786. * Parse properties from a JSON object
  17787. * @param serializationObject defines the JSON object
  17788. */
  17789. parse(serializationObject: any): void;
  17790. }
  17791. }
  17792. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17793. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17794. import { Effect } from "babylonjs/Materials/effect";
  17795. import { Particle } from "babylonjs/Particles/particle";
  17796. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17797. /**
  17798. * Particle emitter emitting particles from the inside of a box.
  17799. * It emits the particles randomly between 2 given directions.
  17800. */
  17801. export class BoxParticleEmitter implements IParticleEmitterType {
  17802. /**
  17803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17804. */
  17805. direction1: Vector3;
  17806. /**
  17807. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17808. */
  17809. direction2: Vector3;
  17810. /**
  17811. * 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.
  17812. */
  17813. minEmitBox: Vector3;
  17814. /**
  17815. * 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.
  17816. */
  17817. maxEmitBox: Vector3;
  17818. /**
  17819. * Creates a new instance BoxParticleEmitter
  17820. */
  17821. constructor();
  17822. /**
  17823. * Called by the particle System when the direction is computed for the created particle.
  17824. * @param worldMatrix is the world matrix of the particle system
  17825. * @param directionToUpdate is the direction vector to update with the result
  17826. * @param particle is the particle we are computed the direction for
  17827. */
  17828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17829. /**
  17830. * Called by the particle System when the position is computed for the created particle.
  17831. * @param worldMatrix is the world matrix of the particle system
  17832. * @param positionToUpdate is the position vector to update with the result
  17833. * @param particle is the particle we are computed the position for
  17834. */
  17835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17836. /**
  17837. * Clones the current emitter and returns a copy of it
  17838. * @returns the new emitter
  17839. */
  17840. clone(): BoxParticleEmitter;
  17841. /**
  17842. * Called by the GPUParticleSystem to setup the update shader
  17843. * @param effect defines the update shader
  17844. */
  17845. applyToShader(effect: Effect): void;
  17846. /**
  17847. * Returns a string to use to update the GPU particles update shader
  17848. * @returns a string containng the defines string
  17849. */
  17850. getEffectDefines(): string;
  17851. /**
  17852. * Returns the string "BoxParticleEmitter"
  17853. * @returns a string containing the class name
  17854. */
  17855. getClassName(): string;
  17856. /**
  17857. * Serializes the particle system to a JSON object.
  17858. * @returns the JSON object
  17859. */
  17860. serialize(): any;
  17861. /**
  17862. * Parse properties from a JSON object
  17863. * @param serializationObject defines the JSON object
  17864. */
  17865. parse(serializationObject: any): void;
  17866. }
  17867. }
  17868. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17870. import { Effect } from "babylonjs/Materials/effect";
  17871. import { Particle } from "babylonjs/Particles/particle";
  17872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17873. /**
  17874. * Particle emitter emitting particles from the inside of a cone.
  17875. * It emits the particles alongside the cone volume from the base to the particle.
  17876. * The emission direction might be randomized.
  17877. */
  17878. export class ConeParticleEmitter implements IParticleEmitterType {
  17879. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17880. directionRandomizer: number;
  17881. private _radius;
  17882. private _angle;
  17883. private _height;
  17884. /**
  17885. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17886. */
  17887. radiusRange: number;
  17888. /**
  17889. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17890. */
  17891. heightRange: number;
  17892. /**
  17893. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17894. */
  17895. emitFromSpawnPointOnly: boolean;
  17896. /**
  17897. * Gets or sets the radius of the emission cone
  17898. */
  17899. radius: number;
  17900. /**
  17901. * Gets or sets the angle of the emission cone
  17902. */
  17903. angle: number;
  17904. private _buildHeight;
  17905. /**
  17906. * Creates a new instance ConeParticleEmitter
  17907. * @param radius the radius of the emission cone (1 by default)
  17908. * @param angle the cone base angle (PI by default)
  17909. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17910. */
  17911. constructor(radius?: number, angle?: number,
  17912. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17913. directionRandomizer?: number);
  17914. /**
  17915. * Called by the particle System when the direction is computed for the created particle.
  17916. * @param worldMatrix is the world matrix of the particle system
  17917. * @param directionToUpdate is the direction vector to update with the result
  17918. * @param particle is the particle we are computed the direction for
  17919. */
  17920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17921. /**
  17922. * Called by the particle System when the position is computed for the created particle.
  17923. * @param worldMatrix is the world matrix of the particle system
  17924. * @param positionToUpdate is the position vector to update with the result
  17925. * @param particle is the particle we are computed the position for
  17926. */
  17927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17928. /**
  17929. * Clones the current emitter and returns a copy of it
  17930. * @returns the new emitter
  17931. */
  17932. clone(): ConeParticleEmitter;
  17933. /**
  17934. * Called by the GPUParticleSystem to setup the update shader
  17935. * @param effect defines the update shader
  17936. */
  17937. applyToShader(effect: Effect): void;
  17938. /**
  17939. * Returns a string to use to update the GPU particles update shader
  17940. * @returns a string containng the defines string
  17941. */
  17942. getEffectDefines(): string;
  17943. /**
  17944. * Returns the string "ConeParticleEmitter"
  17945. * @returns a string containing the class name
  17946. */
  17947. getClassName(): string;
  17948. /**
  17949. * Serializes the particle system to a JSON object.
  17950. * @returns the JSON object
  17951. */
  17952. serialize(): any;
  17953. /**
  17954. * Parse properties from a JSON object
  17955. * @param serializationObject defines the JSON object
  17956. */
  17957. parse(serializationObject: any): void;
  17958. }
  17959. }
  17960. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17961. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17962. import { Effect } from "babylonjs/Materials/effect";
  17963. import { Particle } from "babylonjs/Particles/particle";
  17964. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17965. /**
  17966. * Particle emitter emitting particles from the inside of a cylinder.
  17967. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17968. */
  17969. export class CylinderParticleEmitter implements IParticleEmitterType {
  17970. /**
  17971. * The radius of the emission cylinder.
  17972. */
  17973. radius: number;
  17974. /**
  17975. * The height of the emission cylinder.
  17976. */
  17977. height: number;
  17978. /**
  17979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17980. */
  17981. radiusRange: number;
  17982. /**
  17983. * How much to randomize the particle direction [0-1].
  17984. */
  17985. directionRandomizer: number;
  17986. /**
  17987. * Creates a new instance CylinderParticleEmitter
  17988. * @param radius the radius of the emission cylinder (1 by default)
  17989. * @param height the height of the emission cylinder (1 by default)
  17990. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17991. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17992. */
  17993. constructor(
  17994. /**
  17995. * The radius of the emission cylinder.
  17996. */
  17997. radius?: number,
  17998. /**
  17999. * The height of the emission cylinder.
  18000. */
  18001. height?: number,
  18002. /**
  18003. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18004. */
  18005. radiusRange?: number,
  18006. /**
  18007. * How much to randomize the particle direction [0-1].
  18008. */
  18009. directionRandomizer?: number);
  18010. /**
  18011. * Called by the particle System when the direction is computed for the created particle.
  18012. * @param worldMatrix is the world matrix of the particle system
  18013. * @param directionToUpdate is the direction vector to update with the result
  18014. * @param particle is the particle we are computed the direction for
  18015. */
  18016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18017. /**
  18018. * Called by the particle System when the position is computed for the created particle.
  18019. * @param worldMatrix is the world matrix of the particle system
  18020. * @param positionToUpdate is the position vector to update with the result
  18021. * @param particle is the particle we are computed the position for
  18022. */
  18023. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18024. /**
  18025. * Clones the current emitter and returns a copy of it
  18026. * @returns the new emitter
  18027. */
  18028. clone(): CylinderParticleEmitter;
  18029. /**
  18030. * Called by the GPUParticleSystem to setup the update shader
  18031. * @param effect defines the update shader
  18032. */
  18033. applyToShader(effect: Effect): void;
  18034. /**
  18035. * Returns a string to use to update the GPU particles update shader
  18036. * @returns a string containng the defines string
  18037. */
  18038. getEffectDefines(): string;
  18039. /**
  18040. * Returns the string "CylinderParticleEmitter"
  18041. * @returns a string containing the class name
  18042. */
  18043. getClassName(): string;
  18044. /**
  18045. * Serializes the particle system to a JSON object.
  18046. * @returns the JSON object
  18047. */
  18048. serialize(): any;
  18049. /**
  18050. * Parse properties from a JSON object
  18051. * @param serializationObject defines the JSON object
  18052. */
  18053. parse(serializationObject: any): void;
  18054. }
  18055. /**
  18056. * Particle emitter emitting particles from the inside of a cylinder.
  18057. * It emits the particles randomly between two vectors.
  18058. */
  18059. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18060. /**
  18061. * The min limit of the emission direction.
  18062. */
  18063. direction1: Vector3;
  18064. /**
  18065. * The max limit of the emission direction.
  18066. */
  18067. direction2: Vector3;
  18068. /**
  18069. * Creates a new instance CylinderDirectedParticleEmitter
  18070. * @param radius the radius of the emission cylinder (1 by default)
  18071. * @param height the height of the emission cylinder (1 by default)
  18072. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18073. * @param direction1 the min limit of the emission direction (up vector by default)
  18074. * @param direction2 the max limit of the emission direction (up vector by default)
  18075. */
  18076. constructor(radius?: number, height?: number, radiusRange?: number,
  18077. /**
  18078. * The min limit of the emission direction.
  18079. */
  18080. direction1?: Vector3,
  18081. /**
  18082. * The max limit of the emission direction.
  18083. */
  18084. direction2?: Vector3);
  18085. /**
  18086. * Called by the particle System when the direction is computed for the created particle.
  18087. * @param worldMatrix is the world matrix of the particle system
  18088. * @param directionToUpdate is the direction vector to update with the result
  18089. * @param particle is the particle we are computed the direction for
  18090. */
  18091. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18092. /**
  18093. * Clones the current emitter and returns a copy of it
  18094. * @returns the new emitter
  18095. */
  18096. clone(): CylinderDirectedParticleEmitter;
  18097. /**
  18098. * Called by the GPUParticleSystem to setup the update shader
  18099. * @param effect defines the update shader
  18100. */
  18101. applyToShader(effect: Effect): void;
  18102. /**
  18103. * Returns a string to use to update the GPU particles update shader
  18104. * @returns a string containng the defines string
  18105. */
  18106. getEffectDefines(): string;
  18107. /**
  18108. * Returns the string "CylinderDirectedParticleEmitter"
  18109. * @returns a string containing the class name
  18110. */
  18111. getClassName(): string;
  18112. /**
  18113. * Serializes the particle system to a JSON object.
  18114. * @returns the JSON object
  18115. */
  18116. serialize(): any;
  18117. /**
  18118. * Parse properties from a JSON object
  18119. * @param serializationObject defines the JSON object
  18120. */
  18121. parse(serializationObject: any): void;
  18122. }
  18123. }
  18124. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18125. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18126. import { Effect } from "babylonjs/Materials/effect";
  18127. import { Particle } from "babylonjs/Particles/particle";
  18128. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18129. /**
  18130. * Particle emitter emitting particles from the inside of a hemisphere.
  18131. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18132. */
  18133. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18134. /**
  18135. * The radius of the emission hemisphere.
  18136. */
  18137. radius: number;
  18138. /**
  18139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18140. */
  18141. radiusRange: number;
  18142. /**
  18143. * How much to randomize the particle direction [0-1].
  18144. */
  18145. directionRandomizer: number;
  18146. /**
  18147. * Creates a new instance HemisphericParticleEmitter
  18148. * @param radius the radius of the emission hemisphere (1 by default)
  18149. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18150. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18151. */
  18152. constructor(
  18153. /**
  18154. * The radius of the emission hemisphere.
  18155. */
  18156. radius?: number,
  18157. /**
  18158. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18159. */
  18160. radiusRange?: number,
  18161. /**
  18162. * How much to randomize the particle direction [0-1].
  18163. */
  18164. directionRandomizer?: number);
  18165. /**
  18166. * Called by the particle System when the direction is computed for the created particle.
  18167. * @param worldMatrix is the world matrix of the particle system
  18168. * @param directionToUpdate is the direction vector to update with the result
  18169. * @param particle is the particle we are computed the direction for
  18170. */
  18171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18172. /**
  18173. * Called by the particle System when the position is computed for the created particle.
  18174. * @param worldMatrix is the world matrix of the particle system
  18175. * @param positionToUpdate is the position vector to update with the result
  18176. * @param particle is the particle we are computed the position for
  18177. */
  18178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18179. /**
  18180. * Clones the current emitter and returns a copy of it
  18181. * @returns the new emitter
  18182. */
  18183. clone(): HemisphericParticleEmitter;
  18184. /**
  18185. * Called by the GPUParticleSystem to setup the update shader
  18186. * @param effect defines the update shader
  18187. */
  18188. applyToShader(effect: Effect): void;
  18189. /**
  18190. * Returns a string to use to update the GPU particles update shader
  18191. * @returns a string containng the defines string
  18192. */
  18193. getEffectDefines(): string;
  18194. /**
  18195. * Returns the string "HemisphericParticleEmitter"
  18196. * @returns a string containing the class name
  18197. */
  18198. getClassName(): string;
  18199. /**
  18200. * Serializes the particle system to a JSON object.
  18201. * @returns the JSON object
  18202. */
  18203. serialize(): any;
  18204. /**
  18205. * Parse properties from a JSON object
  18206. * @param serializationObject defines the JSON object
  18207. */
  18208. parse(serializationObject: any): void;
  18209. }
  18210. }
  18211. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18213. import { Effect } from "babylonjs/Materials/effect";
  18214. import { Particle } from "babylonjs/Particles/particle";
  18215. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18216. /**
  18217. * Particle emitter emitting particles from a point.
  18218. * It emits the particles randomly between 2 given directions.
  18219. */
  18220. export class PointParticleEmitter implements IParticleEmitterType {
  18221. /**
  18222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18223. */
  18224. direction1: Vector3;
  18225. /**
  18226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18227. */
  18228. direction2: Vector3;
  18229. /**
  18230. * Creates a new instance PointParticleEmitter
  18231. */
  18232. constructor();
  18233. /**
  18234. * Called by the particle System when the direction is computed for the created particle.
  18235. * @param worldMatrix is the world matrix of the particle system
  18236. * @param directionToUpdate is the direction vector to update with the result
  18237. * @param particle is the particle we are computed the direction for
  18238. */
  18239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18240. /**
  18241. * Called by the particle System when the position is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param positionToUpdate is the position vector to update with the result
  18244. * @param particle is the particle we are computed the position for
  18245. */
  18246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Clones the current emitter and returns a copy of it
  18249. * @returns the new emitter
  18250. */
  18251. clone(): PointParticleEmitter;
  18252. /**
  18253. * Called by the GPUParticleSystem to setup the update shader
  18254. * @param effect defines the update shader
  18255. */
  18256. applyToShader(effect: Effect): void;
  18257. /**
  18258. * Returns a string to use to update the GPU particles update shader
  18259. * @returns a string containng the defines string
  18260. */
  18261. getEffectDefines(): string;
  18262. /**
  18263. * Returns the string "PointParticleEmitter"
  18264. * @returns a string containing the class name
  18265. */
  18266. getClassName(): string;
  18267. /**
  18268. * Serializes the particle system to a JSON object.
  18269. * @returns the JSON object
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Parse properties from a JSON object
  18274. * @param serializationObject defines the JSON object
  18275. */
  18276. parse(serializationObject: any): void;
  18277. }
  18278. }
  18279. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18280. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18281. import { Effect } from "babylonjs/Materials/effect";
  18282. import { Particle } from "babylonjs/Particles/particle";
  18283. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18284. /**
  18285. * Particle emitter emitting particles from the inside of a sphere.
  18286. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18287. */
  18288. export class SphereParticleEmitter implements IParticleEmitterType {
  18289. /**
  18290. * The radius of the emission sphere.
  18291. */
  18292. radius: number;
  18293. /**
  18294. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18295. */
  18296. radiusRange: number;
  18297. /**
  18298. * How much to randomize the particle direction [0-1].
  18299. */
  18300. directionRandomizer: number;
  18301. /**
  18302. * Creates a new instance SphereParticleEmitter
  18303. * @param radius the radius of the emission sphere (1 by default)
  18304. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18305. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18306. */
  18307. constructor(
  18308. /**
  18309. * The radius of the emission sphere.
  18310. */
  18311. radius?: number,
  18312. /**
  18313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18314. */
  18315. radiusRange?: number,
  18316. /**
  18317. * How much to randomize the particle direction [0-1].
  18318. */
  18319. directionRandomizer?: number);
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): SphereParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "SphereParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. /**
  18366. * Particle emitter emitting particles from the inside of a sphere.
  18367. * It emits the particles randomly between two vectors.
  18368. */
  18369. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18370. /**
  18371. * The min limit of the emission direction.
  18372. */
  18373. direction1: Vector3;
  18374. /**
  18375. * The max limit of the emission direction.
  18376. */
  18377. direction2: Vector3;
  18378. /**
  18379. * Creates a new instance SphereDirectedParticleEmitter
  18380. * @param radius the radius of the emission sphere (1 by default)
  18381. * @param direction1 the min limit of the emission direction (up vector by default)
  18382. * @param direction2 the max limit of the emission direction (up vector by default)
  18383. */
  18384. constructor(radius?: number,
  18385. /**
  18386. * The min limit of the emission direction.
  18387. */
  18388. direction1?: Vector3,
  18389. /**
  18390. * The max limit of the emission direction.
  18391. */
  18392. direction2?: Vector3);
  18393. /**
  18394. * Called by the particle System when the direction is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param directionToUpdate is the direction vector to update with the result
  18397. * @param particle is the particle we are computed the direction for
  18398. */
  18399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): SphereDirectedParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "SphereDirectedParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/index" {
  18433. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18434. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18435. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18436. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18437. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18438. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18439. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18440. }
  18441. declare module "babylonjs/Particles/IParticleSystem" {
  18442. import { Nullable } from "babylonjs/types";
  18443. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18444. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18447. import { Texture } from "babylonjs/Materials/Textures/texture";
  18448. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18449. import { Scene } from "babylonjs/scene";
  18450. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18451. import { Animation } from "babylonjs/Animations/animation";
  18452. /**
  18453. * Interface representing a particle system in Babylon.js.
  18454. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18455. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18456. */
  18457. export interface IParticleSystem {
  18458. /**
  18459. * List of animations used by the particle system.
  18460. */
  18461. animations: Animation[];
  18462. /**
  18463. * The id of the Particle system.
  18464. */
  18465. id: string;
  18466. /**
  18467. * The name of the Particle system.
  18468. */
  18469. name: string;
  18470. /**
  18471. * The emitter represents the Mesh or position we are attaching the particle system to.
  18472. */
  18473. emitter: Nullable<AbstractMesh | Vector3>;
  18474. /**
  18475. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18476. */
  18477. isBillboardBased: boolean;
  18478. /**
  18479. * The rendering group used by the Particle system to chose when to render.
  18480. */
  18481. renderingGroupId: number;
  18482. /**
  18483. * The layer mask we are rendering the particles through.
  18484. */
  18485. layerMask: number;
  18486. /**
  18487. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18488. */
  18489. updateSpeed: number;
  18490. /**
  18491. * The amount of time the particle system is running (depends of the overall update speed).
  18492. */
  18493. targetStopDuration: number;
  18494. /**
  18495. * The texture used to render each particle. (this can be a spritesheet)
  18496. */
  18497. particleTexture: Nullable<Texture>;
  18498. /**
  18499. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18500. */
  18501. blendMode: number;
  18502. /**
  18503. * Minimum life time of emitting particles.
  18504. */
  18505. minLifeTime: number;
  18506. /**
  18507. * Maximum life time of emitting particles.
  18508. */
  18509. maxLifeTime: number;
  18510. /**
  18511. * Minimum Size of emitting particles.
  18512. */
  18513. minSize: number;
  18514. /**
  18515. * Maximum Size of emitting particles.
  18516. */
  18517. maxSize: number;
  18518. /**
  18519. * Minimum scale of emitting particles on X axis.
  18520. */
  18521. minScaleX: number;
  18522. /**
  18523. * Maximum scale of emitting particles on X axis.
  18524. */
  18525. maxScaleX: number;
  18526. /**
  18527. * Minimum scale of emitting particles on Y axis.
  18528. */
  18529. minScaleY: number;
  18530. /**
  18531. * Maximum scale of emitting particles on Y axis.
  18532. */
  18533. maxScaleY: number;
  18534. /**
  18535. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18536. */
  18537. color1: Color4;
  18538. /**
  18539. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18540. */
  18541. color2: Color4;
  18542. /**
  18543. * Color the particle will have at the end of its lifetime.
  18544. */
  18545. colorDead: Color4;
  18546. /**
  18547. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18548. */
  18549. emitRate: number;
  18550. /**
  18551. * You can use gravity if you want to give an orientation to your particles.
  18552. */
  18553. gravity: Vector3;
  18554. /**
  18555. * Minimum power of emitting particles.
  18556. */
  18557. minEmitPower: number;
  18558. /**
  18559. * Maximum power of emitting particles.
  18560. */
  18561. maxEmitPower: number;
  18562. /**
  18563. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18564. */
  18565. minAngularSpeed: number;
  18566. /**
  18567. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18568. */
  18569. maxAngularSpeed: number;
  18570. /**
  18571. * Gets or sets the minimal initial rotation in radians.
  18572. */
  18573. minInitialRotation: number;
  18574. /**
  18575. * Gets or sets the maximal initial rotation in radians.
  18576. */
  18577. maxInitialRotation: number;
  18578. /**
  18579. * The particle emitter type defines the emitter used by the particle system.
  18580. * It can be for example box, sphere, or cone...
  18581. */
  18582. particleEmitterType: Nullable<IParticleEmitterType>;
  18583. /**
  18584. * Defines the delay in milliseconds before starting the system (0 by default)
  18585. */
  18586. startDelay: number;
  18587. /**
  18588. * 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
  18589. */
  18590. preWarmCycles: number;
  18591. /**
  18592. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18593. */
  18594. preWarmStepOffset: number;
  18595. /**
  18596. * 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)
  18597. */
  18598. spriteCellChangeSpeed: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18601. */
  18602. startSpriteCellID: number;
  18603. /**
  18604. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18605. */
  18606. endSpriteCellID: number;
  18607. /**
  18608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18609. */
  18610. spriteCellWidth: number;
  18611. /**
  18612. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18613. */
  18614. spriteCellHeight: number;
  18615. /**
  18616. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18617. */
  18618. spriteRandomStartCell: boolean;
  18619. /**
  18620. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18621. */
  18622. isAnimationSheetEnabled: boolean;
  18623. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18624. translationPivot: Vector2;
  18625. /**
  18626. * Gets or sets a texture used to add random noise to particle positions
  18627. */
  18628. noiseTexture: Nullable<BaseTexture>;
  18629. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18630. noiseStrength: Vector3;
  18631. /**
  18632. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18633. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18634. */
  18635. billboardMode: number;
  18636. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18637. limitVelocityDamping: number;
  18638. /**
  18639. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18640. */
  18641. beginAnimationOnStart: boolean;
  18642. /**
  18643. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18644. */
  18645. beginAnimationFrom: number;
  18646. /**
  18647. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18648. */
  18649. beginAnimationTo: number;
  18650. /**
  18651. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18652. */
  18653. beginAnimationLoop: boolean;
  18654. /**
  18655. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18656. */
  18657. disposeOnStop: boolean;
  18658. /**
  18659. * Gets the maximum number of particles active at the same time.
  18660. * @returns The max number of active particles.
  18661. */
  18662. getCapacity(): number;
  18663. /**
  18664. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18665. * @returns True if it has been started, otherwise false.
  18666. */
  18667. isStarted(): boolean;
  18668. /**
  18669. * Animates the particle system for this frame.
  18670. */
  18671. animate(): void;
  18672. /**
  18673. * Renders the particle system in its current state.
  18674. * @returns the current number of particles
  18675. */
  18676. render(): number;
  18677. /**
  18678. * Dispose the particle system and frees its associated resources.
  18679. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18680. */
  18681. dispose(disposeTexture?: boolean): void;
  18682. /**
  18683. * Clones the particle system.
  18684. * @param name The name of the cloned object
  18685. * @param newEmitter The new emitter to use
  18686. * @returns the cloned particle system
  18687. */
  18688. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18689. /**
  18690. * Serializes the particle system to a JSON object.
  18691. * @returns the JSON object
  18692. */
  18693. serialize(): any;
  18694. /**
  18695. * Rebuild the particle system
  18696. */
  18697. rebuild(): void;
  18698. /**
  18699. * Starts the particle system and begins to emit
  18700. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18701. */
  18702. start(delay?: number): void;
  18703. /**
  18704. * Stops the particle system.
  18705. */
  18706. stop(): void;
  18707. /**
  18708. * Remove all active particles
  18709. */
  18710. reset(): void;
  18711. /**
  18712. * Is this system ready to be used/rendered
  18713. * @return true if the system is ready
  18714. */
  18715. isReady(): boolean;
  18716. /**
  18717. * Adds a new color gradient
  18718. * @param gradient defines the gradient to use (between 0 and 1)
  18719. * @param color1 defines the color to affect to the specified gradient
  18720. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18721. * @returns the current particle system
  18722. */
  18723. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18724. /**
  18725. * Remove a specific color gradient
  18726. * @param gradient defines the gradient to remove
  18727. * @returns the current particle system
  18728. */
  18729. removeColorGradient(gradient: number): IParticleSystem;
  18730. /**
  18731. * Adds a new size gradient
  18732. * @param gradient defines the gradient to use (between 0 and 1)
  18733. * @param factor defines the size factor to affect to the specified gradient
  18734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18735. * @returns the current particle system
  18736. */
  18737. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18738. /**
  18739. * Remove a specific size gradient
  18740. * @param gradient defines the gradient to remove
  18741. * @returns the current particle system
  18742. */
  18743. removeSizeGradient(gradient: number): IParticleSystem;
  18744. /**
  18745. * Gets the current list of color gradients.
  18746. * You must use addColorGradient and removeColorGradient to udpate this list
  18747. * @returns the list of color gradients
  18748. */
  18749. getColorGradients(): Nullable<Array<ColorGradient>>;
  18750. /**
  18751. * Gets the current list of size gradients.
  18752. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18753. * @returns the list of size gradients
  18754. */
  18755. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18756. /**
  18757. * Gets the current list of angular speed gradients.
  18758. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18759. * @returns the list of angular speed gradients
  18760. */
  18761. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new angular speed gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific angular speed gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of velocity gradients.
  18778. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18779. * @returns the list of velocity gradients
  18780. */
  18781. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Gets the current list of limit velocity gradients.
  18798. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18799. * @returns the list of limit velocity gradients
  18800. */
  18801. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18802. /**
  18803. * Adds a new limit velocity gradient
  18804. * @param gradient defines the gradient to use (between 0 and 1)
  18805. * @param factor defines the limit velocity to affect to the specified gradient
  18806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18807. * @returns the current particle system
  18808. */
  18809. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18810. /**
  18811. * Remove a specific limit velocity gradient
  18812. * @param gradient defines the gradient to remove
  18813. * @returns the current particle system
  18814. */
  18815. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18816. /**
  18817. * Adds a new drag gradient
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific drag gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeDragGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of drag gradients.
  18832. * You must use addDragGradient and removeDragGradient to udpate this list
  18833. * @returns the list of drag gradients
  18834. */
  18835. getDragGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new emit rate 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 emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific emit rate gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeEmitRateGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of emit rate gradients.
  18852. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18853. * @returns the list of emit rate gradients
  18854. */
  18855. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific start size gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeStartSizeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of start size gradients.
  18872. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18873. * @returns the list of start size gradients
  18874. */
  18875. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Adds a new life time gradient
  18878. * @param gradient defines the gradient to use (between 0 and 1)
  18879. * @param factor defines the life time factor to affect to the specified gradient
  18880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18881. * @returns the current particle system
  18882. */
  18883. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18884. /**
  18885. * Remove a specific life time gradient
  18886. * @param gradient defines the gradient to remove
  18887. * @returns the current particle system
  18888. */
  18889. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18890. /**
  18891. * Gets the current list of life time gradients.
  18892. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18893. * @returns the list of life time gradients
  18894. */
  18895. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18896. /**
  18897. * Gets the current list of color gradients.
  18898. * You must use addColorGradient and removeColorGradient to udpate this list
  18899. * @returns the list of color gradients
  18900. */
  18901. getColorGradients(): Nullable<Array<ColorGradient>>;
  18902. /**
  18903. * Adds a new ramp gradient used to remap particle colors
  18904. * @param gradient defines the gradient to use (between 0 and 1)
  18905. * @param color defines the color to affect to the specified gradient
  18906. * @returns the current particle system
  18907. */
  18908. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18909. /**
  18910. * Gets the current list of ramp gradients.
  18911. * You must use addRampGradient and removeRampGradient to udpate this list
  18912. * @returns the list of ramp gradients
  18913. */
  18914. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18915. /** Gets or sets a boolean indicating that ramp gradients must be used
  18916. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18917. */
  18918. useRampGradients: boolean;
  18919. /**
  18920. * Adds a new color remap gradient
  18921. * @param gradient defines the gradient to use (between 0 and 1)
  18922. * @param min defines the color remap minimal range
  18923. * @param max defines the color remap maximal range
  18924. * @returns the current particle system
  18925. */
  18926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18927. /**
  18928. * Gets the current list of color remap gradients.
  18929. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18930. * @returns the list of color remap gradients
  18931. */
  18932. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18933. /**
  18934. * Adds a new alpha remap gradient
  18935. * @param gradient defines the gradient to use (between 0 and 1)
  18936. * @param min defines the alpha remap minimal range
  18937. * @param max defines the alpha remap maximal range
  18938. * @returns the current particle system
  18939. */
  18940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18941. /**
  18942. * Gets the current list of alpha remap gradients.
  18943. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18944. * @returns the list of alpha remap gradients
  18945. */
  18946. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18947. /**
  18948. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18951. * @returns the emitter
  18952. */
  18953. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18954. /**
  18955. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18956. * @param radius The radius of the hemisphere to emit from
  18957. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18958. * @returns the emitter
  18959. */
  18960. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18961. /**
  18962. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18963. * @param radius The radius of the sphere to emit from
  18964. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18965. * @returns the emitter
  18966. */
  18967. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18968. /**
  18969. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18970. * @param radius The radius of the sphere to emit from
  18971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18973. * @returns the emitter
  18974. */
  18975. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18976. /**
  18977. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18978. * @param radius The radius of the emission cylinder
  18979. * @param height The height of the emission cylinder
  18980. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18981. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18982. * @returns the emitter
  18983. */
  18984. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18985. /**
  18986. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18987. * @param radius The radius of the cylinder to emit from
  18988. * @param height The height of the emission cylinder
  18989. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18992. * @returns the emitter
  18993. */
  18994. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18995. /**
  18996. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18997. * @param radius The radius of the cone to emit from
  18998. * @param angle The base angle of the cone
  18999. * @returns the emitter
  19000. */
  19001. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19002. /**
  19003. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19006. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19007. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19008. * @returns the emitter
  19009. */
  19010. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19011. /**
  19012. * Get hosting scene
  19013. * @returns the scene
  19014. */
  19015. getScene(): Scene;
  19016. }
  19017. }
  19018. declare module "babylonjs/Meshes/instancedMesh" {
  19019. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19020. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19021. import { Camera } from "babylonjs/Cameras/camera";
  19022. import { Node } from "babylonjs/node";
  19023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19024. import { Mesh } from "babylonjs/Meshes/mesh";
  19025. import { Material } from "babylonjs/Materials/material";
  19026. import { Skeleton } from "babylonjs/Bones/skeleton";
  19027. import { Light } from "babylonjs/Lights/light";
  19028. /**
  19029. * Creates an instance based on a source mesh.
  19030. */
  19031. export class InstancedMesh extends AbstractMesh {
  19032. private _sourceMesh;
  19033. private _currentLOD;
  19034. /** @hidden */
  19035. _indexInSourceMeshInstanceArray: number;
  19036. constructor(name: string, source: Mesh);
  19037. /**
  19038. * Returns the string "InstancedMesh".
  19039. */
  19040. getClassName(): string;
  19041. /** Gets the list of lights affecting that mesh */
  19042. readonly lightSources: Light[];
  19043. _resyncLightSources(): void;
  19044. _resyncLighSource(light: Light): void;
  19045. _removeLightSource(light: Light): void;
  19046. /**
  19047. * If the source mesh receives shadows
  19048. */
  19049. readonly receiveShadows: boolean;
  19050. /**
  19051. * The material of the source mesh
  19052. */
  19053. readonly material: Nullable<Material>;
  19054. /**
  19055. * Visibility of the source mesh
  19056. */
  19057. readonly visibility: number;
  19058. /**
  19059. * Skeleton of the source mesh
  19060. */
  19061. readonly skeleton: Nullable<Skeleton>;
  19062. /**
  19063. * Rendering ground id of the source mesh
  19064. */
  19065. renderingGroupId: number;
  19066. /**
  19067. * Returns the total number of vertices (integer).
  19068. */
  19069. getTotalVertices(): number;
  19070. /**
  19071. * Returns a positive integer : the total number of indices in this mesh geometry.
  19072. * @returns the numner of indices or zero if the mesh has no geometry.
  19073. */
  19074. getTotalIndices(): number;
  19075. /**
  19076. * The source mesh of the instance
  19077. */
  19078. readonly sourceMesh: Mesh;
  19079. /**
  19080. * Is this node ready to be used/rendered
  19081. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19082. * @return {boolean} is it ready
  19083. */
  19084. isReady(completeCheck?: boolean): boolean;
  19085. /**
  19086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19087. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19088. * @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.
  19089. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19090. */
  19091. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19092. /**
  19093. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19094. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19095. * The `data` are either a numeric array either a Float32Array.
  19096. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19097. * 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).
  19098. * Note that a new underlying VertexBuffer object is created each call.
  19099. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19100. *
  19101. * Possible `kind` values :
  19102. * - VertexBuffer.PositionKind
  19103. * - VertexBuffer.UVKind
  19104. * - VertexBuffer.UV2Kind
  19105. * - VertexBuffer.UV3Kind
  19106. * - VertexBuffer.UV4Kind
  19107. * - VertexBuffer.UV5Kind
  19108. * - VertexBuffer.UV6Kind
  19109. * - VertexBuffer.ColorKind
  19110. * - VertexBuffer.MatricesIndicesKind
  19111. * - VertexBuffer.MatricesIndicesExtraKind
  19112. * - VertexBuffer.MatricesWeightsKind
  19113. * - VertexBuffer.MatricesWeightsExtraKind
  19114. *
  19115. * Returns the Mesh.
  19116. */
  19117. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19118. /**
  19119. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19120. * If the mesh has no geometry, it is simply returned as it is.
  19121. * The `data` are either a numeric array either a Float32Array.
  19122. * No new underlying VertexBuffer object is created.
  19123. * 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.
  19124. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19125. *
  19126. * Possible `kind` values :
  19127. * - VertexBuffer.PositionKind
  19128. * - VertexBuffer.UVKind
  19129. * - VertexBuffer.UV2Kind
  19130. * - VertexBuffer.UV3Kind
  19131. * - VertexBuffer.UV4Kind
  19132. * - VertexBuffer.UV5Kind
  19133. * - VertexBuffer.UV6Kind
  19134. * - VertexBuffer.ColorKind
  19135. * - VertexBuffer.MatricesIndicesKind
  19136. * - VertexBuffer.MatricesIndicesExtraKind
  19137. * - VertexBuffer.MatricesWeightsKind
  19138. * - VertexBuffer.MatricesWeightsExtraKind
  19139. *
  19140. * Returns the Mesh.
  19141. */
  19142. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19143. /**
  19144. * Sets the mesh indices.
  19145. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19146. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19147. * This method creates a new index buffer each call.
  19148. * Returns the Mesh.
  19149. */
  19150. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19151. /**
  19152. * Boolean : True if the mesh owns the requested kind of data.
  19153. */
  19154. isVerticesDataPresent(kind: string): boolean;
  19155. /**
  19156. * Returns an array of indices (IndicesArray).
  19157. */
  19158. getIndices(): Nullable<IndicesArray>;
  19159. readonly _positions: Nullable<Vector3[]>;
  19160. /**
  19161. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19162. * This means the mesh underlying bounding box and sphere are recomputed.
  19163. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19164. * @returns the current mesh
  19165. */
  19166. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19167. /** @hidden */
  19168. _preActivate(): InstancedMesh;
  19169. /** @hidden */
  19170. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19171. /** @hidden */
  19172. _postActivate(): void;
  19173. getWorldMatrix(): Matrix;
  19174. readonly isAnInstance: boolean;
  19175. /**
  19176. * Returns the current associated LOD AbstractMesh.
  19177. */
  19178. getLOD(camera: Camera): AbstractMesh;
  19179. /** @hidden */
  19180. _syncSubMeshes(): InstancedMesh;
  19181. /** @hidden */
  19182. _generatePointsArray(): boolean;
  19183. /**
  19184. * Creates a new InstancedMesh from the current mesh.
  19185. * - name (string) : the cloned mesh name
  19186. * - newParent (optional Node) : the optional Node to parent the clone to.
  19187. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19188. *
  19189. * Returns the clone.
  19190. */
  19191. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19192. /**
  19193. * Disposes the InstancedMesh.
  19194. * Returns nothing.
  19195. */
  19196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19197. }
  19198. }
  19199. declare module "babylonjs/Materials/shaderMaterial" {
  19200. import { Scene } from "babylonjs/scene";
  19201. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19203. import { Mesh } from "babylonjs/Meshes/mesh";
  19204. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19206. import { Texture } from "babylonjs/Materials/Textures/texture";
  19207. import { Material } from "babylonjs/Materials/material";
  19208. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19209. /**
  19210. * Defines the options associated with the creation of a shader material.
  19211. */
  19212. export interface IShaderMaterialOptions {
  19213. /**
  19214. * Does the material work in alpha blend mode
  19215. */
  19216. needAlphaBlending: boolean;
  19217. /**
  19218. * Does the material work in alpha test mode
  19219. */
  19220. needAlphaTesting: boolean;
  19221. /**
  19222. * The list of attribute names used in the shader
  19223. */
  19224. attributes: string[];
  19225. /**
  19226. * The list of unifrom names used in the shader
  19227. */
  19228. uniforms: string[];
  19229. /**
  19230. * The list of UBO names used in the shader
  19231. */
  19232. uniformBuffers: string[];
  19233. /**
  19234. * The list of sampler names used in the shader
  19235. */
  19236. samplers: string[];
  19237. /**
  19238. * The list of defines used in the shader
  19239. */
  19240. defines: string[];
  19241. }
  19242. /**
  19243. * 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.
  19244. *
  19245. * This returned material effects how the mesh will look based on the code in the shaders.
  19246. *
  19247. * @see http://doc.babylonjs.com/how_to/shader_material
  19248. */
  19249. export class ShaderMaterial extends Material {
  19250. private _shaderPath;
  19251. private _options;
  19252. private _textures;
  19253. private _textureArrays;
  19254. private _floats;
  19255. private _ints;
  19256. private _floatsArrays;
  19257. private _colors3;
  19258. private _colors3Arrays;
  19259. private _colors4;
  19260. private _colors4Arrays;
  19261. private _vectors2;
  19262. private _vectors3;
  19263. private _vectors4;
  19264. private _matrices;
  19265. private _matrices3x3;
  19266. private _matrices2x2;
  19267. private _vectors2Arrays;
  19268. private _vectors3Arrays;
  19269. private _vectors4Arrays;
  19270. private _cachedWorldViewMatrix;
  19271. private _cachedWorldViewProjectionMatrix;
  19272. private _renderId;
  19273. /**
  19274. * Instantiate a new shader material.
  19275. * 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.
  19276. * This returned material effects how the mesh will look based on the code in the shaders.
  19277. * @see http://doc.babylonjs.com/how_to/shader_material
  19278. * @param name Define the name of the material in the scene
  19279. * @param scene Define the scene the material belongs to
  19280. * @param shaderPath Defines the route to the shader code in one of three ways:
  19281. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19282. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19283. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19284. * @param options Define the options used to create the shader
  19285. */
  19286. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19287. /**
  19288. * Gets the options used to compile the shader.
  19289. * They can be modified to trigger a new compilation
  19290. */
  19291. readonly options: IShaderMaterialOptions;
  19292. /**
  19293. * Gets the current class name of the material e.g. "ShaderMaterial"
  19294. * Mainly use in serialization.
  19295. * @returns the class name
  19296. */
  19297. getClassName(): string;
  19298. /**
  19299. * Specifies if the material will require alpha blending
  19300. * @returns a boolean specifying if alpha blending is needed
  19301. */
  19302. needAlphaBlending(): boolean;
  19303. /**
  19304. * Specifies if this material should be rendered in alpha test mode
  19305. * @returns a boolean specifying if an alpha test is needed.
  19306. */
  19307. needAlphaTesting(): boolean;
  19308. private _checkUniform;
  19309. /**
  19310. * Set a texture in the shader.
  19311. * @param name Define the name of the uniform samplers as defined in the shader
  19312. * @param texture Define the texture to bind to this sampler
  19313. * @return the material itself allowing "fluent" like uniform updates
  19314. */
  19315. setTexture(name: string, texture: Texture): ShaderMaterial;
  19316. /**
  19317. * Set a texture array in the shader.
  19318. * @param name Define the name of the uniform sampler array as defined in the shader
  19319. * @param textures Define the list of textures to bind to this sampler
  19320. * @return the material itself allowing "fluent" like uniform updates
  19321. */
  19322. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19323. /**
  19324. * Set a float in the shader.
  19325. * @param name Define the name of the uniform as defined in the shader
  19326. * @param value Define the value to give to the uniform
  19327. * @return the material itself allowing "fluent" like uniform updates
  19328. */
  19329. setFloat(name: string, value: number): ShaderMaterial;
  19330. /**
  19331. * Set a int in the shader.
  19332. * @param name Define the name of the uniform as defined in the shader
  19333. * @param value Define the value to give to the uniform
  19334. * @return the material itself allowing "fluent" like uniform updates
  19335. */
  19336. setInt(name: string, value: number): ShaderMaterial;
  19337. /**
  19338. * Set an array of floats in the shader.
  19339. * @param name Define the name of the uniform as defined in the shader
  19340. * @param value Define the value to give to the uniform
  19341. * @return the material itself allowing "fluent" like uniform updates
  19342. */
  19343. setFloats(name: string, value: number[]): ShaderMaterial;
  19344. /**
  19345. * Set a vec3 in the shader from a Color3.
  19346. * @param name Define the name of the uniform as defined in the shader
  19347. * @param value Define the value to give to the uniform
  19348. * @return the material itself allowing "fluent" like uniform updates
  19349. */
  19350. setColor3(name: string, value: Color3): ShaderMaterial;
  19351. /**
  19352. * Set a vec3 array in the shader from a Color3 array.
  19353. * @param name Define the name of the uniform as defined in the shader
  19354. * @param value Define the value to give to the uniform
  19355. * @return the material itself allowing "fluent" like uniform updates
  19356. */
  19357. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19358. /**
  19359. * Set a vec4 in the shader from a Color4.
  19360. * @param name Define the name of the uniform as defined in the shader
  19361. * @param value Define the value to give to the uniform
  19362. * @return the material itself allowing "fluent" like uniform updates
  19363. */
  19364. setColor4(name: string, value: Color4): ShaderMaterial;
  19365. /**
  19366. * Set a vec4 array in the shader from a Color4 array.
  19367. * @param name Define the name of the uniform as defined in the shader
  19368. * @param value Define the value to give to the uniform
  19369. * @return the material itself allowing "fluent" like uniform updates
  19370. */
  19371. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19372. /**
  19373. * Set a vec2 in the shader from a Vector2.
  19374. * @param name Define the name of the uniform as defined in the shader
  19375. * @param value Define the value to give to the uniform
  19376. * @return the material itself allowing "fluent" like uniform updates
  19377. */
  19378. setVector2(name: string, value: Vector2): ShaderMaterial;
  19379. /**
  19380. * Set a vec3 in the shader from a Vector3.
  19381. * @param name Define the name of the uniform as defined in the shader
  19382. * @param value Define the value to give to the uniform
  19383. * @return the material itself allowing "fluent" like uniform updates
  19384. */
  19385. setVector3(name: string, value: Vector3): ShaderMaterial;
  19386. /**
  19387. * Set a vec4 in the shader from a Vector4.
  19388. * @param name Define the name of the uniform as defined in the shader
  19389. * @param value Define the value to give to the uniform
  19390. * @return the material itself allowing "fluent" like uniform updates
  19391. */
  19392. setVector4(name: string, value: Vector4): ShaderMaterial;
  19393. /**
  19394. * Set a mat4 in the shader from a Matrix.
  19395. * @param name Define the name of the uniform as defined in the shader
  19396. * @param value Define the value to give to the uniform
  19397. * @return the material itself allowing "fluent" like uniform updates
  19398. */
  19399. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19400. /**
  19401. * Set a mat3 in the shader from a Float32Array.
  19402. * @param name Define the name of the uniform as defined in the shader
  19403. * @param value Define the value to give to the uniform
  19404. * @return the material itself allowing "fluent" like uniform updates
  19405. */
  19406. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19407. /**
  19408. * Set a mat2 in the shader from a Float32Array.
  19409. * @param name Define the name of the uniform as defined in the shader
  19410. * @param value Define the value to give to the uniform
  19411. * @return the material itself allowing "fluent" like uniform updates
  19412. */
  19413. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19414. /**
  19415. * Set a vec2 array in the shader from a number array.
  19416. * @param name Define the name of the uniform as defined in the shader
  19417. * @param value Define the value to give to the uniform
  19418. * @return the material itself allowing "fluent" like uniform updates
  19419. */
  19420. setArray2(name: string, value: number[]): ShaderMaterial;
  19421. /**
  19422. * Set a vec3 array in the shader from a number array.
  19423. * @param name Define the name of the uniform as defined in the shader
  19424. * @param value Define the value to give to the uniform
  19425. * @return the material itself allowing "fluent" like uniform updates
  19426. */
  19427. setArray3(name: string, value: number[]): ShaderMaterial;
  19428. /**
  19429. * Set a vec4 array in the shader from a number array.
  19430. * @param name Define the name of the uniform as defined in the shader
  19431. * @param value Define the value to give to the uniform
  19432. * @return the material itself allowing "fluent" like uniform updates
  19433. */
  19434. setArray4(name: string, value: number[]): ShaderMaterial;
  19435. private _checkCache;
  19436. /**
  19437. * Specifies that the submesh is ready to be used
  19438. * @param mesh defines the mesh to check
  19439. * @param subMesh defines which submesh to check
  19440. * @param useInstances specifies that instances should be used
  19441. * @returns a boolean indicating that the submesh is ready or not
  19442. */
  19443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19444. /**
  19445. * Checks if the material is ready to render the requested mesh
  19446. * @param mesh Define the mesh to render
  19447. * @param useInstances Define whether or not the material is used with instances
  19448. * @returns true if ready, otherwise false
  19449. */
  19450. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19451. /**
  19452. * Binds the world matrix to the material
  19453. * @param world defines the world transformation matrix
  19454. */
  19455. bindOnlyWorldMatrix(world: Matrix): void;
  19456. /**
  19457. * Binds the material to the mesh
  19458. * @param world defines the world transformation matrix
  19459. * @param mesh defines the mesh to bind the material to
  19460. */
  19461. bind(world: Matrix, mesh?: Mesh): void;
  19462. /**
  19463. * Gets the active textures from the material
  19464. * @returns an array of textures
  19465. */
  19466. getActiveTextures(): BaseTexture[];
  19467. /**
  19468. * Specifies if the material uses a texture
  19469. * @param texture defines the texture to check against the material
  19470. * @returns a boolean specifying if the material uses the texture
  19471. */
  19472. hasTexture(texture: BaseTexture): boolean;
  19473. /**
  19474. * Makes a duplicate of the material, and gives it a new name
  19475. * @param name defines the new name for the duplicated material
  19476. * @returns the cloned material
  19477. */
  19478. clone(name: string): ShaderMaterial;
  19479. /**
  19480. * Disposes the material
  19481. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19482. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19483. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19484. */
  19485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19486. /**
  19487. * Serializes this material in a JSON representation
  19488. * @returns the serialized material object
  19489. */
  19490. serialize(): any;
  19491. /**
  19492. * Creates a shader material from parsed shader material data
  19493. * @param source defines the JSON represnetation of the material
  19494. * @param scene defines the hosting scene
  19495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19496. * @returns a new material
  19497. */
  19498. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19499. }
  19500. }
  19501. declare module "babylonjs/Shaders/color.fragment" {
  19502. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19504. /** @hidden */
  19505. export var colorPixelShader: {
  19506. name: string;
  19507. shader: string;
  19508. };
  19509. }
  19510. declare module "babylonjs/Shaders/color.vertex" {
  19511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19516. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19517. /** @hidden */
  19518. export var colorVertexShader: {
  19519. name: string;
  19520. shader: string;
  19521. };
  19522. }
  19523. declare module "babylonjs/Meshes/linesMesh" {
  19524. import { Nullable } from "babylonjs/types";
  19525. import { Scene } from "babylonjs/scene";
  19526. import { Color3 } from "babylonjs/Maths/math.color";
  19527. import { Node } from "babylonjs/node";
  19528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19529. import { Mesh } from "babylonjs/Meshes/mesh";
  19530. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19531. import { Effect } from "babylonjs/Materials/effect";
  19532. import { Material } from "babylonjs/Materials/material";
  19533. import "babylonjs/Shaders/color.fragment";
  19534. import "babylonjs/Shaders/color.vertex";
  19535. /**
  19536. * Line mesh
  19537. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19538. */
  19539. export class LinesMesh extends Mesh {
  19540. /**
  19541. * If vertex color should be applied to the mesh
  19542. */
  19543. readonly useVertexColor?: boolean | undefined;
  19544. /**
  19545. * If vertex alpha should be applied to the mesh
  19546. */
  19547. readonly useVertexAlpha?: boolean | undefined;
  19548. /**
  19549. * Color of the line (Default: White)
  19550. */
  19551. color: Color3;
  19552. /**
  19553. * Alpha of the line (Default: 1)
  19554. */
  19555. alpha: number;
  19556. /**
  19557. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19558. * This margin is expressed in world space coordinates, so its value may vary.
  19559. * Default value is 0.1
  19560. */
  19561. intersectionThreshold: number;
  19562. private _colorShader;
  19563. private color4;
  19564. /**
  19565. * Creates a new LinesMesh
  19566. * @param name defines the name
  19567. * @param scene defines the hosting scene
  19568. * @param parent defines the parent mesh if any
  19569. * @param source defines the optional source LinesMesh used to clone data from
  19570. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19571. * When false, achieved by calling a clone(), also passing False.
  19572. * This will make creation of children, recursive.
  19573. * @param useVertexColor defines if this LinesMesh supports vertex color
  19574. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19575. */
  19576. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19577. /**
  19578. * If vertex color should be applied to the mesh
  19579. */
  19580. useVertexColor?: boolean | undefined,
  19581. /**
  19582. * If vertex alpha should be applied to the mesh
  19583. */
  19584. useVertexAlpha?: boolean | undefined);
  19585. private _addClipPlaneDefine;
  19586. private _removeClipPlaneDefine;
  19587. isReady(): boolean;
  19588. /**
  19589. * Returns the string "LineMesh"
  19590. */
  19591. getClassName(): string;
  19592. /**
  19593. * @hidden
  19594. */
  19595. /**
  19596. * @hidden
  19597. */
  19598. material: Material;
  19599. /**
  19600. * @hidden
  19601. */
  19602. readonly checkCollisions: boolean;
  19603. /** @hidden */
  19604. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19605. /** @hidden */
  19606. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19607. /**
  19608. * Disposes of the line mesh
  19609. * @param doNotRecurse If children should be disposed
  19610. */
  19611. dispose(doNotRecurse?: boolean): void;
  19612. /**
  19613. * Returns a new LineMesh object cloned from the current one.
  19614. */
  19615. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19616. /**
  19617. * Creates a new InstancedLinesMesh object from the mesh model.
  19618. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19619. * @param name defines the name of the new instance
  19620. * @returns a new InstancedLinesMesh
  19621. */
  19622. createInstance(name: string): InstancedLinesMesh;
  19623. }
  19624. /**
  19625. * Creates an instance based on a source LinesMesh
  19626. */
  19627. export class InstancedLinesMesh extends InstancedMesh {
  19628. /**
  19629. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19630. * This margin is expressed in world space coordinates, so its value may vary.
  19631. * Initilized with the intersectionThreshold value of the source LinesMesh
  19632. */
  19633. intersectionThreshold: number;
  19634. constructor(name: string, source: LinesMesh);
  19635. /**
  19636. * Returns the string "InstancedLinesMesh".
  19637. */
  19638. getClassName(): string;
  19639. }
  19640. }
  19641. declare module "babylonjs/Shaders/line.fragment" {
  19642. /** @hidden */
  19643. export var linePixelShader: {
  19644. name: string;
  19645. shader: string;
  19646. };
  19647. }
  19648. declare module "babylonjs/Shaders/line.vertex" {
  19649. /** @hidden */
  19650. export var lineVertexShader: {
  19651. name: string;
  19652. shader: string;
  19653. };
  19654. }
  19655. declare module "babylonjs/Rendering/edgesRenderer" {
  19656. import { Nullable } from "babylonjs/types";
  19657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19659. import { Vector3 } from "babylonjs/Maths/math.vector";
  19660. import { IDisposable } from "babylonjs/scene";
  19661. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19662. import "babylonjs/Shaders/line.fragment";
  19663. import "babylonjs/Shaders/line.vertex";
  19664. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19665. module "babylonjs/Meshes/abstractMesh" {
  19666. interface AbstractMesh {
  19667. /**
  19668. * Gets the edgesRenderer associated with the mesh
  19669. */
  19670. edgesRenderer: Nullable<EdgesRenderer>;
  19671. }
  19672. }
  19673. module "babylonjs/Meshes/linesMesh" {
  19674. interface LinesMesh {
  19675. /**
  19676. * Enables the edge rendering mode on the mesh.
  19677. * This mode makes the mesh edges visible
  19678. * @param epsilon defines the maximal distance between two angles to detect a face
  19679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19680. * @returns the currentAbstractMesh
  19681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19682. */
  19683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19684. }
  19685. }
  19686. module "babylonjs/Meshes/linesMesh" {
  19687. interface InstancedLinesMesh {
  19688. /**
  19689. * Enables the edge rendering mode on the mesh.
  19690. * This mode makes the mesh edges visible
  19691. * @param epsilon defines the maximal distance between two angles to detect a face
  19692. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19693. * @returns the current InstancedLinesMesh
  19694. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19695. */
  19696. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19697. }
  19698. }
  19699. /**
  19700. * Defines the minimum contract an Edges renderer should follow.
  19701. */
  19702. export interface IEdgesRenderer extends IDisposable {
  19703. /**
  19704. * Gets or sets a boolean indicating if the edgesRenderer is active
  19705. */
  19706. isEnabled: boolean;
  19707. /**
  19708. * Renders the edges of the attached mesh,
  19709. */
  19710. render(): void;
  19711. /**
  19712. * Checks wether or not the edges renderer is ready to render.
  19713. * @return true if ready, otherwise false.
  19714. */
  19715. isReady(): boolean;
  19716. }
  19717. /**
  19718. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19719. */
  19720. export class EdgesRenderer implements IEdgesRenderer {
  19721. /**
  19722. * Define the size of the edges with an orthographic camera
  19723. */
  19724. edgesWidthScalerForOrthographic: number;
  19725. /**
  19726. * Define the size of the edges with a perspective camera
  19727. */
  19728. edgesWidthScalerForPerspective: number;
  19729. protected _source: AbstractMesh;
  19730. protected _linesPositions: number[];
  19731. protected _linesNormals: number[];
  19732. protected _linesIndices: number[];
  19733. protected _epsilon: number;
  19734. protected _indicesCount: number;
  19735. protected _lineShader: ShaderMaterial;
  19736. protected _ib: DataBuffer;
  19737. protected _buffers: {
  19738. [key: string]: Nullable<VertexBuffer>;
  19739. };
  19740. protected _checkVerticesInsteadOfIndices: boolean;
  19741. private _meshRebuildObserver;
  19742. private _meshDisposeObserver;
  19743. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19744. isEnabled: boolean;
  19745. /**
  19746. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19747. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19748. * @param source Mesh used to create edges
  19749. * @param epsilon sum of angles in adjacency to check for edge
  19750. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19751. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19752. */
  19753. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19754. protected _prepareRessources(): void;
  19755. /** @hidden */
  19756. _rebuild(): void;
  19757. /**
  19758. * Releases the required resources for the edges renderer
  19759. */
  19760. dispose(): void;
  19761. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19762. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19763. /**
  19764. * Checks if the pair of p0 and p1 is en edge
  19765. * @param faceIndex
  19766. * @param edge
  19767. * @param faceNormals
  19768. * @param p0
  19769. * @param p1
  19770. * @private
  19771. */
  19772. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19773. /**
  19774. * push line into the position, normal and index buffer
  19775. * @protected
  19776. */
  19777. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19778. /**
  19779. * Generates lines edges from adjacencjes
  19780. * @private
  19781. */
  19782. _generateEdgesLines(): void;
  19783. /**
  19784. * Checks wether or not the edges renderer is ready to render.
  19785. * @return true if ready, otherwise false.
  19786. */
  19787. isReady(): boolean;
  19788. /**
  19789. * Renders the edges of the attached mesh,
  19790. */
  19791. render(): void;
  19792. }
  19793. /**
  19794. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19795. */
  19796. export class LineEdgesRenderer extends EdgesRenderer {
  19797. /**
  19798. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19799. * @param source LineMesh used to generate edges
  19800. * @param epsilon not important (specified angle for edge detection)
  19801. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19802. */
  19803. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19804. /**
  19805. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19806. */
  19807. _generateEdgesLines(): void;
  19808. }
  19809. }
  19810. declare module "babylonjs/Rendering/renderingGroup" {
  19811. import { SmartArray } from "babylonjs/Misc/smartArray";
  19812. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Nullable } from "babylonjs/types";
  19815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19816. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19817. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19818. import { Material } from "babylonjs/Materials/material";
  19819. import { Scene } from "babylonjs/scene";
  19820. /**
  19821. * This represents the object necessary to create a rendering group.
  19822. * This is exclusively used and created by the rendering manager.
  19823. * To modify the behavior, you use the available helpers in your scene or meshes.
  19824. * @hidden
  19825. */
  19826. export class RenderingGroup {
  19827. index: number;
  19828. private static _zeroVector;
  19829. private _scene;
  19830. private _opaqueSubMeshes;
  19831. private _transparentSubMeshes;
  19832. private _alphaTestSubMeshes;
  19833. private _depthOnlySubMeshes;
  19834. private _particleSystems;
  19835. private _spriteManagers;
  19836. private _opaqueSortCompareFn;
  19837. private _alphaTestSortCompareFn;
  19838. private _transparentSortCompareFn;
  19839. private _renderOpaque;
  19840. private _renderAlphaTest;
  19841. private _renderTransparent;
  19842. /** @hidden */
  19843. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19844. onBeforeTransparentRendering: () => void;
  19845. /**
  19846. * Set the opaque sort comparison function.
  19847. * If null the sub meshes will be render in the order they were created
  19848. */
  19849. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19850. /**
  19851. * Set the alpha test sort comparison function.
  19852. * If null the sub meshes will be render in the order they were created
  19853. */
  19854. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19855. /**
  19856. * Set the transparent sort comparison function.
  19857. * If null the sub meshes will be render in the order they were created
  19858. */
  19859. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19860. /**
  19861. * Creates a new rendering group.
  19862. * @param index The rendering group index
  19863. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19864. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19865. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19866. */
  19867. 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>);
  19868. /**
  19869. * Render all the sub meshes contained in the group.
  19870. * @param customRenderFunction Used to override the default render behaviour of the group.
  19871. * @returns true if rendered some submeshes.
  19872. */
  19873. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19874. /**
  19875. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19876. * @param subMeshes The submeshes to render
  19877. */
  19878. private renderOpaqueSorted;
  19879. /**
  19880. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19881. * @param subMeshes The submeshes to render
  19882. */
  19883. private renderAlphaTestSorted;
  19884. /**
  19885. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19886. * @param subMeshes The submeshes to render
  19887. */
  19888. private renderTransparentSorted;
  19889. /**
  19890. * Renders the submeshes in a specified order.
  19891. * @param subMeshes The submeshes to sort before render
  19892. * @param sortCompareFn The comparison function use to sort
  19893. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19894. * @param transparent Specifies to activate blending if true
  19895. */
  19896. private static renderSorted;
  19897. /**
  19898. * Renders the submeshes in the order they were dispatched (no sort applied).
  19899. * @param subMeshes The submeshes to render
  19900. */
  19901. private static renderUnsorted;
  19902. /**
  19903. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19904. * are rendered back to front if in the same alpha index.
  19905. *
  19906. * @param a The first submesh
  19907. * @param b The second submesh
  19908. * @returns The result of the comparison
  19909. */
  19910. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19911. /**
  19912. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19913. * are rendered back to front.
  19914. *
  19915. * @param a The first submesh
  19916. * @param b The second submesh
  19917. * @returns The result of the comparison
  19918. */
  19919. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19920. /**
  19921. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19922. * are rendered front to back (prevent overdraw).
  19923. *
  19924. * @param a The first submesh
  19925. * @param b The second submesh
  19926. * @returns The result of the comparison
  19927. */
  19928. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19929. /**
  19930. * Resets the different lists of submeshes to prepare a new frame.
  19931. */
  19932. prepare(): void;
  19933. dispose(): void;
  19934. /**
  19935. * Inserts the submesh in its correct queue depending on its material.
  19936. * @param subMesh The submesh to dispatch
  19937. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19938. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19939. */
  19940. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19941. dispatchSprites(spriteManager: ISpriteManager): void;
  19942. dispatchParticles(particleSystem: IParticleSystem): void;
  19943. private _renderParticles;
  19944. private _renderSprites;
  19945. }
  19946. }
  19947. declare module "babylonjs/Rendering/renderingManager" {
  19948. import { Nullable } from "babylonjs/types";
  19949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19951. import { SmartArray } from "babylonjs/Misc/smartArray";
  19952. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19953. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19954. import { Material } from "babylonjs/Materials/material";
  19955. import { Scene } from "babylonjs/scene";
  19956. import { Camera } from "babylonjs/Cameras/camera";
  19957. /**
  19958. * Interface describing the different options available in the rendering manager
  19959. * regarding Auto Clear between groups.
  19960. */
  19961. export interface IRenderingManagerAutoClearSetup {
  19962. /**
  19963. * Defines whether or not autoclear is enable.
  19964. */
  19965. autoClear: boolean;
  19966. /**
  19967. * Defines whether or not to autoclear the depth buffer.
  19968. */
  19969. depth: boolean;
  19970. /**
  19971. * Defines whether or not to autoclear the stencil buffer.
  19972. */
  19973. stencil: boolean;
  19974. }
  19975. /**
  19976. * This class is used by the onRenderingGroupObservable
  19977. */
  19978. export class RenderingGroupInfo {
  19979. /**
  19980. * The Scene that being rendered
  19981. */
  19982. scene: Scene;
  19983. /**
  19984. * The camera currently used for the rendering pass
  19985. */
  19986. camera: Nullable<Camera>;
  19987. /**
  19988. * The ID of the renderingGroup being processed
  19989. */
  19990. renderingGroupId: number;
  19991. }
  19992. /**
  19993. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19994. * It is enable to manage the different groups as well as the different necessary sort functions.
  19995. * This should not be used directly aside of the few static configurations
  19996. */
  19997. export class RenderingManager {
  19998. /**
  19999. * The max id used for rendering groups (not included)
  20000. */
  20001. static MAX_RENDERINGGROUPS: number;
  20002. /**
  20003. * The min id used for rendering groups (included)
  20004. */
  20005. static MIN_RENDERINGGROUPS: number;
  20006. /**
  20007. * Used to globally prevent autoclearing scenes.
  20008. */
  20009. static AUTOCLEAR: boolean;
  20010. /**
  20011. * @hidden
  20012. */
  20013. _useSceneAutoClearSetup: boolean;
  20014. private _scene;
  20015. private _renderingGroups;
  20016. private _depthStencilBufferAlreadyCleaned;
  20017. private _autoClearDepthStencil;
  20018. private _customOpaqueSortCompareFn;
  20019. private _customAlphaTestSortCompareFn;
  20020. private _customTransparentSortCompareFn;
  20021. private _renderingGroupInfo;
  20022. /**
  20023. * Instantiates a new rendering group for a particular scene
  20024. * @param scene Defines the scene the groups belongs to
  20025. */
  20026. constructor(scene: Scene);
  20027. private _clearDepthStencilBuffer;
  20028. /**
  20029. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20030. * @hidden
  20031. */
  20032. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20033. /**
  20034. * Resets the different information of the group to prepare a new frame
  20035. * @hidden
  20036. */
  20037. reset(): void;
  20038. /**
  20039. * Dispose and release the group and its associated resources.
  20040. * @hidden
  20041. */
  20042. dispose(): void;
  20043. /**
  20044. * Clear the info related to rendering groups preventing retention points during dispose.
  20045. */
  20046. freeRenderingGroups(): void;
  20047. private _prepareRenderingGroup;
  20048. /**
  20049. * Add a sprite manager to the rendering manager in order to render it this frame.
  20050. * @param spriteManager Define the sprite manager to render
  20051. */
  20052. dispatchSprites(spriteManager: ISpriteManager): void;
  20053. /**
  20054. * Add a particle system to the rendering manager in order to render it this frame.
  20055. * @param particleSystem Define the particle system to render
  20056. */
  20057. dispatchParticles(particleSystem: IParticleSystem): void;
  20058. /**
  20059. * Add a submesh to the manager in order to render it this frame
  20060. * @param subMesh The submesh to dispatch
  20061. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20062. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20063. */
  20064. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20065. /**
  20066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20067. * This allowed control for front to back rendering or reversly depending of the special needs.
  20068. *
  20069. * @param renderingGroupId The rendering group id corresponding to its index
  20070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20073. */
  20074. 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;
  20075. /**
  20076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20077. *
  20078. * @param renderingGroupId The rendering group id corresponding to its index
  20079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20080. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20081. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20082. */
  20083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20084. /**
  20085. * Gets the current auto clear configuration for one rendering group of the rendering
  20086. * manager.
  20087. * @param index the rendering group index to get the information for
  20088. * @returns The auto clear setup for the requested rendering group
  20089. */
  20090. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20091. }
  20092. }
  20093. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20094. import { Observable } from "babylonjs/Misc/observable";
  20095. import { SmartArray } from "babylonjs/Misc/smartArray";
  20096. import { Nullable } from "babylonjs/types";
  20097. import { Camera } from "babylonjs/Cameras/camera";
  20098. import { Scene } from "babylonjs/scene";
  20099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20100. import { Color4 } from "babylonjs/Maths/math.color";
  20101. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20104. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20105. import { Texture } from "babylonjs/Materials/Textures/texture";
  20106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20107. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20108. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20109. import { Engine } from "babylonjs/Engines/engine";
  20110. /**
  20111. * This Helps creating a texture that will be created from a camera in your scene.
  20112. * It is basically a dynamic texture that could be used to create special effects for instance.
  20113. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20114. */
  20115. export class RenderTargetTexture extends Texture {
  20116. isCube: boolean;
  20117. /**
  20118. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20119. */
  20120. static readonly REFRESHRATE_RENDER_ONCE: number;
  20121. /**
  20122. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20123. */
  20124. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20125. /**
  20126. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20127. * the central point of your effect and can save a lot of performances.
  20128. */
  20129. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20130. /**
  20131. * Use this predicate to dynamically define the list of mesh you want to render.
  20132. * If set, the renderList property will be overwritten.
  20133. */
  20134. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20135. private _renderList;
  20136. /**
  20137. * Use this list to define the list of mesh you want to render.
  20138. */
  20139. renderList: Nullable<Array<AbstractMesh>>;
  20140. private _hookArray;
  20141. /**
  20142. * Define if particles should be rendered in your texture.
  20143. */
  20144. renderParticles: boolean;
  20145. /**
  20146. * Define if sprites should be rendered in your texture.
  20147. */
  20148. renderSprites: boolean;
  20149. /**
  20150. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20151. */
  20152. coordinatesMode: number;
  20153. /**
  20154. * Define the camera used to render the texture.
  20155. */
  20156. activeCamera: Nullable<Camera>;
  20157. /**
  20158. * Override the render function of the texture with your own one.
  20159. */
  20160. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20161. /**
  20162. * Define if camera post processes should be use while rendering the texture.
  20163. */
  20164. useCameraPostProcesses: boolean;
  20165. /**
  20166. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20167. */
  20168. ignoreCameraViewport: boolean;
  20169. private _postProcessManager;
  20170. private _postProcesses;
  20171. private _resizeObserver;
  20172. /**
  20173. * An event triggered when the texture is unbind.
  20174. */
  20175. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20176. /**
  20177. * An event triggered when the texture is unbind.
  20178. */
  20179. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20180. private _onAfterUnbindObserver;
  20181. /**
  20182. * Set a after unbind callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20184. */
  20185. onAfterUnbind: () => void;
  20186. /**
  20187. * An event triggered before rendering the texture
  20188. */
  20189. onBeforeRenderObservable: Observable<number>;
  20190. private _onBeforeRenderObserver;
  20191. /**
  20192. * Set a before render callback in the texture.
  20193. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20194. */
  20195. onBeforeRender: (faceIndex: number) => void;
  20196. /**
  20197. * An event triggered after rendering the texture
  20198. */
  20199. onAfterRenderObservable: Observable<number>;
  20200. private _onAfterRenderObserver;
  20201. /**
  20202. * Set a after render callback in the texture.
  20203. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20204. */
  20205. onAfterRender: (faceIndex: number) => void;
  20206. /**
  20207. * An event triggered after the texture clear
  20208. */
  20209. onClearObservable: Observable<Engine>;
  20210. private _onClearObserver;
  20211. /**
  20212. * Set a clear callback in the texture.
  20213. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20214. */
  20215. onClear: (Engine: Engine) => void;
  20216. /**
  20217. * An event triggered when the texture is resized.
  20218. */
  20219. onResizeObservable: Observable<RenderTargetTexture>;
  20220. /**
  20221. * Define the clear color of the Render Target if it should be different from the scene.
  20222. */
  20223. clearColor: Color4;
  20224. protected _size: number | {
  20225. width: number;
  20226. height: number;
  20227. };
  20228. protected _initialSizeParameter: number | {
  20229. width: number;
  20230. height: number;
  20231. } | {
  20232. ratio: number;
  20233. };
  20234. protected _sizeRatio: Nullable<number>;
  20235. /** @hidden */
  20236. _generateMipMaps: boolean;
  20237. protected _renderingManager: RenderingManager;
  20238. /** @hidden */
  20239. _waitingRenderList: string[];
  20240. protected _doNotChangeAspectRatio: boolean;
  20241. protected _currentRefreshId: number;
  20242. protected _refreshRate: number;
  20243. protected _textureMatrix: Matrix;
  20244. protected _samples: number;
  20245. protected _renderTargetOptions: RenderTargetCreationOptions;
  20246. /**
  20247. * Gets render target creation options that were used.
  20248. */
  20249. readonly renderTargetOptions: RenderTargetCreationOptions;
  20250. protected _engine: Engine;
  20251. protected _onRatioRescale(): void;
  20252. /**
  20253. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20254. * It must define where the camera used to render the texture is set
  20255. */
  20256. boundingBoxPosition: Vector3;
  20257. private _boundingBoxSize;
  20258. /**
  20259. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20260. * When defined, the cubemap will switch to local mode
  20261. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20262. * @example https://www.babylonjs-playground.com/#RNASML
  20263. */
  20264. boundingBoxSize: Vector3;
  20265. /**
  20266. * In case the RTT has been created with a depth texture, get the associated
  20267. * depth texture.
  20268. * Otherwise, return null.
  20269. */
  20270. depthStencilTexture: Nullable<InternalTexture>;
  20271. /**
  20272. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20273. * or used a shadow, depth texture...
  20274. * @param name The friendly name of the texture
  20275. * @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)
  20276. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20277. * @param generateMipMaps True if mip maps need to be generated after render.
  20278. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20279. * @param type The type of the buffer in the RTT (int, half float, float...)
  20280. * @param isCube True if a cube texture needs to be created
  20281. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20282. * @param generateDepthBuffer True to generate a depth buffer
  20283. * @param generateStencilBuffer True to generate a stencil buffer
  20284. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20285. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20286. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20287. */
  20288. constructor(name: string, size: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20294. /**
  20295. * Creates a depth stencil texture.
  20296. * This is only available in WebGL 2 or with the depth texture extension available.
  20297. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20298. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20299. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20300. */
  20301. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20302. private _processSizeParameter;
  20303. /**
  20304. * Define the number of samples to use in case of MSAA.
  20305. * It defaults to one meaning no MSAA has been enabled.
  20306. */
  20307. samples: number;
  20308. /**
  20309. * Resets the refresh counter of the texture and start bak from scratch.
  20310. * Could be useful to regenerate the texture if it is setup to render only once.
  20311. */
  20312. resetRefreshCounter(): void;
  20313. /**
  20314. * Define the refresh rate of the texture or the rendering frequency.
  20315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20316. */
  20317. refreshRate: number;
  20318. /**
  20319. * Adds a post process to the render target rendering passes.
  20320. * @param postProcess define the post process to add
  20321. */
  20322. addPostProcess(postProcess: PostProcess): void;
  20323. /**
  20324. * Clear all the post processes attached to the render target
  20325. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20326. */
  20327. clearPostProcesses(dispose?: boolean): void;
  20328. /**
  20329. * Remove one of the post process from the list of attached post processes to the texture
  20330. * @param postProcess define the post process to remove from the list
  20331. */
  20332. removePostProcess(postProcess: PostProcess): void;
  20333. /** @hidden */
  20334. _shouldRender(): boolean;
  20335. /**
  20336. * Gets the actual render size of the texture.
  20337. * @returns the width of the render size
  20338. */
  20339. getRenderSize(): number;
  20340. /**
  20341. * Gets the actual render width of the texture.
  20342. * @returns the width of the render size
  20343. */
  20344. getRenderWidth(): number;
  20345. /**
  20346. * Gets the actual render height of the texture.
  20347. * @returns the height of the render size
  20348. */
  20349. getRenderHeight(): number;
  20350. /**
  20351. * Get if the texture can be rescaled or not.
  20352. */
  20353. readonly canRescale: boolean;
  20354. /**
  20355. * Resize the texture using a ratio.
  20356. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20357. */
  20358. scale(ratio: number): void;
  20359. /**
  20360. * Get the texture reflection matrix used to rotate/transform the reflection.
  20361. * @returns the reflection matrix
  20362. */
  20363. getReflectionTextureMatrix(): Matrix;
  20364. /**
  20365. * Resize the texture to a new desired size.
  20366. * Be carrefull as it will recreate all the data in the new texture.
  20367. * @param size Define the new size. It can be:
  20368. * - a number for squared texture,
  20369. * - an object containing { width: number, height: number }
  20370. * - or an object containing a ratio { ratio: number }
  20371. */
  20372. resize(size: number | {
  20373. width: number;
  20374. height: number;
  20375. } | {
  20376. ratio: number;
  20377. }): void;
  20378. /**
  20379. * Renders all the objects from the render list into the texture.
  20380. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20381. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20382. */
  20383. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20384. private _bestReflectionRenderTargetDimension;
  20385. /**
  20386. * @hidden
  20387. * @param faceIndex face index to bind to if this is a cubetexture
  20388. */
  20389. _bindFrameBuffer(faceIndex?: number): void;
  20390. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20391. private renderToTarget;
  20392. /**
  20393. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20394. * This allowed control for front to back rendering or reversly depending of the special needs.
  20395. *
  20396. * @param renderingGroupId The rendering group id corresponding to its index
  20397. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20398. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20399. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20400. */
  20401. 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;
  20402. /**
  20403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20404. *
  20405. * @param renderingGroupId The rendering group id corresponding to its index
  20406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20407. */
  20408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20409. /**
  20410. * Clones the texture.
  20411. * @returns the cloned texture
  20412. */
  20413. clone(): RenderTargetTexture;
  20414. /**
  20415. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20416. * @returns The JSON representation of the texture
  20417. */
  20418. serialize(): any;
  20419. /**
  20420. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20421. */
  20422. disposeFramebufferObjects(): void;
  20423. /**
  20424. * Dispose the texture and release its associated resources.
  20425. */
  20426. dispose(): void;
  20427. /** @hidden */
  20428. _rebuild(): void;
  20429. /**
  20430. * Clear the info related to rendering groups preventing retention point in material dispose.
  20431. */
  20432. freeRenderingGroups(): void;
  20433. /**
  20434. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20435. * @returns the view count
  20436. */
  20437. getViewCount(): number;
  20438. }
  20439. }
  20440. declare module "babylonjs/Materials/material" {
  20441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20442. import { SmartArray } from "babylonjs/Misc/smartArray";
  20443. import { Observable } from "babylonjs/Misc/observable";
  20444. import { Nullable } from "babylonjs/types";
  20445. import { Scene } from "babylonjs/scene";
  20446. import { Matrix } from "babylonjs/Maths/math.vector";
  20447. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20449. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20450. import { Effect } from "babylonjs/Materials/effect";
  20451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20453. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20454. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20455. import { Mesh } from "babylonjs/Meshes/mesh";
  20456. import { Animation } from "babylonjs/Animations/animation";
  20457. /**
  20458. * Base class for the main features of a material in Babylon.js
  20459. */
  20460. export class Material implements IAnimatable {
  20461. /**
  20462. * Returns the triangle fill mode
  20463. */
  20464. static readonly TriangleFillMode: number;
  20465. /**
  20466. * Returns the wireframe mode
  20467. */
  20468. static readonly WireFrameFillMode: number;
  20469. /**
  20470. * Returns the point fill mode
  20471. */
  20472. static readonly PointFillMode: number;
  20473. /**
  20474. * Returns the point list draw mode
  20475. */
  20476. static readonly PointListDrawMode: number;
  20477. /**
  20478. * Returns the line list draw mode
  20479. */
  20480. static readonly LineListDrawMode: number;
  20481. /**
  20482. * Returns the line loop draw mode
  20483. */
  20484. static readonly LineLoopDrawMode: number;
  20485. /**
  20486. * Returns the line strip draw mode
  20487. */
  20488. static readonly LineStripDrawMode: number;
  20489. /**
  20490. * Returns the triangle strip draw mode
  20491. */
  20492. static readonly TriangleStripDrawMode: number;
  20493. /**
  20494. * Returns the triangle fan draw mode
  20495. */
  20496. static readonly TriangleFanDrawMode: number;
  20497. /**
  20498. * Stores the clock-wise side orientation
  20499. */
  20500. static readonly ClockWiseSideOrientation: number;
  20501. /**
  20502. * Stores the counter clock-wise side orientation
  20503. */
  20504. static readonly CounterClockWiseSideOrientation: number;
  20505. /**
  20506. * The dirty texture flag value
  20507. */
  20508. static readonly TextureDirtyFlag: number;
  20509. /**
  20510. * The dirty light flag value
  20511. */
  20512. static readonly LightDirtyFlag: number;
  20513. /**
  20514. * The dirty fresnel flag value
  20515. */
  20516. static readonly FresnelDirtyFlag: number;
  20517. /**
  20518. * The dirty attribute flag value
  20519. */
  20520. static readonly AttributesDirtyFlag: number;
  20521. /**
  20522. * The dirty misc flag value
  20523. */
  20524. static readonly MiscDirtyFlag: number;
  20525. /**
  20526. * The all dirty flag value
  20527. */
  20528. static readonly AllDirtyFlag: number;
  20529. /**
  20530. * The ID of the material
  20531. */
  20532. id: string;
  20533. /**
  20534. * Gets or sets the unique id of the material
  20535. */
  20536. uniqueId: number;
  20537. /**
  20538. * The name of the material
  20539. */
  20540. name: string;
  20541. /**
  20542. * Gets or sets user defined metadata
  20543. */
  20544. metadata: any;
  20545. /**
  20546. * For internal use only. Please do not use.
  20547. */
  20548. reservedDataStore: any;
  20549. /**
  20550. * Specifies if the ready state should be checked on each call
  20551. */
  20552. checkReadyOnEveryCall: boolean;
  20553. /**
  20554. * Specifies if the ready state should be checked once
  20555. */
  20556. checkReadyOnlyOnce: boolean;
  20557. /**
  20558. * The state of the material
  20559. */
  20560. state: string;
  20561. /**
  20562. * The alpha value of the material
  20563. */
  20564. protected _alpha: number;
  20565. /**
  20566. * List of inspectable custom properties (used by the Inspector)
  20567. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20568. */
  20569. inspectableCustomProperties: IInspectable[];
  20570. /**
  20571. * Sets the alpha value of the material
  20572. */
  20573. /**
  20574. * Gets the alpha value of the material
  20575. */
  20576. alpha: number;
  20577. /**
  20578. * Specifies if back face culling is enabled
  20579. */
  20580. protected _backFaceCulling: boolean;
  20581. /**
  20582. * Sets the back-face culling state
  20583. */
  20584. /**
  20585. * Gets the back-face culling state
  20586. */
  20587. backFaceCulling: boolean;
  20588. /**
  20589. * Stores the value for side orientation
  20590. */
  20591. sideOrientation: number;
  20592. /**
  20593. * Callback triggered when the material is compiled
  20594. */
  20595. onCompiled: Nullable<(effect: Effect) => void>;
  20596. /**
  20597. * Callback triggered when an error occurs
  20598. */
  20599. onError: Nullable<(effect: Effect, errors: string) => void>;
  20600. /**
  20601. * Callback triggered to get the render target textures
  20602. */
  20603. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20604. /**
  20605. * Gets a boolean indicating that current material needs to register RTT
  20606. */
  20607. readonly hasRenderTargetTextures: boolean;
  20608. /**
  20609. * Specifies if the material should be serialized
  20610. */
  20611. doNotSerialize: boolean;
  20612. /**
  20613. * @hidden
  20614. */
  20615. _storeEffectOnSubMeshes: boolean;
  20616. /**
  20617. * Stores the animations for the material
  20618. */
  20619. animations: Nullable<Array<Animation>>;
  20620. /**
  20621. * An event triggered when the material is disposed
  20622. */
  20623. onDisposeObservable: Observable<Material>;
  20624. /**
  20625. * An observer which watches for dispose events
  20626. */
  20627. private _onDisposeObserver;
  20628. private _onUnBindObservable;
  20629. /**
  20630. * Called during a dispose event
  20631. */
  20632. onDispose: () => void;
  20633. private _onBindObservable;
  20634. /**
  20635. * An event triggered when the material is bound
  20636. */
  20637. readonly onBindObservable: Observable<AbstractMesh>;
  20638. /**
  20639. * An observer which watches for bind events
  20640. */
  20641. private _onBindObserver;
  20642. /**
  20643. * Called during a bind event
  20644. */
  20645. onBind: (Mesh: AbstractMesh) => void;
  20646. /**
  20647. * An event triggered when the material is unbound
  20648. */
  20649. readonly onUnBindObservable: Observable<Material>;
  20650. /**
  20651. * Stores the value of the alpha mode
  20652. */
  20653. private _alphaMode;
  20654. /**
  20655. * Sets the value of the alpha mode.
  20656. *
  20657. * | Value | Type | Description |
  20658. * | --- | --- | --- |
  20659. * | 0 | ALPHA_DISABLE | |
  20660. * | 1 | ALPHA_ADD | |
  20661. * | 2 | ALPHA_COMBINE | |
  20662. * | 3 | ALPHA_SUBTRACT | |
  20663. * | 4 | ALPHA_MULTIPLY | |
  20664. * | 5 | ALPHA_MAXIMIZED | |
  20665. * | 6 | ALPHA_ONEONE | |
  20666. * | 7 | ALPHA_PREMULTIPLIED | |
  20667. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20668. * | 9 | ALPHA_INTERPOLATE | |
  20669. * | 10 | ALPHA_SCREENMODE | |
  20670. *
  20671. */
  20672. /**
  20673. * Gets the value of the alpha mode
  20674. */
  20675. alphaMode: number;
  20676. /**
  20677. * Stores the state of the need depth pre-pass value
  20678. */
  20679. private _needDepthPrePass;
  20680. /**
  20681. * Sets the need depth pre-pass value
  20682. */
  20683. /**
  20684. * Gets the depth pre-pass value
  20685. */
  20686. needDepthPrePass: boolean;
  20687. /**
  20688. * Specifies if depth writing should be disabled
  20689. */
  20690. disableDepthWrite: boolean;
  20691. /**
  20692. * Specifies if depth writing should be forced
  20693. */
  20694. forceDepthWrite: boolean;
  20695. /**
  20696. * Specifies if there should be a separate pass for culling
  20697. */
  20698. separateCullingPass: boolean;
  20699. /**
  20700. * Stores the state specifing if fog should be enabled
  20701. */
  20702. private _fogEnabled;
  20703. /**
  20704. * Sets the state for enabling fog
  20705. */
  20706. /**
  20707. * Gets the value of the fog enabled state
  20708. */
  20709. fogEnabled: boolean;
  20710. /**
  20711. * Stores the size of points
  20712. */
  20713. pointSize: number;
  20714. /**
  20715. * Stores the z offset value
  20716. */
  20717. zOffset: number;
  20718. /**
  20719. * Gets a value specifying if wireframe mode is enabled
  20720. */
  20721. /**
  20722. * Sets the state of wireframe mode
  20723. */
  20724. wireframe: boolean;
  20725. /**
  20726. * Gets the value specifying if point clouds are enabled
  20727. */
  20728. /**
  20729. * Sets the state of point cloud mode
  20730. */
  20731. pointsCloud: boolean;
  20732. /**
  20733. * Gets the material fill mode
  20734. */
  20735. /**
  20736. * Sets the material fill mode
  20737. */
  20738. fillMode: number;
  20739. /**
  20740. * @hidden
  20741. * Stores the effects for the material
  20742. */
  20743. _effect: Nullable<Effect>;
  20744. /**
  20745. * @hidden
  20746. * Specifies if the material was previously ready
  20747. */
  20748. _wasPreviouslyReady: boolean;
  20749. /**
  20750. * Specifies if uniform buffers should be used
  20751. */
  20752. private _useUBO;
  20753. /**
  20754. * Stores a reference to the scene
  20755. */
  20756. private _scene;
  20757. /**
  20758. * Stores the fill mode state
  20759. */
  20760. private _fillMode;
  20761. /**
  20762. * Specifies if the depth write state should be cached
  20763. */
  20764. private _cachedDepthWriteState;
  20765. /**
  20766. * Stores the uniform buffer
  20767. */
  20768. protected _uniformBuffer: UniformBuffer;
  20769. /** @hidden */
  20770. _indexInSceneMaterialArray: number;
  20771. /** @hidden */
  20772. meshMap: Nullable<{
  20773. [id: string]: AbstractMesh | undefined;
  20774. }>;
  20775. /**
  20776. * Creates a material instance
  20777. * @param name defines the name of the material
  20778. * @param scene defines the scene to reference
  20779. * @param doNotAdd specifies if the material should be added to the scene
  20780. */
  20781. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20782. /**
  20783. * Returns a string representation of the current material
  20784. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20785. * @returns a string with material information
  20786. */
  20787. toString(fullDetails?: boolean): string;
  20788. /**
  20789. * Gets the class name of the material
  20790. * @returns a string with the class name of the material
  20791. */
  20792. getClassName(): string;
  20793. /**
  20794. * Specifies if updates for the material been locked
  20795. */
  20796. readonly isFrozen: boolean;
  20797. /**
  20798. * Locks updates for the material
  20799. */
  20800. freeze(): void;
  20801. /**
  20802. * Unlocks updates for the material
  20803. */
  20804. unfreeze(): void;
  20805. /**
  20806. * Specifies if the material is ready to be used
  20807. * @param mesh defines the mesh to check
  20808. * @param useInstances specifies if instances should be used
  20809. * @returns a boolean indicating if the material is ready to be used
  20810. */
  20811. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20812. /**
  20813. * Specifies that the submesh is ready to be used
  20814. * @param mesh defines the mesh to check
  20815. * @param subMesh defines which submesh to check
  20816. * @param useInstances specifies that instances should be used
  20817. * @returns a boolean indicating that the submesh is ready or not
  20818. */
  20819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20820. /**
  20821. * Returns the material effect
  20822. * @returns the effect associated with the material
  20823. */
  20824. getEffect(): Nullable<Effect>;
  20825. /**
  20826. * Returns the current scene
  20827. * @returns a Scene
  20828. */
  20829. getScene(): Scene;
  20830. /**
  20831. * Specifies if the material will require alpha blending
  20832. * @returns a boolean specifying if alpha blending is needed
  20833. */
  20834. needAlphaBlending(): boolean;
  20835. /**
  20836. * Specifies if the mesh will require alpha blending
  20837. * @param mesh defines the mesh to check
  20838. * @returns a boolean specifying if alpha blending is needed for the mesh
  20839. */
  20840. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20841. /**
  20842. * Specifies if this material should be rendered in alpha test mode
  20843. * @returns a boolean specifying if an alpha test is needed.
  20844. */
  20845. needAlphaTesting(): boolean;
  20846. /**
  20847. * Gets the texture used for the alpha test
  20848. * @returns the texture to use for alpha testing
  20849. */
  20850. getAlphaTestTexture(): Nullable<BaseTexture>;
  20851. /**
  20852. * Marks the material to indicate that it needs to be re-calculated
  20853. */
  20854. markDirty(): void;
  20855. /** @hidden */
  20856. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20857. /**
  20858. * Binds the material to the mesh
  20859. * @param world defines the world transformation matrix
  20860. * @param mesh defines the mesh to bind the material to
  20861. */
  20862. bind(world: Matrix, mesh?: Mesh): void;
  20863. /**
  20864. * Binds the submesh to the material
  20865. * @param world defines the world transformation matrix
  20866. * @param mesh defines the mesh containing the submesh
  20867. * @param subMesh defines the submesh to bind the material to
  20868. */
  20869. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20870. /**
  20871. * Binds the world matrix to the material
  20872. * @param world defines the world transformation matrix
  20873. */
  20874. bindOnlyWorldMatrix(world: Matrix): void;
  20875. /**
  20876. * Binds the scene's uniform buffer to the effect.
  20877. * @param effect defines the effect to bind to the scene uniform buffer
  20878. * @param sceneUbo defines the uniform buffer storing scene data
  20879. */
  20880. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20881. /**
  20882. * Binds the view matrix to the effect
  20883. * @param effect defines the effect to bind the view matrix to
  20884. */
  20885. bindView(effect: Effect): void;
  20886. /**
  20887. * Binds the view projection matrix to the effect
  20888. * @param effect defines the effect to bind the view projection matrix to
  20889. */
  20890. bindViewProjection(effect: Effect): void;
  20891. /**
  20892. * Specifies if material alpha testing should be turned on for the mesh
  20893. * @param mesh defines the mesh to check
  20894. */
  20895. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20896. /**
  20897. * Processes to execute after binding the material to a mesh
  20898. * @param mesh defines the rendered mesh
  20899. */
  20900. protected _afterBind(mesh?: Mesh): void;
  20901. /**
  20902. * Unbinds the material from the mesh
  20903. */
  20904. unbind(): void;
  20905. /**
  20906. * Gets the active textures from the material
  20907. * @returns an array of textures
  20908. */
  20909. getActiveTextures(): BaseTexture[];
  20910. /**
  20911. * Specifies if the material uses a texture
  20912. * @param texture defines the texture to check against the material
  20913. * @returns a boolean specifying if the material uses the texture
  20914. */
  20915. hasTexture(texture: BaseTexture): boolean;
  20916. /**
  20917. * Makes a duplicate of the material, and gives it a new name
  20918. * @param name defines the new name for the duplicated material
  20919. * @returns the cloned material
  20920. */
  20921. clone(name: string): Nullable<Material>;
  20922. /**
  20923. * Gets the meshes bound to the material
  20924. * @returns an array of meshes bound to the material
  20925. */
  20926. getBindedMeshes(): AbstractMesh[];
  20927. /**
  20928. * Force shader compilation
  20929. * @param mesh defines the mesh associated with this material
  20930. * @param onCompiled defines a function to execute once the material is compiled
  20931. * @param options defines the options to configure the compilation
  20932. */
  20933. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20934. clipPlane: boolean;
  20935. }>): void;
  20936. /**
  20937. * Force shader compilation
  20938. * @param mesh defines the mesh that will use this material
  20939. * @param options defines additional options for compiling the shaders
  20940. * @returns a promise that resolves when the compilation completes
  20941. */
  20942. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20943. clipPlane: boolean;
  20944. }>): Promise<void>;
  20945. private static readonly _AllDirtyCallBack;
  20946. private static readonly _ImageProcessingDirtyCallBack;
  20947. private static readonly _TextureDirtyCallBack;
  20948. private static readonly _FresnelDirtyCallBack;
  20949. private static readonly _MiscDirtyCallBack;
  20950. private static readonly _LightsDirtyCallBack;
  20951. private static readonly _AttributeDirtyCallBack;
  20952. private static _FresnelAndMiscDirtyCallBack;
  20953. private static _TextureAndMiscDirtyCallBack;
  20954. private static readonly _DirtyCallbackArray;
  20955. private static readonly _RunDirtyCallBacks;
  20956. /**
  20957. * Marks a define in the material to indicate that it needs to be re-computed
  20958. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20959. */
  20960. markAsDirty(flag: number): void;
  20961. /**
  20962. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20963. * @param func defines a function which checks material defines against the submeshes
  20964. */
  20965. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20966. /**
  20967. * Indicates that we need to re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsAllDirty(): void;
  20970. /**
  20971. * Indicates that image processing needs to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20974. /**
  20975. * Indicates that textures need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsTexturesDirty(): void;
  20978. /**
  20979. * Indicates that fresnel needs to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsFresnelDirty(): void;
  20982. /**
  20983. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20986. /**
  20987. * Indicates that lights need to be re-calculated for all submeshes
  20988. */
  20989. protected _markAllSubMeshesAsLightsDirty(): void;
  20990. /**
  20991. * Indicates that attributes need to be re-calculated for all submeshes
  20992. */
  20993. protected _markAllSubMeshesAsAttributesDirty(): void;
  20994. /**
  20995. * Indicates that misc needs to be re-calculated for all submeshes
  20996. */
  20997. protected _markAllSubMeshesAsMiscDirty(): void;
  20998. /**
  20999. * Indicates that textures and misc need to be re-calculated for all submeshes
  21000. */
  21001. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21002. /**
  21003. * Disposes the material
  21004. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21005. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21006. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21007. */
  21008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21009. /** @hidden */
  21010. private releaseVertexArrayObject;
  21011. /**
  21012. * Serializes this material
  21013. * @returns the serialized material object
  21014. */
  21015. serialize(): any;
  21016. /**
  21017. * Creates a material from parsed material data
  21018. * @param parsedMaterial defines parsed material data
  21019. * @param scene defines the hosting scene
  21020. * @param rootUrl defines the root URL to use to load textures
  21021. * @returns a new material
  21022. */
  21023. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21024. }
  21025. }
  21026. declare module "babylonjs/Materials/multiMaterial" {
  21027. import { Nullable } from "babylonjs/types";
  21028. import { Scene } from "babylonjs/scene";
  21029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21030. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21032. import { Material } from "babylonjs/Materials/material";
  21033. /**
  21034. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21035. * separate meshes. This can be use to improve performances.
  21036. * @see http://doc.babylonjs.com/how_to/multi_materials
  21037. */
  21038. export class MultiMaterial extends Material {
  21039. private _subMaterials;
  21040. /**
  21041. * Gets or Sets the list of Materials used within the multi material.
  21042. * They need to be ordered according to the submeshes order in the associated mesh
  21043. */
  21044. subMaterials: Nullable<Material>[];
  21045. /**
  21046. * Function used to align with Node.getChildren()
  21047. * @returns the list of Materials used within the multi material
  21048. */
  21049. getChildren(): Nullable<Material>[];
  21050. /**
  21051. * Instantiates a new Multi Material
  21052. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21053. * separate meshes. This can be use to improve performances.
  21054. * @see http://doc.babylonjs.com/how_to/multi_materials
  21055. * @param name Define the name in the scene
  21056. * @param scene Define the scene the material belongs to
  21057. */
  21058. constructor(name: string, scene: Scene);
  21059. private _hookArray;
  21060. /**
  21061. * Get one of the submaterial by its index in the submaterials array
  21062. * @param index The index to look the sub material at
  21063. * @returns The Material if the index has been defined
  21064. */
  21065. getSubMaterial(index: number): Nullable<Material>;
  21066. /**
  21067. * Get the list of active textures for the whole sub materials list.
  21068. * @returns All the textures that will be used during the rendering
  21069. */
  21070. getActiveTextures(): BaseTexture[];
  21071. /**
  21072. * Gets the current class name of the material e.g. "MultiMaterial"
  21073. * Mainly use in serialization.
  21074. * @returns the class name
  21075. */
  21076. getClassName(): string;
  21077. /**
  21078. * Checks if the material is ready to render the requested sub mesh
  21079. * @param mesh Define the mesh the submesh belongs to
  21080. * @param subMesh Define the sub mesh to look readyness for
  21081. * @param useInstances Define whether or not the material is used with instances
  21082. * @returns true if ready, otherwise false
  21083. */
  21084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21085. /**
  21086. * Clones the current material and its related sub materials
  21087. * @param name Define the name of the newly cloned material
  21088. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21089. * @returns the cloned material
  21090. */
  21091. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21092. /**
  21093. * Serializes the materials into a JSON representation.
  21094. * @returns the JSON representation
  21095. */
  21096. serialize(): any;
  21097. /**
  21098. * Dispose the material and release its associated resources
  21099. * @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)
  21100. * @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)
  21101. * @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)
  21102. */
  21103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21104. /**
  21105. * Creates a MultiMaterial from parsed MultiMaterial data.
  21106. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21107. * @param scene defines the hosting scene
  21108. * @returns a new MultiMaterial
  21109. */
  21110. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21111. }
  21112. }
  21113. declare module "babylonjs/Meshes/subMesh" {
  21114. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21115. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21116. import { Engine } from "babylonjs/Engines/engine";
  21117. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21118. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21119. import { Effect } from "babylonjs/Materials/effect";
  21120. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21121. import { Plane } from "babylonjs/Maths/math.plane";
  21122. import { Collider } from "babylonjs/Collisions/collider";
  21123. import { Material } from "babylonjs/Materials/material";
  21124. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21126. import { Mesh } from "babylonjs/Meshes/mesh";
  21127. import { Ray } from "babylonjs/Culling/ray";
  21128. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21129. /**
  21130. * Base class for submeshes
  21131. */
  21132. export class BaseSubMesh {
  21133. /** @hidden */
  21134. _materialDefines: Nullable<MaterialDefines>;
  21135. /** @hidden */
  21136. _materialEffect: Nullable<Effect>;
  21137. /**
  21138. * Gets associated effect
  21139. */
  21140. readonly effect: Nullable<Effect>;
  21141. /**
  21142. * Sets associated effect (effect used to render this submesh)
  21143. * @param effect defines the effect to associate with
  21144. * @param defines defines the set of defines used to compile this effect
  21145. */
  21146. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21147. }
  21148. /**
  21149. * Defines a subdivision inside a mesh
  21150. */
  21151. export class SubMesh extends BaseSubMesh implements ICullable {
  21152. /** the material index to use */
  21153. materialIndex: number;
  21154. /** vertex index start */
  21155. verticesStart: number;
  21156. /** vertices count */
  21157. verticesCount: number;
  21158. /** index start */
  21159. indexStart: number;
  21160. /** indices count */
  21161. indexCount: number;
  21162. /** @hidden */
  21163. _linesIndexCount: number;
  21164. private _mesh;
  21165. private _renderingMesh;
  21166. private _boundingInfo;
  21167. private _linesIndexBuffer;
  21168. /** @hidden */
  21169. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21170. /** @hidden */
  21171. _trianglePlanes: Plane[];
  21172. /** @hidden */
  21173. _lastColliderTransformMatrix: Nullable<Matrix>;
  21174. /** @hidden */
  21175. _renderId: number;
  21176. /** @hidden */
  21177. _alphaIndex: number;
  21178. /** @hidden */
  21179. _distanceToCamera: number;
  21180. /** @hidden */
  21181. _id: number;
  21182. private _currentMaterial;
  21183. /**
  21184. * Add a new submesh to a mesh
  21185. * @param materialIndex defines the material index to use
  21186. * @param verticesStart defines vertex index start
  21187. * @param verticesCount defines vertices count
  21188. * @param indexStart defines index start
  21189. * @param indexCount defines indices count
  21190. * @param mesh defines the parent mesh
  21191. * @param renderingMesh defines an optional rendering mesh
  21192. * @param createBoundingBox defines if bounding box should be created for this submesh
  21193. * @returns the new submesh
  21194. */
  21195. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21196. /**
  21197. * Creates a new submesh
  21198. * @param materialIndex defines the material index to use
  21199. * @param verticesStart defines vertex index start
  21200. * @param verticesCount defines vertices count
  21201. * @param indexStart defines index start
  21202. * @param indexCount defines indices count
  21203. * @param mesh defines the parent mesh
  21204. * @param renderingMesh defines an optional rendering mesh
  21205. * @param createBoundingBox defines if bounding box should be created for this submesh
  21206. */
  21207. constructor(
  21208. /** the material index to use */
  21209. materialIndex: number,
  21210. /** vertex index start */
  21211. verticesStart: number,
  21212. /** vertices count */
  21213. verticesCount: number,
  21214. /** index start */
  21215. indexStart: number,
  21216. /** indices count */
  21217. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21218. /**
  21219. * Returns true if this submesh covers the entire parent mesh
  21220. * @ignorenaming
  21221. */
  21222. readonly IsGlobal: boolean;
  21223. /**
  21224. * Returns the submesh BoudingInfo object
  21225. * @returns current bounding info (or mesh's one if the submesh is global)
  21226. */
  21227. getBoundingInfo(): BoundingInfo;
  21228. /**
  21229. * Sets the submesh BoundingInfo
  21230. * @param boundingInfo defines the new bounding info to use
  21231. * @returns the SubMesh
  21232. */
  21233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21234. /**
  21235. * Returns the mesh of the current submesh
  21236. * @return the parent mesh
  21237. */
  21238. getMesh(): AbstractMesh;
  21239. /**
  21240. * Returns the rendering mesh of the submesh
  21241. * @returns the rendering mesh (could be different from parent mesh)
  21242. */
  21243. getRenderingMesh(): Mesh;
  21244. /**
  21245. * Returns the submesh material
  21246. * @returns null or the current material
  21247. */
  21248. getMaterial(): Nullable<Material>;
  21249. /**
  21250. * Sets a new updated BoundingInfo object to the submesh
  21251. * @param data defines an optional position array to use to determine the bounding info
  21252. * @returns the SubMesh
  21253. */
  21254. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21255. /** @hidden */
  21256. _checkCollision(collider: Collider): boolean;
  21257. /**
  21258. * Updates the submesh BoundingInfo
  21259. * @param world defines the world matrix to use to update the bounding info
  21260. * @returns the submesh
  21261. */
  21262. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21263. /**
  21264. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21265. * @param frustumPlanes defines the frustum planes
  21266. * @returns true if the submesh is intersecting with the frustum
  21267. */
  21268. isInFrustum(frustumPlanes: Plane[]): boolean;
  21269. /**
  21270. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21271. * @param frustumPlanes defines the frustum planes
  21272. * @returns true if the submesh is inside the frustum
  21273. */
  21274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21275. /**
  21276. * Renders the submesh
  21277. * @param enableAlphaMode defines if alpha needs to be used
  21278. * @returns the submesh
  21279. */
  21280. render(enableAlphaMode: boolean): SubMesh;
  21281. /**
  21282. * @hidden
  21283. */
  21284. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21285. /**
  21286. * Checks if the submesh intersects with a ray
  21287. * @param ray defines the ray to test
  21288. * @returns true is the passed ray intersects the submesh bounding box
  21289. */
  21290. canIntersects(ray: Ray): boolean;
  21291. /**
  21292. * Intersects current submesh with a ray
  21293. * @param ray defines the ray to test
  21294. * @param positions defines mesh's positions array
  21295. * @param indices defines mesh's indices array
  21296. * @param fastCheck defines if only bounding info should be used
  21297. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21298. * @returns intersection info or null if no intersection
  21299. */
  21300. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21301. /** @hidden */
  21302. private _intersectLines;
  21303. /** @hidden */
  21304. private _intersectUnIndexedLines;
  21305. /** @hidden */
  21306. private _intersectTriangles;
  21307. /** @hidden */
  21308. private _intersectUnIndexedTriangles;
  21309. /** @hidden */
  21310. _rebuild(): void;
  21311. /**
  21312. * Creates a new submesh from the passed mesh
  21313. * @param newMesh defines the new hosting mesh
  21314. * @param newRenderingMesh defines an optional rendering mesh
  21315. * @returns the new submesh
  21316. */
  21317. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21318. /**
  21319. * Release associated resources
  21320. */
  21321. dispose(): void;
  21322. /**
  21323. * Gets the class name
  21324. * @returns the string "SubMesh".
  21325. */
  21326. getClassName(): string;
  21327. /**
  21328. * Creates a new submesh from indices data
  21329. * @param materialIndex the index of the main mesh material
  21330. * @param startIndex the index where to start the copy in the mesh indices array
  21331. * @param indexCount the number of indices to copy then from the startIndex
  21332. * @param mesh the main mesh to create the submesh from
  21333. * @param renderingMesh the optional rendering mesh
  21334. * @returns a new submesh
  21335. */
  21336. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21337. }
  21338. }
  21339. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21340. /**
  21341. * Class used to represent data loading progression
  21342. */
  21343. export class SceneLoaderFlags {
  21344. private static _ForceFullSceneLoadingForIncremental;
  21345. private static _ShowLoadingScreen;
  21346. private static _CleanBoneMatrixWeights;
  21347. private static _loggingLevel;
  21348. /**
  21349. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21350. */
  21351. static ForceFullSceneLoadingForIncremental: boolean;
  21352. /**
  21353. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21354. */
  21355. static ShowLoadingScreen: boolean;
  21356. /**
  21357. * Defines the current logging level (while loading the scene)
  21358. * @ignorenaming
  21359. */
  21360. static loggingLevel: number;
  21361. /**
  21362. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21363. */
  21364. static CleanBoneMatrixWeights: boolean;
  21365. }
  21366. }
  21367. declare module "babylonjs/Meshes/geometry" {
  21368. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21371. import { Engine } from "babylonjs/Engines/engine";
  21372. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21373. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21374. import { Effect } from "babylonjs/Materials/effect";
  21375. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21377. import { Mesh } from "babylonjs/Meshes/mesh";
  21378. /**
  21379. * Class used to store geometry data (vertex buffers + index buffer)
  21380. */
  21381. export class Geometry implements IGetSetVerticesData {
  21382. /**
  21383. * Gets or sets the ID of the geometry
  21384. */
  21385. id: string;
  21386. /**
  21387. * Gets or sets the unique ID of the geometry
  21388. */
  21389. uniqueId: number;
  21390. /**
  21391. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21392. */
  21393. delayLoadState: number;
  21394. /**
  21395. * Gets the file containing the data to load when running in delay load state
  21396. */
  21397. delayLoadingFile: Nullable<string>;
  21398. /**
  21399. * Callback called when the geometry is updated
  21400. */
  21401. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21402. private _scene;
  21403. private _engine;
  21404. private _meshes;
  21405. private _totalVertices;
  21406. /** @hidden */
  21407. _indices: IndicesArray;
  21408. /** @hidden */
  21409. _vertexBuffers: {
  21410. [key: string]: VertexBuffer;
  21411. };
  21412. private _isDisposed;
  21413. private _extend;
  21414. private _boundingBias;
  21415. /** @hidden */
  21416. _delayInfo: Array<string>;
  21417. private _indexBuffer;
  21418. private _indexBufferIsUpdatable;
  21419. /** @hidden */
  21420. _boundingInfo: Nullable<BoundingInfo>;
  21421. /** @hidden */
  21422. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21423. /** @hidden */
  21424. _softwareSkinningFrameId: number;
  21425. private _vertexArrayObjects;
  21426. private _updatable;
  21427. /** @hidden */
  21428. _positions: Nullable<Vector3[]>;
  21429. /**
  21430. * 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
  21431. */
  21432. /**
  21433. * 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
  21434. */
  21435. boundingBias: Vector2;
  21436. /**
  21437. * Static function used to attach a new empty geometry to a mesh
  21438. * @param mesh defines the mesh to attach the geometry to
  21439. * @returns the new Geometry
  21440. */
  21441. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21442. /**
  21443. * Creates a new geometry
  21444. * @param id defines the unique ID
  21445. * @param scene defines the hosting scene
  21446. * @param vertexData defines the VertexData used to get geometry data
  21447. * @param updatable defines if geometry must be updatable (false by default)
  21448. * @param mesh defines the mesh that will be associated with the geometry
  21449. */
  21450. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21451. /**
  21452. * Gets the current extend of the geometry
  21453. */
  21454. readonly extend: {
  21455. minimum: Vector3;
  21456. maximum: Vector3;
  21457. };
  21458. /**
  21459. * Gets the hosting scene
  21460. * @returns the hosting Scene
  21461. */
  21462. getScene(): Scene;
  21463. /**
  21464. * Gets the hosting engine
  21465. * @returns the hosting Engine
  21466. */
  21467. getEngine(): Engine;
  21468. /**
  21469. * Defines if the geometry is ready to use
  21470. * @returns true if the geometry is ready to be used
  21471. */
  21472. isReady(): boolean;
  21473. /**
  21474. * Gets a value indicating that the geometry should not be serialized
  21475. */
  21476. readonly doNotSerialize: boolean;
  21477. /** @hidden */
  21478. _rebuild(): void;
  21479. /**
  21480. * Affects all geometry data in one call
  21481. * @param vertexData defines the geometry data
  21482. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21483. */
  21484. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21485. /**
  21486. * Set specific vertex data
  21487. * @param kind defines the data kind (Position, normal, etc...)
  21488. * @param data defines the vertex data to use
  21489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21491. */
  21492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21493. /**
  21494. * Removes a specific vertex data
  21495. * @param kind defines the data kind (Position, normal, etc...)
  21496. */
  21497. removeVerticesData(kind: string): void;
  21498. /**
  21499. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21500. * @param buffer defines the vertex buffer to use
  21501. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21502. */
  21503. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21504. /**
  21505. * Update a specific vertex buffer
  21506. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21507. * It will do nothing if the buffer is not updatable
  21508. * @param kind defines the data kind (Position, normal, etc...)
  21509. * @param data defines the data to use
  21510. * @param offset defines the offset in the target buffer where to store the data
  21511. * @param useBytes set to true if the offset is in bytes
  21512. */
  21513. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21514. /**
  21515. * Update a specific vertex buffer
  21516. * This function will create a new buffer if the current one is not updatable
  21517. * @param kind defines the data kind (Position, normal, etc...)
  21518. * @param data defines the data to use
  21519. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21520. */
  21521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21522. private _updateBoundingInfo;
  21523. /** @hidden */
  21524. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21525. /**
  21526. * Gets total number of vertices
  21527. * @returns the total number of vertices
  21528. */
  21529. getTotalVertices(): number;
  21530. /**
  21531. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21532. * @param kind defines the data kind (Position, normal, etc...)
  21533. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21535. * @returns a float array containing vertex data
  21536. */
  21537. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21538. /**
  21539. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21540. * @param kind defines the data kind (Position, normal, etc...)
  21541. * @returns true if the vertex buffer with the specified kind is updatable
  21542. */
  21543. isVertexBufferUpdatable(kind: string): boolean;
  21544. /**
  21545. * Gets a specific vertex buffer
  21546. * @param kind defines the data kind (Position, normal, etc...)
  21547. * @returns a VertexBuffer
  21548. */
  21549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21550. /**
  21551. * Returns all vertex buffers
  21552. * @return an object holding all vertex buffers indexed by kind
  21553. */
  21554. getVertexBuffers(): Nullable<{
  21555. [key: string]: VertexBuffer;
  21556. }>;
  21557. /**
  21558. * Gets a boolean indicating if specific vertex buffer is present
  21559. * @param kind defines the data kind (Position, normal, etc...)
  21560. * @returns true if data is present
  21561. */
  21562. isVerticesDataPresent(kind: string): boolean;
  21563. /**
  21564. * Gets a list of all attached data kinds (Position, normal, etc...)
  21565. * @returns a list of string containing all kinds
  21566. */
  21567. getVerticesDataKinds(): string[];
  21568. /**
  21569. * Update index buffer
  21570. * @param indices defines the indices to store in the index buffer
  21571. * @param offset defines the offset in the target buffer where to store the data
  21572. * @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)
  21573. */
  21574. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21575. /**
  21576. * Creates a new index buffer
  21577. * @param indices defines the indices to store in the index buffer
  21578. * @param totalVertices defines the total number of vertices (could be null)
  21579. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21580. */
  21581. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21582. /**
  21583. * Return the total number of indices
  21584. * @returns the total number of indices
  21585. */
  21586. getTotalIndices(): number;
  21587. /**
  21588. * Gets the index buffer array
  21589. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21591. * @returns the index buffer array
  21592. */
  21593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21594. /**
  21595. * Gets the index buffer
  21596. * @return the index buffer
  21597. */
  21598. getIndexBuffer(): Nullable<DataBuffer>;
  21599. /** @hidden */
  21600. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21601. /**
  21602. * Release the associated resources for a specific mesh
  21603. * @param mesh defines the source mesh
  21604. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21605. */
  21606. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21607. /**
  21608. * Apply current geometry to a given mesh
  21609. * @param mesh defines the mesh to apply geometry to
  21610. */
  21611. applyToMesh(mesh: Mesh): void;
  21612. private _updateExtend;
  21613. private _applyToMesh;
  21614. private notifyUpdate;
  21615. /**
  21616. * Load the geometry if it was flagged as delay loaded
  21617. * @param scene defines the hosting scene
  21618. * @param onLoaded defines a callback called when the geometry is loaded
  21619. */
  21620. load(scene: Scene, onLoaded?: () => void): void;
  21621. private _queueLoad;
  21622. /**
  21623. * Invert the geometry to move from a right handed system to a left handed one.
  21624. */
  21625. toLeftHanded(): void;
  21626. /** @hidden */
  21627. _resetPointsArrayCache(): void;
  21628. /** @hidden */
  21629. _generatePointsArray(): boolean;
  21630. /**
  21631. * Gets a value indicating if the geometry is disposed
  21632. * @returns true if the geometry was disposed
  21633. */
  21634. isDisposed(): boolean;
  21635. private _disposeVertexArrayObjects;
  21636. /**
  21637. * Free all associated resources
  21638. */
  21639. dispose(): void;
  21640. /**
  21641. * Clone the current geometry into a new geometry
  21642. * @param id defines the unique ID of the new geometry
  21643. * @returns a new geometry object
  21644. */
  21645. copy(id: string): Geometry;
  21646. /**
  21647. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21648. * @return a JSON representation of the current geometry data (without the vertices data)
  21649. */
  21650. serialize(): any;
  21651. private toNumberArray;
  21652. /**
  21653. * Serialize all vertices data into a JSON oject
  21654. * @returns a JSON representation of the current geometry data
  21655. */
  21656. serializeVerticeData(): any;
  21657. /**
  21658. * Extracts a clone of a mesh geometry
  21659. * @param mesh defines the source mesh
  21660. * @param id defines the unique ID of the new geometry object
  21661. * @returns the new geometry object
  21662. */
  21663. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21664. /**
  21665. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21666. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21667. * Be aware Math.random() could cause collisions, but:
  21668. * "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"
  21669. * @returns a string containing a new GUID
  21670. */
  21671. static RandomId(): string;
  21672. /** @hidden */
  21673. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21674. private static _CleanMatricesWeights;
  21675. /**
  21676. * Create a new geometry from persisted data (Using .babylon file format)
  21677. * @param parsedVertexData defines the persisted data
  21678. * @param scene defines the hosting scene
  21679. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21680. * @returns the new geometry object
  21681. */
  21682. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21683. }
  21684. }
  21685. declare module "babylonjs/Meshes/mesh.vertexData" {
  21686. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21687. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21688. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21689. import { Geometry } from "babylonjs/Meshes/geometry";
  21690. import { Mesh } from "babylonjs/Meshes/mesh";
  21691. /**
  21692. * Define an interface for all classes that will get and set the data on vertices
  21693. */
  21694. export interface IGetSetVerticesData {
  21695. /**
  21696. * Gets a boolean indicating if specific vertex data is present
  21697. * @param kind defines the vertex data kind to use
  21698. * @returns true is data kind is present
  21699. */
  21700. isVerticesDataPresent(kind: string): boolean;
  21701. /**
  21702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21703. * @param kind defines the data kind (Position, normal, etc...)
  21704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21706. * @returns a float array containing vertex data
  21707. */
  21708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21709. /**
  21710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21711. * @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.
  21712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21713. * @returns the indices array or an empty array if the mesh has no geometry
  21714. */
  21715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21716. /**
  21717. * Set specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. * @param data defines the vertex data to use
  21720. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21721. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21722. */
  21723. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21724. /**
  21725. * Update a specific associated vertex buffer
  21726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21727. * - VertexBuffer.PositionKind
  21728. * - VertexBuffer.UVKind
  21729. * - VertexBuffer.UV2Kind
  21730. * - VertexBuffer.UV3Kind
  21731. * - VertexBuffer.UV4Kind
  21732. * - VertexBuffer.UV5Kind
  21733. * - VertexBuffer.UV6Kind
  21734. * - VertexBuffer.ColorKind
  21735. * - VertexBuffer.MatricesIndicesKind
  21736. * - VertexBuffer.MatricesIndicesExtraKind
  21737. * - VertexBuffer.MatricesWeightsKind
  21738. * - VertexBuffer.MatricesWeightsExtraKind
  21739. * @param data defines the data source
  21740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21741. * @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)
  21742. */
  21743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21744. /**
  21745. * Creates a new index buffer
  21746. * @param indices defines the indices to store in the index buffer
  21747. * @param totalVertices defines the total number of vertices (could be null)
  21748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21749. */
  21750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21751. }
  21752. /**
  21753. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21754. */
  21755. export class VertexData {
  21756. /**
  21757. * Mesh side orientation : usually the external or front surface
  21758. */
  21759. static readonly FRONTSIDE: number;
  21760. /**
  21761. * Mesh side orientation : usually the internal or back surface
  21762. */
  21763. static readonly BACKSIDE: number;
  21764. /**
  21765. * Mesh side orientation : both internal and external or front and back surfaces
  21766. */
  21767. static readonly DOUBLESIDE: number;
  21768. /**
  21769. * Mesh side orientation : by default, `FRONTSIDE`
  21770. */
  21771. static readonly DEFAULTSIDE: number;
  21772. /**
  21773. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21774. */
  21775. positions: Nullable<FloatArray>;
  21776. /**
  21777. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21778. */
  21779. normals: Nullable<FloatArray>;
  21780. /**
  21781. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21782. */
  21783. tangents: Nullable<FloatArray>;
  21784. /**
  21785. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs: Nullable<FloatArray>;
  21788. /**
  21789. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21790. */
  21791. uvs2: Nullable<FloatArray>;
  21792. /**
  21793. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21794. */
  21795. uvs3: Nullable<FloatArray>;
  21796. /**
  21797. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21798. */
  21799. uvs4: Nullable<FloatArray>;
  21800. /**
  21801. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21802. */
  21803. uvs5: Nullable<FloatArray>;
  21804. /**
  21805. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21806. */
  21807. uvs6: Nullable<FloatArray>;
  21808. /**
  21809. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21810. */
  21811. colors: Nullable<FloatArray>;
  21812. /**
  21813. * 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).
  21814. */
  21815. matricesIndices: Nullable<FloatArray>;
  21816. /**
  21817. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21818. */
  21819. matricesWeights: Nullable<FloatArray>;
  21820. /**
  21821. * An array extending the number of possible indices
  21822. */
  21823. matricesIndicesExtra: Nullable<FloatArray>;
  21824. /**
  21825. * An array extending the number of possible weights when the number of indices is extended
  21826. */
  21827. matricesWeightsExtra: Nullable<FloatArray>;
  21828. /**
  21829. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21830. */
  21831. indices: Nullable<IndicesArray>;
  21832. /**
  21833. * Uses the passed data array to set the set the values for the specified kind of data
  21834. * @param data a linear array of floating numbers
  21835. * @param kind the type of data that is being set, eg positions, colors etc
  21836. */
  21837. set(data: FloatArray, kind: string): void;
  21838. /**
  21839. * Associates the vertexData to the passed Mesh.
  21840. * Sets it as updatable or not (default `false`)
  21841. * @param mesh the mesh the vertexData is applied to
  21842. * @param updatable when used and having the value true allows new data to update the vertexData
  21843. * @returns the VertexData
  21844. */
  21845. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21846. /**
  21847. * Associates the vertexData to the passed Geometry.
  21848. * Sets it as updatable or not (default `false`)
  21849. * @param geometry the geometry the vertexData is applied to
  21850. * @param updatable when used and having the value true allows new data to update the vertexData
  21851. * @returns VertexData
  21852. */
  21853. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21854. /**
  21855. * Updates the associated mesh
  21856. * @param mesh the mesh to be updated
  21857. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21858. * @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
  21859. * @returns VertexData
  21860. */
  21861. updateMesh(mesh: Mesh): VertexData;
  21862. /**
  21863. * Updates the associated geometry
  21864. * @param geometry the geometry to be updated
  21865. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21866. * @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
  21867. * @returns VertexData.
  21868. */
  21869. updateGeometry(geometry: Geometry): VertexData;
  21870. private _applyTo;
  21871. private _update;
  21872. /**
  21873. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21874. * @param matrix the transforming matrix
  21875. * @returns the VertexData
  21876. */
  21877. transform(matrix: Matrix): VertexData;
  21878. /**
  21879. * Merges the passed VertexData into the current one
  21880. * @param other the VertexData to be merged into the current one
  21881. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21882. * @returns the modified VertexData
  21883. */
  21884. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21885. private _mergeElement;
  21886. private _validate;
  21887. /**
  21888. * Serializes the VertexData
  21889. * @returns a serialized object
  21890. */
  21891. serialize(): any;
  21892. /**
  21893. * Extracts the vertexData from a mesh
  21894. * @param mesh the mesh from which to extract the VertexData
  21895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21897. * @returns the object VertexData associated to the passed mesh
  21898. */
  21899. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21900. /**
  21901. * Extracts the vertexData from the geometry
  21902. * @param geometry the geometry from which to extract the VertexData
  21903. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21905. * @returns the object VertexData associated to the passed mesh
  21906. */
  21907. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21908. private static _ExtractFrom;
  21909. /**
  21910. * Creates the VertexData for a Ribbon
  21911. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21912. * * pathArray array of paths, each of which an array of successive Vector3
  21913. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21914. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21915. * * 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
  21916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21917. * * 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)
  21918. * * 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)
  21919. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21920. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21921. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21922. * @returns the VertexData of the ribbon
  21923. */
  21924. static CreateRibbon(options: {
  21925. pathArray: Vector3[][];
  21926. closeArray?: boolean;
  21927. closePath?: boolean;
  21928. offset?: number;
  21929. sideOrientation?: number;
  21930. frontUVs?: Vector4;
  21931. backUVs?: Vector4;
  21932. invertUV?: boolean;
  21933. uvs?: Vector2[];
  21934. colors?: Color4[];
  21935. }): VertexData;
  21936. /**
  21937. * Creates the VertexData for a box
  21938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21939. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21940. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21941. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21942. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21943. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21944. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21946. * * 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)
  21947. * * 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)
  21948. * @returns the VertexData of the box
  21949. */
  21950. static CreateBox(options: {
  21951. size?: number;
  21952. width?: number;
  21953. height?: number;
  21954. depth?: number;
  21955. faceUV?: Vector4[];
  21956. faceColors?: Color4[];
  21957. sideOrientation?: number;
  21958. frontUVs?: Vector4;
  21959. backUVs?: Vector4;
  21960. }): VertexData;
  21961. /**
  21962. * Creates the VertexData for a tiled box
  21963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * @returns the VertexData of the box
  21969. */
  21970. static CreateTiledBox(options: {
  21971. pattern?: number;
  21972. width?: number;
  21973. height?: number;
  21974. depth?: number;
  21975. tileSize?: number;
  21976. tileWidth?: number;
  21977. tileHeight?: number;
  21978. alignHorizontal?: number;
  21979. alignVertical?: number;
  21980. faceUV?: Vector4[];
  21981. faceColors?: Color4[];
  21982. sideOrientation?: number;
  21983. }): VertexData;
  21984. /**
  21985. * Creates the VertexData for a tiled plane
  21986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21987. * * pattern a limited pattern arrangement depending on the number
  21988. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21989. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21990. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21992. * * 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)
  21993. * * 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)
  21994. * @returns the VertexData of the tiled plane
  21995. */
  21996. static CreateTiledPlane(options: {
  21997. pattern?: number;
  21998. tileSize?: number;
  21999. tileWidth?: number;
  22000. tileHeight?: number;
  22001. size?: number;
  22002. width?: number;
  22003. height?: number;
  22004. alignHorizontal?: number;
  22005. alignVertical?: number;
  22006. sideOrientation?: number;
  22007. frontUVs?: Vector4;
  22008. backUVs?: Vector4;
  22009. }): VertexData;
  22010. /**
  22011. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22013. * * segments sets the number of horizontal strips optional, default 32
  22014. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22015. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22016. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22017. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22018. * * 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
  22019. * * 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
  22020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22021. * * 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)
  22022. * * 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)
  22023. * @returns the VertexData of the ellipsoid
  22024. */
  22025. static CreateSphere(options: {
  22026. segments?: number;
  22027. diameter?: number;
  22028. diameterX?: number;
  22029. diameterY?: number;
  22030. diameterZ?: number;
  22031. arc?: number;
  22032. slice?: number;
  22033. sideOrientation?: number;
  22034. frontUVs?: Vector4;
  22035. backUVs?: Vector4;
  22036. }): VertexData;
  22037. /**
  22038. * Creates the VertexData for a cylinder, cone or prism
  22039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22040. * * height sets the height (y direction) of the cylinder, optional, default 2
  22041. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22042. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22043. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22044. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22045. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22046. * * 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
  22047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22049. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22050. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22052. * * 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)
  22053. * * 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)
  22054. * @returns the VertexData of the cylinder, cone or prism
  22055. */
  22056. static CreateCylinder(options: {
  22057. height?: number;
  22058. diameterTop?: number;
  22059. diameterBottom?: number;
  22060. diameter?: number;
  22061. tessellation?: number;
  22062. subdivisions?: number;
  22063. arc?: number;
  22064. faceColors?: Color4[];
  22065. faceUV?: Vector4[];
  22066. hasRings?: boolean;
  22067. enclose?: boolean;
  22068. sideOrientation?: number;
  22069. frontUVs?: Vector4;
  22070. backUVs?: Vector4;
  22071. }): VertexData;
  22072. /**
  22073. * Creates the VertexData for a torus
  22074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22075. * * diameter the diameter of the torus, optional default 1
  22076. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22079. * * 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)
  22080. * * 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)
  22081. * @returns the VertexData of the torus
  22082. */
  22083. static CreateTorus(options: {
  22084. diameter?: number;
  22085. thickness?: number;
  22086. tessellation?: number;
  22087. sideOrientation?: number;
  22088. frontUVs?: Vector4;
  22089. backUVs?: Vector4;
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData of the LineSystem
  22093. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22094. * - lines an array of lines, each line being an array of successive Vector3
  22095. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22096. * @returns the VertexData of the LineSystem
  22097. */
  22098. static CreateLineSystem(options: {
  22099. lines: Vector3[][];
  22100. colors?: Nullable<Color4[][]>;
  22101. }): VertexData;
  22102. /**
  22103. * Create the VertexData for a DashedLines
  22104. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22105. * - points an array successive Vector3
  22106. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22107. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22108. * - dashNb the intended total number of dashes, optional, default 200
  22109. * @returns the VertexData for the DashedLines
  22110. */
  22111. static CreateDashedLines(options: {
  22112. points: Vector3[];
  22113. dashSize?: number;
  22114. gapSize?: number;
  22115. dashNb?: number;
  22116. }): VertexData;
  22117. /**
  22118. * Creates the VertexData for a Ground
  22119. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22120. * - width the width (x direction) of the ground, optional, default 1
  22121. * - height the height (z direction) of the ground, optional, default 1
  22122. * - subdivisions the number of subdivisions per side, optional, default 1
  22123. * @returns the VertexData of the Ground
  22124. */
  22125. static CreateGround(options: {
  22126. width?: number;
  22127. height?: number;
  22128. subdivisions?: number;
  22129. subdivisionsX?: number;
  22130. subdivisionsY?: number;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22135. * * xmin the ground minimum X coordinate, optional, default -1
  22136. * * zmin the ground minimum Z coordinate, optional, default -1
  22137. * * xmax the ground maximum X coordinate, optional, default 1
  22138. * * zmax the ground maximum Z coordinate, optional, default 1
  22139. * * 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}
  22140. * * 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}
  22141. * @returns the VertexData of the TiledGround
  22142. */
  22143. static CreateTiledGround(options: {
  22144. xmin: number;
  22145. zmin: number;
  22146. xmax: number;
  22147. zmax: number;
  22148. subdivisions?: {
  22149. w: number;
  22150. h: number;
  22151. };
  22152. precision?: {
  22153. w: number;
  22154. h: number;
  22155. };
  22156. }): VertexData;
  22157. /**
  22158. * Creates the VertexData of the Ground designed from a heightmap
  22159. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22160. * * width the width (x direction) of the ground
  22161. * * height the height (z direction) of the ground
  22162. * * subdivisions the number of subdivisions per side
  22163. * * minHeight the minimum altitude on the ground, optional, default 0
  22164. * * maxHeight the maximum altitude on the ground, optional default 1
  22165. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22166. * * buffer the array holding the image color data
  22167. * * bufferWidth the width of image
  22168. * * bufferHeight the height of image
  22169. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22170. * @returns the VertexData of the Ground designed from a heightmap
  22171. */
  22172. static CreateGroundFromHeightMap(options: {
  22173. width: number;
  22174. height: number;
  22175. subdivisions: number;
  22176. minHeight: number;
  22177. maxHeight: number;
  22178. colorFilter: Color3;
  22179. buffer: Uint8Array;
  22180. bufferWidth: number;
  22181. bufferHeight: number;
  22182. alphaFilter: number;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a Plane
  22186. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22187. * * size sets the width and height of the plane to the value of size, optional default 1
  22188. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22189. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * * 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)
  22192. * * 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)
  22193. * @returns the VertexData of the box
  22194. */
  22195. static CreatePlane(options: {
  22196. size?: number;
  22197. width?: number;
  22198. height?: number;
  22199. sideOrientation?: number;
  22200. frontUVs?: Vector4;
  22201. backUVs?: Vector4;
  22202. }): VertexData;
  22203. /**
  22204. * Creates the VertexData of the Disc or regular Polygon
  22205. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22206. * * radius the radius of the disc, optional default 0.5
  22207. * * tessellation the number of polygon sides, optional, default 64
  22208. * * 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
  22209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22210. * * 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)
  22211. * * 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)
  22212. * @returns the VertexData of the box
  22213. */
  22214. static CreateDisc(options: {
  22215. radius?: number;
  22216. tessellation?: number;
  22217. arc?: number;
  22218. sideOrientation?: number;
  22219. frontUVs?: Vector4;
  22220. backUVs?: Vector4;
  22221. }): VertexData;
  22222. /**
  22223. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22224. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22225. * @param polygon a mesh built from polygonTriangulation.build()
  22226. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22227. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22228. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22229. * @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)
  22230. * @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)
  22231. * @returns the VertexData of the Polygon
  22232. */
  22233. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22234. /**
  22235. * Creates the VertexData of the IcoSphere
  22236. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22237. * * radius the radius of the IcoSphere, optional default 1
  22238. * * radiusX allows stretching in the x direction, optional, default radius
  22239. * * radiusY allows stretching in the y direction, optional, default radius
  22240. * * radiusZ allows stretching in the z direction, optional, default radius
  22241. * * flat when true creates a flat shaded mesh, optional, default true
  22242. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * 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)
  22245. * * 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)
  22246. * @returns the VertexData of the IcoSphere
  22247. */
  22248. static CreateIcoSphere(options: {
  22249. radius?: number;
  22250. radiusX?: number;
  22251. radiusY?: number;
  22252. radiusZ?: number;
  22253. flat?: boolean;
  22254. subdivisions?: number;
  22255. sideOrientation?: number;
  22256. frontUVs?: Vector4;
  22257. backUVs?: Vector4;
  22258. }): VertexData;
  22259. /**
  22260. * Creates the VertexData for a Polyhedron
  22261. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22262. * * type provided types are:
  22263. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22264. * * 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)
  22265. * * size the size of the IcoSphere, optional default 1
  22266. * * sizeX allows stretching in the x direction, optional, default size
  22267. * * sizeY allows stretching in the y direction, optional, default size
  22268. * * sizeZ allows stretching in the z direction, optional, default size
  22269. * * 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
  22270. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22271. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22272. * * flat when true creates a flat shaded mesh, optional, default true
  22273. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the Polyhedron
  22278. */
  22279. static CreatePolyhedron(options: {
  22280. type?: number;
  22281. size?: number;
  22282. sizeX?: number;
  22283. sizeY?: number;
  22284. sizeZ?: number;
  22285. custom?: any;
  22286. faceUV?: Vector4[];
  22287. faceColors?: Color4[];
  22288. flat?: boolean;
  22289. sideOrientation?: number;
  22290. frontUVs?: Vector4;
  22291. backUVs?: Vector4;
  22292. }): VertexData;
  22293. /**
  22294. * Creates the VertexData for a TorusKnot
  22295. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22296. * * radius the radius of the torus knot, optional, default 2
  22297. * * tube the thickness of the tube, optional, default 0.5
  22298. * * radialSegments the number of sides on each tube segments, optional, default 32
  22299. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22300. * * p the number of windings around the z axis, optional, default 2
  22301. * * q the number of windings around the x axis, optional, default 3
  22302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22303. * * 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)
  22304. * * 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)
  22305. * @returns the VertexData of the Torus Knot
  22306. */
  22307. static CreateTorusKnot(options: {
  22308. radius?: number;
  22309. tube?: number;
  22310. radialSegments?: number;
  22311. tubularSegments?: number;
  22312. p?: number;
  22313. q?: number;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Compute normals for given positions and indices
  22320. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22321. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22322. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22323. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22324. * * facetNormals : optional array of facet normals (vector3)
  22325. * * facetPositions : optional array of facet positions (vector3)
  22326. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22327. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22328. * * bInfo : optional bounding info, required for facetPartitioning computation
  22329. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22330. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22331. * * useRightHandedSystem: optional boolean to for right handed system computation
  22332. * * depthSort : optional boolean to enable the facet depth sort computation
  22333. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22334. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22335. */
  22336. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22337. facetNormals?: any;
  22338. facetPositions?: any;
  22339. facetPartitioning?: any;
  22340. ratio?: number;
  22341. bInfo?: any;
  22342. bbSize?: Vector3;
  22343. subDiv?: any;
  22344. useRightHandedSystem?: boolean;
  22345. depthSort?: boolean;
  22346. distanceTo?: Vector3;
  22347. depthSortedFacets?: any;
  22348. }): void;
  22349. /** @hidden */
  22350. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22351. /**
  22352. * Applies VertexData created from the imported parameters to the geometry
  22353. * @param parsedVertexData the parsed data from an imported file
  22354. * @param geometry the geometry to apply the VertexData to
  22355. */
  22356. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22357. }
  22358. }
  22359. declare module "babylonjs/Morph/morphTarget" {
  22360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22361. import { Observable } from "babylonjs/Misc/observable";
  22362. import { Nullable, FloatArray } from "babylonjs/types";
  22363. import { Scene } from "babylonjs/scene";
  22364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22365. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22366. /**
  22367. * Defines a target to use with MorphTargetManager
  22368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22369. */
  22370. export class MorphTarget implements IAnimatable {
  22371. /** defines the name of the target */
  22372. name: string;
  22373. /**
  22374. * Gets or sets the list of animations
  22375. */
  22376. animations: import("babylonjs/Animations/animation").Animation[];
  22377. private _scene;
  22378. private _positions;
  22379. private _normals;
  22380. private _tangents;
  22381. private _uvs;
  22382. private _influence;
  22383. /**
  22384. * Observable raised when the influence changes
  22385. */
  22386. onInfluenceChanged: Observable<boolean>;
  22387. /** @hidden */
  22388. _onDataLayoutChanged: Observable<void>;
  22389. /**
  22390. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22391. */
  22392. influence: number;
  22393. /**
  22394. * Gets or sets the id of the morph Target
  22395. */
  22396. id: string;
  22397. private _animationPropertiesOverride;
  22398. /**
  22399. * Gets or sets the animation properties override
  22400. */
  22401. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22402. /**
  22403. * Creates a new MorphTarget
  22404. * @param name defines the name of the target
  22405. * @param influence defines the influence to use
  22406. * @param scene defines the scene the morphtarget belongs to
  22407. */
  22408. constructor(
  22409. /** defines the name of the target */
  22410. name: string, influence?: number, scene?: Nullable<Scene>);
  22411. /**
  22412. * Gets a boolean defining if the target contains position data
  22413. */
  22414. readonly hasPositions: boolean;
  22415. /**
  22416. * Gets a boolean defining if the target contains normal data
  22417. */
  22418. readonly hasNormals: boolean;
  22419. /**
  22420. * Gets a boolean defining if the target contains tangent data
  22421. */
  22422. readonly hasTangents: boolean;
  22423. /**
  22424. * Gets a boolean defining if the target contains texture coordinates data
  22425. */
  22426. readonly hasUVs: boolean;
  22427. /**
  22428. * Affects position data to this target
  22429. * @param data defines the position data to use
  22430. */
  22431. setPositions(data: Nullable<FloatArray>): void;
  22432. /**
  22433. * Gets the position data stored in this target
  22434. * @returns a FloatArray containing the position data (or null if not present)
  22435. */
  22436. getPositions(): Nullable<FloatArray>;
  22437. /**
  22438. * Affects normal data to this target
  22439. * @param data defines the normal data to use
  22440. */
  22441. setNormals(data: Nullable<FloatArray>): void;
  22442. /**
  22443. * Gets the normal data stored in this target
  22444. * @returns a FloatArray containing the normal data (or null if not present)
  22445. */
  22446. getNormals(): Nullable<FloatArray>;
  22447. /**
  22448. * Affects tangent data to this target
  22449. * @param data defines the tangent data to use
  22450. */
  22451. setTangents(data: Nullable<FloatArray>): void;
  22452. /**
  22453. * Gets the tangent data stored in this target
  22454. * @returns a FloatArray containing the tangent data (or null if not present)
  22455. */
  22456. getTangents(): Nullable<FloatArray>;
  22457. /**
  22458. * Affects texture coordinates data to this target
  22459. * @param data defines the texture coordinates data to use
  22460. */
  22461. setUVs(data: Nullable<FloatArray>): void;
  22462. /**
  22463. * Gets the texture coordinates data stored in this target
  22464. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22465. */
  22466. getUVs(): Nullable<FloatArray>;
  22467. /**
  22468. * Serializes the current target into a Serialization object
  22469. * @returns the serialized object
  22470. */
  22471. serialize(): any;
  22472. /**
  22473. * Returns the string "MorphTarget"
  22474. * @returns "MorphTarget"
  22475. */
  22476. getClassName(): string;
  22477. /**
  22478. * Creates a new target from serialized data
  22479. * @param serializationObject defines the serialized data to use
  22480. * @returns a new MorphTarget
  22481. */
  22482. static Parse(serializationObject: any): MorphTarget;
  22483. /**
  22484. * Creates a MorphTarget from mesh data
  22485. * @param mesh defines the source mesh
  22486. * @param name defines the name to use for the new target
  22487. * @param influence defines the influence to attach to the target
  22488. * @returns a new MorphTarget
  22489. */
  22490. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22491. }
  22492. }
  22493. declare module "babylonjs/Morph/morphTargetManager" {
  22494. import { Nullable } from "babylonjs/types";
  22495. import { Scene } from "babylonjs/scene";
  22496. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22497. /**
  22498. * This class is used to deform meshes using morphing between different targets
  22499. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22500. */
  22501. export class MorphTargetManager {
  22502. private _targets;
  22503. private _targetInfluenceChangedObservers;
  22504. private _targetDataLayoutChangedObservers;
  22505. private _activeTargets;
  22506. private _scene;
  22507. private _influences;
  22508. private _supportsNormals;
  22509. private _supportsTangents;
  22510. private _supportsUVs;
  22511. private _vertexCount;
  22512. private _uniqueId;
  22513. private _tempInfluences;
  22514. /**
  22515. * Gets or sets a boolean indicating if normals must be morphed
  22516. */
  22517. enableNormalMorphing: boolean;
  22518. /**
  22519. * Gets or sets a boolean indicating if tangents must be morphed
  22520. */
  22521. enableTangentMorphing: boolean;
  22522. /**
  22523. * Gets or sets a boolean indicating if UV must be morphed
  22524. */
  22525. enableUVMorphing: boolean;
  22526. /**
  22527. * Creates a new MorphTargetManager
  22528. * @param scene defines the current scene
  22529. */
  22530. constructor(scene?: Nullable<Scene>);
  22531. /**
  22532. * Gets the unique ID of this manager
  22533. */
  22534. readonly uniqueId: number;
  22535. /**
  22536. * Gets the number of vertices handled by this manager
  22537. */
  22538. readonly vertexCount: number;
  22539. /**
  22540. * Gets a boolean indicating if this manager supports morphing of normals
  22541. */
  22542. readonly supportsNormals: boolean;
  22543. /**
  22544. * Gets a boolean indicating if this manager supports morphing of tangents
  22545. */
  22546. readonly supportsTangents: boolean;
  22547. /**
  22548. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22549. */
  22550. readonly supportsUVs: boolean;
  22551. /**
  22552. * Gets the number of targets stored in this manager
  22553. */
  22554. readonly numTargets: number;
  22555. /**
  22556. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22557. */
  22558. readonly numInfluencers: number;
  22559. /**
  22560. * Gets the list of influences (one per target)
  22561. */
  22562. readonly influences: Float32Array;
  22563. /**
  22564. * Gets the active target at specified index. An active target is a target with an influence > 0
  22565. * @param index defines the index to check
  22566. * @returns the requested target
  22567. */
  22568. getActiveTarget(index: number): MorphTarget;
  22569. /**
  22570. * Gets the target at specified index
  22571. * @param index defines the index to check
  22572. * @returns the requested target
  22573. */
  22574. getTarget(index: number): MorphTarget;
  22575. /**
  22576. * Add a new target to this manager
  22577. * @param target defines the target to add
  22578. */
  22579. addTarget(target: MorphTarget): void;
  22580. /**
  22581. * Removes a target from the manager
  22582. * @param target defines the target to remove
  22583. */
  22584. removeTarget(target: MorphTarget): void;
  22585. /**
  22586. * Serializes the current manager into a Serialization object
  22587. * @returns the serialized object
  22588. */
  22589. serialize(): any;
  22590. private _syncActiveTargets;
  22591. /**
  22592. * Syncrhonize the targets with all the meshes using this morph target manager
  22593. */
  22594. synchronize(): void;
  22595. /**
  22596. * Creates a new MorphTargetManager from serialized data
  22597. * @param serializationObject defines the serialized data
  22598. * @param scene defines the hosting scene
  22599. * @returns the new MorphTargetManager
  22600. */
  22601. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22602. }
  22603. }
  22604. declare module "babylonjs/Meshes/meshLODLevel" {
  22605. import { Mesh } from "babylonjs/Meshes/mesh";
  22606. import { Nullable } from "babylonjs/types";
  22607. /**
  22608. * Class used to represent a specific level of detail of a mesh
  22609. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22610. */
  22611. export class MeshLODLevel {
  22612. /** Defines the distance where this level should star being displayed */
  22613. distance: number;
  22614. /** Defines the mesh to use to render this level */
  22615. mesh: Nullable<Mesh>;
  22616. /**
  22617. * Creates a new LOD level
  22618. * @param distance defines the distance where this level should star being displayed
  22619. * @param mesh defines the mesh to use to render this level
  22620. */
  22621. constructor(
  22622. /** Defines the distance where this level should star being displayed */
  22623. distance: number,
  22624. /** Defines the mesh to use to render this level */
  22625. mesh: Nullable<Mesh>);
  22626. }
  22627. }
  22628. declare module "babylonjs/Meshes/groundMesh" {
  22629. import { Scene } from "babylonjs/scene";
  22630. import { Vector3 } from "babylonjs/Maths/math.vector";
  22631. import { Mesh } from "babylonjs/Meshes/mesh";
  22632. /**
  22633. * Mesh representing the gorund
  22634. */
  22635. export class GroundMesh extends Mesh {
  22636. /** If octree should be generated */
  22637. generateOctree: boolean;
  22638. private _heightQuads;
  22639. /** @hidden */
  22640. _subdivisionsX: number;
  22641. /** @hidden */
  22642. _subdivisionsY: number;
  22643. /** @hidden */
  22644. _width: number;
  22645. /** @hidden */
  22646. _height: number;
  22647. /** @hidden */
  22648. _minX: number;
  22649. /** @hidden */
  22650. _maxX: number;
  22651. /** @hidden */
  22652. _minZ: number;
  22653. /** @hidden */
  22654. _maxZ: number;
  22655. constructor(name: string, scene: Scene);
  22656. /**
  22657. * "GroundMesh"
  22658. * @returns "GroundMesh"
  22659. */
  22660. getClassName(): string;
  22661. /**
  22662. * The minimum of x and y subdivisions
  22663. */
  22664. readonly subdivisions: number;
  22665. /**
  22666. * X subdivisions
  22667. */
  22668. readonly subdivisionsX: number;
  22669. /**
  22670. * Y subdivisions
  22671. */
  22672. readonly subdivisionsY: number;
  22673. /**
  22674. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22675. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22676. * @param chunksCount the number of subdivisions for x and y
  22677. * @param octreeBlocksSize (Default: 32)
  22678. */
  22679. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22680. /**
  22681. * Returns a height (y) value in the Worl system :
  22682. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22683. * @param x x coordinate
  22684. * @param z z coordinate
  22685. * @returns the ground y position if (x, z) are outside the ground surface.
  22686. */
  22687. getHeightAtCoordinates(x: number, z: number): number;
  22688. /**
  22689. * Returns a normalized vector (Vector3) orthogonal to the ground
  22690. * at the ground coordinates (x, z) expressed in the World system.
  22691. * @param x x coordinate
  22692. * @param z z coordinate
  22693. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22694. */
  22695. getNormalAtCoordinates(x: number, z: number): Vector3;
  22696. /**
  22697. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22698. * at the ground coordinates (x, z) expressed in the World system.
  22699. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22700. * @param x x coordinate
  22701. * @param z z coordinate
  22702. * @param ref vector to store the result
  22703. * @returns the GroundMesh.
  22704. */
  22705. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22706. /**
  22707. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22708. * if the ground has been updated.
  22709. * This can be used in the render loop.
  22710. * @returns the GroundMesh.
  22711. */
  22712. updateCoordinateHeights(): GroundMesh;
  22713. private _getFacetAt;
  22714. private _initHeightQuads;
  22715. private _computeHeightQuads;
  22716. /**
  22717. * Serializes this ground mesh
  22718. * @param serializationObject object to write serialization to
  22719. */
  22720. serialize(serializationObject: any): void;
  22721. /**
  22722. * Parses a serialized ground mesh
  22723. * @param parsedMesh the serialized mesh
  22724. * @param scene the scene to create the ground mesh in
  22725. * @returns the created ground mesh
  22726. */
  22727. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22728. }
  22729. }
  22730. declare module "babylonjs/Physics/physicsJoint" {
  22731. import { Vector3 } from "babylonjs/Maths/math.vector";
  22732. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22733. /**
  22734. * Interface for Physics-Joint data
  22735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22736. */
  22737. export interface PhysicsJointData {
  22738. /**
  22739. * The main pivot of the joint
  22740. */
  22741. mainPivot?: Vector3;
  22742. /**
  22743. * The connected pivot of the joint
  22744. */
  22745. connectedPivot?: Vector3;
  22746. /**
  22747. * The main axis of the joint
  22748. */
  22749. mainAxis?: Vector3;
  22750. /**
  22751. * The connected axis of the joint
  22752. */
  22753. connectedAxis?: Vector3;
  22754. /**
  22755. * The collision of the joint
  22756. */
  22757. collision?: boolean;
  22758. /**
  22759. * Native Oimo/Cannon/Energy data
  22760. */
  22761. nativeParams?: any;
  22762. }
  22763. /**
  22764. * This is a holder class for the physics joint created by the physics plugin
  22765. * It holds a set of functions to control the underlying joint
  22766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22767. */
  22768. export class PhysicsJoint {
  22769. /**
  22770. * The type of the physics joint
  22771. */
  22772. type: number;
  22773. /**
  22774. * The data for the physics joint
  22775. */
  22776. jointData: PhysicsJointData;
  22777. private _physicsJoint;
  22778. protected _physicsPlugin: IPhysicsEnginePlugin;
  22779. /**
  22780. * Initializes the physics joint
  22781. * @param type The type of the physics joint
  22782. * @param jointData The data for the physics joint
  22783. */
  22784. constructor(
  22785. /**
  22786. * The type of the physics joint
  22787. */
  22788. type: number,
  22789. /**
  22790. * The data for the physics joint
  22791. */
  22792. jointData: PhysicsJointData);
  22793. /**
  22794. * Gets the physics joint
  22795. */
  22796. /**
  22797. * Sets the physics joint
  22798. */
  22799. physicsJoint: any;
  22800. /**
  22801. * Sets the physics plugin
  22802. */
  22803. physicsPlugin: IPhysicsEnginePlugin;
  22804. /**
  22805. * Execute a function that is physics-plugin specific.
  22806. * @param {Function} func the function that will be executed.
  22807. * It accepts two parameters: the physics world and the physics joint
  22808. */
  22809. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22810. /**
  22811. * Distance-Joint type
  22812. */
  22813. static DistanceJoint: number;
  22814. /**
  22815. * Hinge-Joint type
  22816. */
  22817. static HingeJoint: number;
  22818. /**
  22819. * Ball-and-Socket joint type
  22820. */
  22821. static BallAndSocketJoint: number;
  22822. /**
  22823. * Wheel-Joint type
  22824. */
  22825. static WheelJoint: number;
  22826. /**
  22827. * Slider-Joint type
  22828. */
  22829. static SliderJoint: number;
  22830. /**
  22831. * Prismatic-Joint type
  22832. */
  22833. static PrismaticJoint: number;
  22834. /**
  22835. * Universal-Joint type
  22836. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22837. */
  22838. static UniversalJoint: number;
  22839. /**
  22840. * Hinge-Joint 2 type
  22841. */
  22842. static Hinge2Joint: number;
  22843. /**
  22844. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22845. */
  22846. static PointToPointJoint: number;
  22847. /**
  22848. * Spring-Joint type
  22849. */
  22850. static SpringJoint: number;
  22851. /**
  22852. * Lock-Joint type
  22853. */
  22854. static LockJoint: number;
  22855. }
  22856. /**
  22857. * A class representing a physics distance joint
  22858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22859. */
  22860. export class DistanceJoint extends PhysicsJoint {
  22861. /**
  22862. *
  22863. * @param jointData The data for the Distance-Joint
  22864. */
  22865. constructor(jointData: DistanceJointData);
  22866. /**
  22867. * Update the predefined distance.
  22868. * @param maxDistance The maximum preferred distance
  22869. * @param minDistance The minimum preferred distance
  22870. */
  22871. updateDistance(maxDistance: number, minDistance?: number): void;
  22872. }
  22873. /**
  22874. * Represents a Motor-Enabled Joint
  22875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22876. */
  22877. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22878. /**
  22879. * Initializes the Motor-Enabled Joint
  22880. * @param type The type of the joint
  22881. * @param jointData The physica joint data for the joint
  22882. */
  22883. constructor(type: number, jointData: PhysicsJointData);
  22884. /**
  22885. * Set the motor values.
  22886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22887. * @param force the force to apply
  22888. * @param maxForce max force for this motor.
  22889. */
  22890. setMotor(force?: number, maxForce?: number): void;
  22891. /**
  22892. * Set the motor's limits.
  22893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22894. * @param upperLimit The upper limit of the motor
  22895. * @param lowerLimit The lower limit of the motor
  22896. */
  22897. setLimit(upperLimit: number, lowerLimit?: number): void;
  22898. }
  22899. /**
  22900. * This class represents a single physics Hinge-Joint
  22901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22902. */
  22903. export class HingeJoint extends MotorEnabledJoint {
  22904. /**
  22905. * Initializes the Hinge-Joint
  22906. * @param jointData The joint data for the Hinge-Joint
  22907. */
  22908. constructor(jointData: PhysicsJointData);
  22909. /**
  22910. * Set the motor values.
  22911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22912. * @param {number} force the force to apply
  22913. * @param {number} maxForce max force for this motor.
  22914. */
  22915. setMotor(force?: number, maxForce?: number): void;
  22916. /**
  22917. * Set the motor's limits.
  22918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22919. * @param upperLimit The upper limit of the motor
  22920. * @param lowerLimit The lower limit of the motor
  22921. */
  22922. setLimit(upperLimit: number, lowerLimit?: number): void;
  22923. }
  22924. /**
  22925. * This class represents a dual hinge physics joint (same as wheel joint)
  22926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22927. */
  22928. export class Hinge2Joint extends MotorEnabledJoint {
  22929. /**
  22930. * Initializes the Hinge2-Joint
  22931. * @param jointData The joint data for the Hinge2-Joint
  22932. */
  22933. constructor(jointData: PhysicsJointData);
  22934. /**
  22935. * Set the motor values.
  22936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22937. * @param {number} targetSpeed the speed the motor is to reach
  22938. * @param {number} maxForce max force for this motor.
  22939. * @param {motorIndex} the motor's index, 0 or 1.
  22940. */
  22941. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22942. /**
  22943. * Set the motor limits.
  22944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22945. * @param {number} upperLimit the upper limit
  22946. * @param {number} lowerLimit lower limit
  22947. * @param {motorIndex} the motor's index, 0 or 1.
  22948. */
  22949. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22950. }
  22951. /**
  22952. * Interface for a motor enabled joint
  22953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22954. */
  22955. export interface IMotorEnabledJoint {
  22956. /**
  22957. * Physics joint
  22958. */
  22959. physicsJoint: any;
  22960. /**
  22961. * Sets the motor of the motor-enabled joint
  22962. * @param force The force of the motor
  22963. * @param maxForce The maximum force of the motor
  22964. * @param motorIndex The index of the motor
  22965. */
  22966. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22967. /**
  22968. * Sets the limit of the motor
  22969. * @param upperLimit The upper limit of the motor
  22970. * @param lowerLimit The lower limit of the motor
  22971. * @param motorIndex The index of the motor
  22972. */
  22973. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22974. }
  22975. /**
  22976. * Joint data for a Distance-Joint
  22977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22978. */
  22979. export interface DistanceJointData extends PhysicsJointData {
  22980. /**
  22981. * Max distance the 2 joint objects can be apart
  22982. */
  22983. maxDistance: number;
  22984. }
  22985. /**
  22986. * Joint data from a spring joint
  22987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22988. */
  22989. export interface SpringJointData extends PhysicsJointData {
  22990. /**
  22991. * Length of the spring
  22992. */
  22993. length: number;
  22994. /**
  22995. * Stiffness of the spring
  22996. */
  22997. stiffness: number;
  22998. /**
  22999. * Damping of the spring
  23000. */
  23001. damping: number;
  23002. /** this callback will be called when applying the force to the impostors. */
  23003. forceApplicationCallback: () => void;
  23004. }
  23005. }
  23006. declare module "babylonjs/Physics/physicsRaycastResult" {
  23007. import { Vector3 } from "babylonjs/Maths/math.vector";
  23008. /**
  23009. * Holds the data for the raycast result
  23010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23011. */
  23012. export class PhysicsRaycastResult {
  23013. private _hasHit;
  23014. private _hitDistance;
  23015. private _hitNormalWorld;
  23016. private _hitPointWorld;
  23017. private _rayFromWorld;
  23018. private _rayToWorld;
  23019. /**
  23020. * Gets if there was a hit
  23021. */
  23022. readonly hasHit: boolean;
  23023. /**
  23024. * Gets the distance from the hit
  23025. */
  23026. readonly hitDistance: number;
  23027. /**
  23028. * Gets the hit normal/direction in the world
  23029. */
  23030. readonly hitNormalWorld: Vector3;
  23031. /**
  23032. * Gets the hit point in the world
  23033. */
  23034. readonly hitPointWorld: Vector3;
  23035. /**
  23036. * Gets the ray "start point" of the ray in the world
  23037. */
  23038. readonly rayFromWorld: Vector3;
  23039. /**
  23040. * Gets the ray "end point" of the ray in the world
  23041. */
  23042. readonly rayToWorld: Vector3;
  23043. /**
  23044. * Sets the hit data (normal & point in world space)
  23045. * @param hitNormalWorld defines the normal in world space
  23046. * @param hitPointWorld defines the point in world space
  23047. */
  23048. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23049. /**
  23050. * Sets the distance from the start point to the hit point
  23051. * @param distance
  23052. */
  23053. setHitDistance(distance: number): void;
  23054. /**
  23055. * Calculates the distance manually
  23056. */
  23057. calculateHitDistance(): void;
  23058. /**
  23059. * Resets all the values to default
  23060. * @param from The from point on world space
  23061. * @param to The to point on world space
  23062. */
  23063. reset(from?: Vector3, to?: Vector3): void;
  23064. }
  23065. /**
  23066. * Interface for the size containing width and height
  23067. */
  23068. interface IXYZ {
  23069. /**
  23070. * X
  23071. */
  23072. x: number;
  23073. /**
  23074. * Y
  23075. */
  23076. y: number;
  23077. /**
  23078. * Z
  23079. */
  23080. z: number;
  23081. }
  23082. }
  23083. declare module "babylonjs/Physics/IPhysicsEngine" {
  23084. import { Nullable } from "babylonjs/types";
  23085. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23087. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23088. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23089. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23090. /**
  23091. * Interface used to describe a physics joint
  23092. */
  23093. export interface PhysicsImpostorJoint {
  23094. /** Defines the main impostor to which the joint is linked */
  23095. mainImpostor: PhysicsImpostor;
  23096. /** Defines the impostor that is connected to the main impostor using this joint */
  23097. connectedImpostor: PhysicsImpostor;
  23098. /** Defines the joint itself */
  23099. joint: PhysicsJoint;
  23100. }
  23101. /** @hidden */
  23102. export interface IPhysicsEnginePlugin {
  23103. world: any;
  23104. name: string;
  23105. setGravity(gravity: Vector3): void;
  23106. setTimeStep(timeStep: number): void;
  23107. getTimeStep(): number;
  23108. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23109. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23111. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23112. removePhysicsBody(impostor: PhysicsImpostor): void;
  23113. generateJoint(joint: PhysicsImpostorJoint): void;
  23114. removeJoint(joint: PhysicsImpostorJoint): void;
  23115. isSupported(): boolean;
  23116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23117. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23118. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23119. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23120. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23121. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23122. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23123. getBodyMass(impostor: PhysicsImpostor): number;
  23124. getBodyFriction(impostor: PhysicsImpostor): number;
  23125. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23126. getBodyRestitution(impostor: PhysicsImpostor): number;
  23127. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23128. getBodyPressure?(impostor: PhysicsImpostor): number;
  23129. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23130. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23131. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23132. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23133. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23134. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23135. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23136. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23137. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23138. sleepBody(impostor: PhysicsImpostor): void;
  23139. wakeUpBody(impostor: PhysicsImpostor): void;
  23140. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23142. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23143. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23144. getRadius(impostor: PhysicsImpostor): number;
  23145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23147. dispose(): void;
  23148. }
  23149. /**
  23150. * Interface used to define a physics engine
  23151. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23152. */
  23153. export interface IPhysicsEngine {
  23154. /**
  23155. * Gets the gravity vector used by the simulation
  23156. */
  23157. gravity: Vector3;
  23158. /**
  23159. * Sets the gravity vector used by the simulation
  23160. * @param gravity defines the gravity vector to use
  23161. */
  23162. setGravity(gravity: Vector3): void;
  23163. /**
  23164. * Set the time step of the physics engine.
  23165. * Default is 1/60.
  23166. * To slow it down, enter 1/600 for example.
  23167. * To speed it up, 1/30
  23168. * @param newTimeStep the new timestep to apply to this world.
  23169. */
  23170. setTimeStep(newTimeStep: number): void;
  23171. /**
  23172. * Get the time step of the physics engine.
  23173. * @returns the current time step
  23174. */
  23175. getTimeStep(): number;
  23176. /**
  23177. * Release all resources
  23178. */
  23179. dispose(): void;
  23180. /**
  23181. * Gets the name of the current physics plugin
  23182. * @returns the name of the plugin
  23183. */
  23184. getPhysicsPluginName(): string;
  23185. /**
  23186. * Adding a new impostor for the impostor tracking.
  23187. * This will be done by the impostor itself.
  23188. * @param impostor the impostor to add
  23189. */
  23190. addImpostor(impostor: PhysicsImpostor): void;
  23191. /**
  23192. * Remove an impostor from the engine.
  23193. * This impostor and its mesh will not longer be updated by the physics engine.
  23194. * @param impostor the impostor to remove
  23195. */
  23196. removeImpostor(impostor: PhysicsImpostor): void;
  23197. /**
  23198. * Add a joint to the physics engine
  23199. * @param mainImpostor defines the main impostor to which the joint is added.
  23200. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23201. * @param joint defines the joint that will connect both impostors.
  23202. */
  23203. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23204. /**
  23205. * Removes a joint from the simulation
  23206. * @param mainImpostor defines the impostor used with the joint
  23207. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23208. * @param joint defines the joint to remove
  23209. */
  23210. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23211. /**
  23212. * Gets the current plugin used to run the simulation
  23213. * @returns current plugin
  23214. */
  23215. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23216. /**
  23217. * Gets the list of physic impostors
  23218. * @returns an array of PhysicsImpostor
  23219. */
  23220. getImpostors(): Array<PhysicsImpostor>;
  23221. /**
  23222. * Gets the impostor for a physics enabled object
  23223. * @param object defines the object impersonated by the impostor
  23224. * @returns the PhysicsImpostor or null if not found
  23225. */
  23226. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23227. /**
  23228. * Gets the impostor for a physics body object
  23229. * @param body defines physics body used by the impostor
  23230. * @returns the PhysicsImpostor or null if not found
  23231. */
  23232. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23233. /**
  23234. * Does a raycast in the physics world
  23235. * @param from when should the ray start?
  23236. * @param to when should the ray end?
  23237. * @returns PhysicsRaycastResult
  23238. */
  23239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23240. /**
  23241. * Called by the scene. No need to call it.
  23242. * @param delta defines the timespam between frames
  23243. */
  23244. _step(delta: number): void;
  23245. }
  23246. }
  23247. declare module "babylonjs/Physics/physicsImpostor" {
  23248. import { Nullable, IndicesArray } from "babylonjs/types";
  23249. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23252. import { Scene } from "babylonjs/scene";
  23253. import { Bone } from "babylonjs/Bones/bone";
  23254. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23255. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23256. import { Space } from "babylonjs/Maths/math.axis";
  23257. /**
  23258. * The interface for the physics imposter parameters
  23259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23260. */
  23261. export interface PhysicsImpostorParameters {
  23262. /**
  23263. * The mass of the physics imposter
  23264. */
  23265. mass: number;
  23266. /**
  23267. * The friction of the physics imposter
  23268. */
  23269. friction?: number;
  23270. /**
  23271. * The coefficient of restitution of the physics imposter
  23272. */
  23273. restitution?: number;
  23274. /**
  23275. * The native options of the physics imposter
  23276. */
  23277. nativeOptions?: any;
  23278. /**
  23279. * Specifies if the parent should be ignored
  23280. */
  23281. ignoreParent?: boolean;
  23282. /**
  23283. * Specifies if bi-directional transformations should be disabled
  23284. */
  23285. disableBidirectionalTransformation?: boolean;
  23286. /**
  23287. * The pressure inside the physics imposter, soft object only
  23288. */
  23289. pressure?: number;
  23290. /**
  23291. * The stiffness the physics imposter, soft object only
  23292. */
  23293. stiffness?: number;
  23294. /**
  23295. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23296. */
  23297. velocityIterations?: number;
  23298. /**
  23299. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23300. */
  23301. positionIterations?: number;
  23302. /**
  23303. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23304. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23305. * Add to fix multiple points
  23306. */
  23307. fixedPoints?: number;
  23308. /**
  23309. * The collision margin around a soft object
  23310. */
  23311. margin?: number;
  23312. /**
  23313. * The collision margin around a soft object
  23314. */
  23315. damping?: number;
  23316. /**
  23317. * The path for a rope based on an extrusion
  23318. */
  23319. path?: any;
  23320. /**
  23321. * The shape of an extrusion used for a rope based on an extrusion
  23322. */
  23323. shape?: any;
  23324. }
  23325. /**
  23326. * Interface for a physics-enabled object
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface IPhysicsEnabledObject {
  23330. /**
  23331. * The position of the physics-enabled object
  23332. */
  23333. position: Vector3;
  23334. /**
  23335. * The rotation of the physics-enabled object
  23336. */
  23337. rotationQuaternion: Nullable<Quaternion>;
  23338. /**
  23339. * The scale of the physics-enabled object
  23340. */
  23341. scaling: Vector3;
  23342. /**
  23343. * The rotation of the physics-enabled object
  23344. */
  23345. rotation?: Vector3;
  23346. /**
  23347. * The parent of the physics-enabled object
  23348. */
  23349. parent?: any;
  23350. /**
  23351. * The bounding info of the physics-enabled object
  23352. * @returns The bounding info of the physics-enabled object
  23353. */
  23354. getBoundingInfo(): BoundingInfo;
  23355. /**
  23356. * Computes the world matrix
  23357. * @param force Specifies if the world matrix should be computed by force
  23358. * @returns A world matrix
  23359. */
  23360. computeWorldMatrix(force: boolean): Matrix;
  23361. /**
  23362. * Gets the world matrix
  23363. * @returns A world matrix
  23364. */
  23365. getWorldMatrix?(): Matrix;
  23366. /**
  23367. * Gets the child meshes
  23368. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23369. * @returns An array of abstract meshes
  23370. */
  23371. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23372. /**
  23373. * Gets the vertex data
  23374. * @param kind The type of vertex data
  23375. * @returns A nullable array of numbers, or a float32 array
  23376. */
  23377. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23378. /**
  23379. * Gets the indices from the mesh
  23380. * @returns A nullable array of index arrays
  23381. */
  23382. getIndices?(): Nullable<IndicesArray>;
  23383. /**
  23384. * Gets the scene from the mesh
  23385. * @returns the indices array or null
  23386. */
  23387. getScene?(): Scene;
  23388. /**
  23389. * Gets the absolute position from the mesh
  23390. * @returns the absolute position
  23391. */
  23392. getAbsolutePosition(): Vector3;
  23393. /**
  23394. * Gets the absolute pivot point from the mesh
  23395. * @returns the absolute pivot point
  23396. */
  23397. getAbsolutePivotPoint(): Vector3;
  23398. /**
  23399. * Rotates the mesh
  23400. * @param axis The axis of rotation
  23401. * @param amount The amount of rotation
  23402. * @param space The space of the rotation
  23403. * @returns The rotation transform node
  23404. */
  23405. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23406. /**
  23407. * Translates the mesh
  23408. * @param axis The axis of translation
  23409. * @param distance The distance of translation
  23410. * @param space The space of the translation
  23411. * @returns The transform node
  23412. */
  23413. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23414. /**
  23415. * Sets the absolute position of the mesh
  23416. * @param absolutePosition The absolute position of the mesh
  23417. * @returns The transform node
  23418. */
  23419. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23420. /**
  23421. * Gets the class name of the mesh
  23422. * @returns The class name
  23423. */
  23424. getClassName(): string;
  23425. }
  23426. /**
  23427. * Represents a physics imposter
  23428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23429. */
  23430. export class PhysicsImpostor {
  23431. /**
  23432. * The physics-enabled object used as the physics imposter
  23433. */
  23434. object: IPhysicsEnabledObject;
  23435. /**
  23436. * The type of the physics imposter
  23437. */
  23438. type: number;
  23439. private _options;
  23440. private _scene?;
  23441. /**
  23442. * The default object size of the imposter
  23443. */
  23444. static DEFAULT_OBJECT_SIZE: Vector3;
  23445. /**
  23446. * The identity quaternion of the imposter
  23447. */
  23448. static IDENTITY_QUATERNION: Quaternion;
  23449. /** @hidden */
  23450. _pluginData: any;
  23451. private _physicsEngine;
  23452. private _physicsBody;
  23453. private _bodyUpdateRequired;
  23454. private _onBeforePhysicsStepCallbacks;
  23455. private _onAfterPhysicsStepCallbacks;
  23456. /** @hidden */
  23457. _onPhysicsCollideCallbacks: Array<{
  23458. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23459. otherImpostors: Array<PhysicsImpostor>;
  23460. }>;
  23461. private _deltaPosition;
  23462. private _deltaRotation;
  23463. private _deltaRotationConjugated;
  23464. /** @hidden */
  23465. _isFromLine: boolean;
  23466. private _parent;
  23467. private _isDisposed;
  23468. private static _tmpVecs;
  23469. private static _tmpQuat;
  23470. /**
  23471. * Specifies if the physics imposter is disposed
  23472. */
  23473. readonly isDisposed: boolean;
  23474. /**
  23475. * Gets the mass of the physics imposter
  23476. */
  23477. mass: number;
  23478. /**
  23479. * Gets the coefficient of friction
  23480. */
  23481. /**
  23482. * Sets the coefficient of friction
  23483. */
  23484. friction: number;
  23485. /**
  23486. * Gets the coefficient of restitution
  23487. */
  23488. /**
  23489. * Sets the coefficient of restitution
  23490. */
  23491. restitution: number;
  23492. /**
  23493. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23494. */
  23495. /**
  23496. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23497. */
  23498. pressure: number;
  23499. /**
  23500. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23501. */
  23502. /**
  23503. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23504. */
  23505. stiffness: number;
  23506. /**
  23507. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23508. */
  23509. /**
  23510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23511. */
  23512. velocityIterations: number;
  23513. /**
  23514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23515. */
  23516. /**
  23517. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23518. */
  23519. positionIterations: number;
  23520. /**
  23521. * The unique id of the physics imposter
  23522. * set by the physics engine when adding this impostor to the array
  23523. */
  23524. uniqueId: number;
  23525. /**
  23526. * @hidden
  23527. */
  23528. soft: boolean;
  23529. /**
  23530. * @hidden
  23531. */
  23532. segments: number;
  23533. private _joints;
  23534. /**
  23535. * Initializes the physics imposter
  23536. * @param object The physics-enabled object used as the physics imposter
  23537. * @param type The type of the physics imposter
  23538. * @param _options The options for the physics imposter
  23539. * @param _scene The Babylon scene
  23540. */
  23541. constructor(
  23542. /**
  23543. * The physics-enabled object used as the physics imposter
  23544. */
  23545. object: IPhysicsEnabledObject,
  23546. /**
  23547. * The type of the physics imposter
  23548. */
  23549. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23550. /**
  23551. * This function will completly initialize this impostor.
  23552. * It will create a new body - but only if this mesh has no parent.
  23553. * If it has, this impostor will not be used other than to define the impostor
  23554. * of the child mesh.
  23555. * @hidden
  23556. */
  23557. _init(): void;
  23558. private _getPhysicsParent;
  23559. /**
  23560. * Should a new body be generated.
  23561. * @returns boolean specifying if body initialization is required
  23562. */
  23563. isBodyInitRequired(): boolean;
  23564. /**
  23565. * Sets the updated scaling
  23566. * @param updated Specifies if the scaling is updated
  23567. */
  23568. setScalingUpdated(): void;
  23569. /**
  23570. * Force a regeneration of this or the parent's impostor's body.
  23571. * Use under cautious - This will remove all joints already implemented.
  23572. */
  23573. forceUpdate(): void;
  23574. /**
  23575. * Gets the body that holds this impostor. Either its own, or its parent.
  23576. */
  23577. /**
  23578. * Set the physics body. Used mainly by the physics engine/plugin
  23579. */
  23580. physicsBody: any;
  23581. /**
  23582. * Get the parent of the physics imposter
  23583. * @returns Physics imposter or null
  23584. */
  23585. /**
  23586. * Sets the parent of the physics imposter
  23587. */
  23588. parent: Nullable<PhysicsImpostor>;
  23589. /**
  23590. * Resets the update flags
  23591. */
  23592. resetUpdateFlags(): void;
  23593. /**
  23594. * Gets the object extend size
  23595. * @returns the object extend size
  23596. */
  23597. getObjectExtendSize(): Vector3;
  23598. /**
  23599. * Gets the object center
  23600. * @returns The object center
  23601. */
  23602. getObjectCenter(): Vector3;
  23603. /**
  23604. * Get a specific parametes from the options parameter
  23605. * @param paramName The object parameter name
  23606. * @returns The object parameter
  23607. */
  23608. getParam(paramName: string): any;
  23609. /**
  23610. * Sets a specific parameter in the options given to the physics plugin
  23611. * @param paramName The parameter name
  23612. * @param value The value of the parameter
  23613. */
  23614. setParam(paramName: string, value: number): void;
  23615. /**
  23616. * Specifically change the body's mass option. Won't recreate the physics body object
  23617. * @param mass The mass of the physics imposter
  23618. */
  23619. setMass(mass: number): void;
  23620. /**
  23621. * Gets the linear velocity
  23622. * @returns linear velocity or null
  23623. */
  23624. getLinearVelocity(): Nullable<Vector3>;
  23625. /**
  23626. * Sets the linear velocity
  23627. * @param velocity linear velocity or null
  23628. */
  23629. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23630. /**
  23631. * Gets the angular velocity
  23632. * @returns angular velocity or null
  23633. */
  23634. getAngularVelocity(): Nullable<Vector3>;
  23635. /**
  23636. * Sets the angular velocity
  23637. * @param velocity The velocity or null
  23638. */
  23639. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23640. /**
  23641. * Execute a function with the physics plugin native code
  23642. * Provide a function the will have two variables - the world object and the physics body object
  23643. * @param func The function to execute with the physics plugin native code
  23644. */
  23645. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23646. /**
  23647. * Register a function that will be executed before the physics world is stepping forward
  23648. * @param func The function to execute before the physics world is stepped forward
  23649. */
  23650. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23651. /**
  23652. * Unregister a function that will be executed before the physics world is stepping forward
  23653. * @param func The function to execute before the physics world is stepped forward
  23654. */
  23655. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23656. /**
  23657. * Register a function that will be executed after the physics step
  23658. * @param func The function to execute after physics step
  23659. */
  23660. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23661. /**
  23662. * Unregisters a function that will be executed after the physics step
  23663. * @param func The function to execute after physics step
  23664. */
  23665. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23666. /**
  23667. * register a function that will be executed when this impostor collides against a different body
  23668. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23669. * @param func Callback that is executed on collision
  23670. */
  23671. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23672. /**
  23673. * Unregisters the physics imposter on contact
  23674. * @param collideAgainst The physics object to collide against
  23675. * @param func Callback to execute on collision
  23676. */
  23677. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23678. private _tmpQuat;
  23679. private _tmpQuat2;
  23680. /**
  23681. * Get the parent rotation
  23682. * @returns The parent rotation
  23683. */
  23684. getParentsRotation(): Quaternion;
  23685. /**
  23686. * this function is executed by the physics engine.
  23687. */
  23688. beforeStep: () => void;
  23689. /**
  23690. * this function is executed by the physics engine
  23691. */
  23692. afterStep: () => void;
  23693. /**
  23694. * Legacy collision detection event support
  23695. */
  23696. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23697. /**
  23698. * event and body object due to cannon's event-based architecture.
  23699. */
  23700. onCollide: (e: {
  23701. body: any;
  23702. }) => void;
  23703. /**
  23704. * Apply a force
  23705. * @param force The force to apply
  23706. * @param contactPoint The contact point for the force
  23707. * @returns The physics imposter
  23708. */
  23709. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23710. /**
  23711. * Apply an impulse
  23712. * @param force The impulse force
  23713. * @param contactPoint The contact point for the impulse force
  23714. * @returns The physics imposter
  23715. */
  23716. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23717. /**
  23718. * A help function to create a joint
  23719. * @param otherImpostor A physics imposter used to create a joint
  23720. * @param jointType The type of joint
  23721. * @param jointData The data for the joint
  23722. * @returns The physics imposter
  23723. */
  23724. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23725. /**
  23726. * Add a joint to this impostor with a different impostor
  23727. * @param otherImpostor A physics imposter used to add a joint
  23728. * @param joint The joint to add
  23729. * @returns The physics imposter
  23730. */
  23731. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23732. /**
  23733. * Add an anchor to a cloth impostor
  23734. * @param otherImpostor rigid impostor to anchor to
  23735. * @param width ratio across width from 0 to 1
  23736. * @param height ratio up height from 0 to 1
  23737. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23738. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23739. * @returns impostor the soft imposter
  23740. */
  23741. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23742. /**
  23743. * Add a hook to a rope impostor
  23744. * @param otherImpostor rigid impostor to anchor to
  23745. * @param length ratio across rope from 0 to 1
  23746. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23748. * @returns impostor the rope imposter
  23749. */
  23750. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23751. /**
  23752. * Will keep this body still, in a sleep mode.
  23753. * @returns the physics imposter
  23754. */
  23755. sleep(): PhysicsImpostor;
  23756. /**
  23757. * Wake the body up.
  23758. * @returns The physics imposter
  23759. */
  23760. wakeUp(): PhysicsImpostor;
  23761. /**
  23762. * Clones the physics imposter
  23763. * @param newObject The physics imposter clones to this physics-enabled object
  23764. * @returns A nullable physics imposter
  23765. */
  23766. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23767. /**
  23768. * Disposes the physics imposter
  23769. */
  23770. dispose(): void;
  23771. /**
  23772. * Sets the delta position
  23773. * @param position The delta position amount
  23774. */
  23775. setDeltaPosition(position: Vector3): void;
  23776. /**
  23777. * Sets the delta rotation
  23778. * @param rotation The delta rotation amount
  23779. */
  23780. setDeltaRotation(rotation: Quaternion): void;
  23781. /**
  23782. * Gets the box size of the physics imposter and stores the result in the input parameter
  23783. * @param result Stores the box size
  23784. * @returns The physics imposter
  23785. */
  23786. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23787. /**
  23788. * Gets the radius of the physics imposter
  23789. * @returns Radius of the physics imposter
  23790. */
  23791. getRadius(): number;
  23792. /**
  23793. * Sync a bone with this impostor
  23794. * @param bone The bone to sync to the impostor.
  23795. * @param boneMesh The mesh that the bone is influencing.
  23796. * @param jointPivot The pivot of the joint / bone in local space.
  23797. * @param distToJoint Optional distance from the impostor to the joint.
  23798. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23799. */
  23800. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23801. /**
  23802. * Sync impostor to a bone
  23803. * @param bone The bone that the impostor will be synced to.
  23804. * @param boneMesh The mesh that the bone is influencing.
  23805. * @param jointPivot The pivot of the joint / bone in local space.
  23806. * @param distToJoint Optional distance from the impostor to the joint.
  23807. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23808. * @param boneAxis Optional vector3 axis the bone is aligned with
  23809. */
  23810. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23811. /**
  23812. * No-Imposter type
  23813. */
  23814. static NoImpostor: number;
  23815. /**
  23816. * Sphere-Imposter type
  23817. */
  23818. static SphereImpostor: number;
  23819. /**
  23820. * Box-Imposter type
  23821. */
  23822. static BoxImpostor: number;
  23823. /**
  23824. * Plane-Imposter type
  23825. */
  23826. static PlaneImpostor: number;
  23827. /**
  23828. * Mesh-imposter type
  23829. */
  23830. static MeshImpostor: number;
  23831. /**
  23832. * Capsule-Impostor type (Ammo.js plugin only)
  23833. */
  23834. static CapsuleImpostor: number;
  23835. /**
  23836. * Cylinder-Imposter type
  23837. */
  23838. static CylinderImpostor: number;
  23839. /**
  23840. * Particle-Imposter type
  23841. */
  23842. static ParticleImpostor: number;
  23843. /**
  23844. * Heightmap-Imposter type
  23845. */
  23846. static HeightmapImpostor: number;
  23847. /**
  23848. * ConvexHull-Impostor type (Ammo.js plugin only)
  23849. */
  23850. static ConvexHullImpostor: number;
  23851. /**
  23852. * Rope-Imposter type
  23853. */
  23854. static RopeImpostor: number;
  23855. /**
  23856. * Cloth-Imposter type
  23857. */
  23858. static ClothImpostor: number;
  23859. /**
  23860. * Softbody-Imposter type
  23861. */
  23862. static SoftbodyImpostor: number;
  23863. }
  23864. }
  23865. declare module "babylonjs/Meshes/mesh" {
  23866. import { Observable } from "babylonjs/Misc/observable";
  23867. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23868. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23869. import { Camera } from "babylonjs/Cameras/camera";
  23870. import { Scene } from "babylonjs/scene";
  23871. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23872. import { Color4 } from "babylonjs/Maths/math.color";
  23873. import { Engine } from "babylonjs/Engines/engine";
  23874. import { Node } from "babylonjs/node";
  23875. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23876. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23877. import { Buffer } from "babylonjs/Meshes/buffer";
  23878. import { Geometry } from "babylonjs/Meshes/geometry";
  23879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23882. import { Effect } from "babylonjs/Materials/effect";
  23883. import { Material } from "babylonjs/Materials/material";
  23884. import { Skeleton } from "babylonjs/Bones/skeleton";
  23885. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23886. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23887. import { Path3D } from "babylonjs/Maths/math.path";
  23888. import { Plane } from "babylonjs/Maths/math.plane";
  23889. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23890. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23891. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23892. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23893. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23894. /**
  23895. * @hidden
  23896. **/
  23897. export class _CreationDataStorage {
  23898. closePath?: boolean;
  23899. closeArray?: boolean;
  23900. idx: number[];
  23901. dashSize: number;
  23902. gapSize: number;
  23903. path3D: Path3D;
  23904. pathArray: Vector3[][];
  23905. arc: number;
  23906. radius: number;
  23907. cap: number;
  23908. tessellation: number;
  23909. }
  23910. /**
  23911. * @hidden
  23912. **/
  23913. class _InstanceDataStorage {
  23914. visibleInstances: any;
  23915. batchCache: _InstancesBatch;
  23916. instancesBufferSize: number;
  23917. instancesBuffer: Nullable<Buffer>;
  23918. instancesData: Float32Array;
  23919. overridenInstanceCount: number;
  23920. isFrozen: boolean;
  23921. previousBatch: Nullable<_InstancesBatch>;
  23922. hardwareInstancedRendering: boolean;
  23923. sideOrientation: number;
  23924. }
  23925. /**
  23926. * @hidden
  23927. **/
  23928. export class _InstancesBatch {
  23929. mustReturn: boolean;
  23930. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23931. renderSelf: boolean[];
  23932. hardwareInstancedRendering: boolean[];
  23933. }
  23934. /**
  23935. * Class used to represent renderable models
  23936. */
  23937. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23938. /**
  23939. * Mesh side orientation : usually the external or front surface
  23940. */
  23941. static readonly FRONTSIDE: number;
  23942. /**
  23943. * Mesh side orientation : usually the internal or back surface
  23944. */
  23945. static readonly BACKSIDE: number;
  23946. /**
  23947. * Mesh side orientation : both internal and external or front and back surfaces
  23948. */
  23949. static readonly DOUBLESIDE: number;
  23950. /**
  23951. * Mesh side orientation : by default, `FRONTSIDE`
  23952. */
  23953. static readonly DEFAULTSIDE: number;
  23954. /**
  23955. * Mesh cap setting : no cap
  23956. */
  23957. static readonly NO_CAP: number;
  23958. /**
  23959. * Mesh cap setting : one cap at the beginning of the mesh
  23960. */
  23961. static readonly CAP_START: number;
  23962. /**
  23963. * Mesh cap setting : one cap at the end of the mesh
  23964. */
  23965. static readonly CAP_END: number;
  23966. /**
  23967. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23968. */
  23969. static readonly CAP_ALL: number;
  23970. /**
  23971. * Mesh pattern setting : no flip or rotate
  23972. */
  23973. static readonly NO_FLIP: number;
  23974. /**
  23975. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23976. */
  23977. static readonly FLIP_TILE: number;
  23978. /**
  23979. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23980. */
  23981. static readonly ROTATE_TILE: number;
  23982. /**
  23983. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23984. */
  23985. static readonly FLIP_ROW: number;
  23986. /**
  23987. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23988. */
  23989. static readonly ROTATE_ROW: number;
  23990. /**
  23991. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23992. */
  23993. static readonly FLIP_N_ROTATE_TILE: number;
  23994. /**
  23995. * Mesh pattern setting : rotate pattern and rotate
  23996. */
  23997. static readonly FLIP_N_ROTATE_ROW: number;
  23998. /**
  23999. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24000. */
  24001. static readonly CENTER: number;
  24002. /**
  24003. * Mesh tile positioning : part tiles on left
  24004. */
  24005. static readonly LEFT: number;
  24006. /**
  24007. * Mesh tile positioning : part tiles on right
  24008. */
  24009. static readonly RIGHT: number;
  24010. /**
  24011. * Mesh tile positioning : part tiles on top
  24012. */
  24013. static readonly TOP: number;
  24014. /**
  24015. * Mesh tile positioning : part tiles on bottom
  24016. */
  24017. static readonly BOTTOM: number;
  24018. /**
  24019. * Gets the default side orientation.
  24020. * @param orientation the orientation to value to attempt to get
  24021. * @returns the default orientation
  24022. * @hidden
  24023. */
  24024. static _GetDefaultSideOrientation(orientation?: number): number;
  24025. private _internalMeshDataInfo;
  24026. /**
  24027. * An event triggered before rendering the mesh
  24028. */
  24029. readonly onBeforeRenderObservable: Observable<Mesh>;
  24030. /**
  24031. * An event triggered before binding the mesh
  24032. */
  24033. readonly onBeforeBindObservable: Observable<Mesh>;
  24034. /**
  24035. * An event triggered after rendering the mesh
  24036. */
  24037. readonly onAfterRenderObservable: Observable<Mesh>;
  24038. /**
  24039. * An event triggered before drawing the mesh
  24040. */
  24041. readonly onBeforeDrawObservable: Observable<Mesh>;
  24042. private _onBeforeDrawObserver;
  24043. /**
  24044. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24045. */
  24046. onBeforeDraw: () => void;
  24047. /**
  24048. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24049. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24050. */
  24051. delayLoadState: number;
  24052. /**
  24053. * Gets the list of instances created from this mesh
  24054. * it is not supposed to be modified manually.
  24055. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24056. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24057. */
  24058. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24059. /**
  24060. * Gets the file containing delay loading data for this mesh
  24061. */
  24062. delayLoadingFile: string;
  24063. /** @hidden */
  24064. _binaryInfo: any;
  24065. /**
  24066. * User defined function used to change how LOD level selection is done
  24067. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24068. */
  24069. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24070. /**
  24071. * Gets or sets the morph target manager
  24072. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24073. */
  24074. morphTargetManager: Nullable<MorphTargetManager>;
  24075. /** @hidden */
  24076. _creationDataStorage: Nullable<_CreationDataStorage>;
  24077. /** @hidden */
  24078. _geometry: Nullable<Geometry>;
  24079. /** @hidden */
  24080. _delayInfo: Array<string>;
  24081. /** @hidden */
  24082. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24083. /** @hidden */
  24084. _instanceDataStorage: _InstanceDataStorage;
  24085. private _effectiveMaterial;
  24086. /** @hidden */
  24087. _shouldGenerateFlatShading: boolean;
  24088. /** @hidden */
  24089. _originalBuilderSideOrientation: number;
  24090. /**
  24091. * Use this property to change the original side orientation defined at construction time
  24092. */
  24093. overrideMaterialSideOrientation: Nullable<number>;
  24094. /**
  24095. * Gets the source mesh (the one used to clone this one from)
  24096. */
  24097. readonly source: Nullable<Mesh>;
  24098. /**
  24099. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24100. */
  24101. isUnIndexed: boolean;
  24102. /**
  24103. * @constructor
  24104. * @param name The value used by scene.getMeshByName() to do a lookup.
  24105. * @param scene The scene to add this mesh to.
  24106. * @param parent The parent of this mesh, if it has one
  24107. * @param source An optional Mesh from which geometry is shared, cloned.
  24108. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24109. * When false, achieved by calling a clone(), also passing False.
  24110. * This will make creation of children, recursive.
  24111. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24112. */
  24113. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24114. /**
  24115. * Gets the class name
  24116. * @returns the string "Mesh".
  24117. */
  24118. getClassName(): string;
  24119. /** @hidden */
  24120. readonly _isMesh: boolean;
  24121. /**
  24122. * Returns a description of this mesh
  24123. * @param fullDetails define if full details about this mesh must be used
  24124. * @returns a descriptive string representing this mesh
  24125. */
  24126. toString(fullDetails?: boolean): string;
  24127. /** @hidden */
  24128. _unBindEffect(): void;
  24129. /**
  24130. * Gets a boolean indicating if this mesh has LOD
  24131. */
  24132. readonly hasLODLevels: boolean;
  24133. /**
  24134. * Gets the list of MeshLODLevel associated with the current mesh
  24135. * @returns an array of MeshLODLevel
  24136. */
  24137. getLODLevels(): MeshLODLevel[];
  24138. private _sortLODLevels;
  24139. /**
  24140. * Add a mesh as LOD level triggered at the given distance.
  24141. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24142. * @param distance The distance from the center of the object to show this level
  24143. * @param mesh The mesh to be added as LOD level (can be null)
  24144. * @return This mesh (for chaining)
  24145. */
  24146. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24147. /**
  24148. * Returns the LOD level mesh at the passed distance or null if not found.
  24149. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24150. * @param distance The distance from the center of the object to show this level
  24151. * @returns a Mesh or `null`
  24152. */
  24153. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24154. /**
  24155. * Remove a mesh from the LOD array
  24156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24157. * @param mesh defines the mesh to be removed
  24158. * @return This mesh (for chaining)
  24159. */
  24160. removeLODLevel(mesh: Mesh): Mesh;
  24161. /**
  24162. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24163. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24164. * @param camera defines the camera to use to compute distance
  24165. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24166. * @return This mesh (for chaining)
  24167. */
  24168. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24169. /**
  24170. * Gets the mesh internal Geometry object
  24171. */
  24172. readonly geometry: Nullable<Geometry>;
  24173. /**
  24174. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24175. * @returns the total number of vertices
  24176. */
  24177. getTotalVertices(): number;
  24178. /**
  24179. * Returns the content of an associated vertex buffer
  24180. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24181. * - VertexBuffer.PositionKind
  24182. * - VertexBuffer.UVKind
  24183. * - VertexBuffer.UV2Kind
  24184. * - VertexBuffer.UV3Kind
  24185. * - VertexBuffer.UV4Kind
  24186. * - VertexBuffer.UV5Kind
  24187. * - VertexBuffer.UV6Kind
  24188. * - VertexBuffer.ColorKind
  24189. * - VertexBuffer.MatricesIndicesKind
  24190. * - VertexBuffer.MatricesIndicesExtraKind
  24191. * - VertexBuffer.MatricesWeightsKind
  24192. * - VertexBuffer.MatricesWeightsExtraKind
  24193. * @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
  24194. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24195. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24196. */
  24197. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24198. /**
  24199. * Returns the mesh VertexBuffer object from the requested `kind`
  24200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24201. * - VertexBuffer.PositionKind
  24202. * - VertexBuffer.NormalKind
  24203. * - VertexBuffer.UVKind
  24204. * - VertexBuffer.UV2Kind
  24205. * - VertexBuffer.UV3Kind
  24206. * - VertexBuffer.UV4Kind
  24207. * - VertexBuffer.UV5Kind
  24208. * - VertexBuffer.UV6Kind
  24209. * - VertexBuffer.ColorKind
  24210. * - VertexBuffer.MatricesIndicesKind
  24211. * - VertexBuffer.MatricesIndicesExtraKind
  24212. * - VertexBuffer.MatricesWeightsKind
  24213. * - VertexBuffer.MatricesWeightsExtraKind
  24214. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24215. */
  24216. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24217. /**
  24218. * Tests if a specific vertex buffer is associated with this mesh
  24219. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24220. * - VertexBuffer.PositionKind
  24221. * - VertexBuffer.NormalKind
  24222. * - VertexBuffer.UVKind
  24223. * - VertexBuffer.UV2Kind
  24224. * - VertexBuffer.UV3Kind
  24225. * - VertexBuffer.UV4Kind
  24226. * - VertexBuffer.UV5Kind
  24227. * - VertexBuffer.UV6Kind
  24228. * - VertexBuffer.ColorKind
  24229. * - VertexBuffer.MatricesIndicesKind
  24230. * - VertexBuffer.MatricesIndicesExtraKind
  24231. * - VertexBuffer.MatricesWeightsKind
  24232. * - VertexBuffer.MatricesWeightsExtraKind
  24233. * @returns a boolean
  24234. */
  24235. isVerticesDataPresent(kind: string): boolean;
  24236. /**
  24237. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24238. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24239. * - VertexBuffer.PositionKind
  24240. * - VertexBuffer.UVKind
  24241. * - VertexBuffer.UV2Kind
  24242. * - VertexBuffer.UV3Kind
  24243. * - VertexBuffer.UV4Kind
  24244. * - VertexBuffer.UV5Kind
  24245. * - VertexBuffer.UV6Kind
  24246. * - VertexBuffer.ColorKind
  24247. * - VertexBuffer.MatricesIndicesKind
  24248. * - VertexBuffer.MatricesIndicesExtraKind
  24249. * - VertexBuffer.MatricesWeightsKind
  24250. * - VertexBuffer.MatricesWeightsExtraKind
  24251. * @returns a boolean
  24252. */
  24253. isVertexBufferUpdatable(kind: string): boolean;
  24254. /**
  24255. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24257. * - VertexBuffer.PositionKind
  24258. * - VertexBuffer.NormalKind
  24259. * - VertexBuffer.UVKind
  24260. * - VertexBuffer.UV2Kind
  24261. * - VertexBuffer.UV3Kind
  24262. * - VertexBuffer.UV4Kind
  24263. * - VertexBuffer.UV5Kind
  24264. * - VertexBuffer.UV6Kind
  24265. * - VertexBuffer.ColorKind
  24266. * - VertexBuffer.MatricesIndicesKind
  24267. * - VertexBuffer.MatricesIndicesExtraKind
  24268. * - VertexBuffer.MatricesWeightsKind
  24269. * - VertexBuffer.MatricesWeightsExtraKind
  24270. * @returns an array of strings
  24271. */
  24272. getVerticesDataKinds(): string[];
  24273. /**
  24274. * Returns a positive integer : the total number of indices in this mesh geometry.
  24275. * @returns the numner of indices or zero if the mesh has no geometry.
  24276. */
  24277. getTotalIndices(): number;
  24278. /**
  24279. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24280. * @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.
  24281. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24282. * @returns the indices array or an empty array if the mesh has no geometry
  24283. */
  24284. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24285. readonly isBlocked: boolean;
  24286. /**
  24287. * Determine if the current mesh is ready to be rendered
  24288. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24289. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24290. * @returns true if all associated assets are ready (material, textures, shaders)
  24291. */
  24292. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24293. /**
  24294. * 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.
  24295. */
  24296. readonly areNormalsFrozen: boolean;
  24297. /**
  24298. * 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.
  24299. * @returns the current mesh
  24300. */
  24301. freezeNormals(): Mesh;
  24302. /**
  24303. * 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
  24304. * @returns the current mesh
  24305. */
  24306. unfreezeNormals(): Mesh;
  24307. /**
  24308. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24309. */
  24310. overridenInstanceCount: number;
  24311. /** @hidden */
  24312. _preActivate(): Mesh;
  24313. /** @hidden */
  24314. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24315. /** @hidden */
  24316. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24317. /**
  24318. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24319. * This means the mesh underlying bounding box and sphere are recomputed.
  24320. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24321. * @returns the current mesh
  24322. */
  24323. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24324. /** @hidden */
  24325. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24326. /**
  24327. * This function will subdivide the mesh into multiple submeshes
  24328. * @param count defines the expected number of submeshes
  24329. */
  24330. subdivide(count: number): void;
  24331. /**
  24332. * Copy a FloatArray into a specific associated vertex buffer
  24333. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24334. * - VertexBuffer.PositionKind
  24335. * - VertexBuffer.UVKind
  24336. * - VertexBuffer.UV2Kind
  24337. * - VertexBuffer.UV3Kind
  24338. * - VertexBuffer.UV4Kind
  24339. * - VertexBuffer.UV5Kind
  24340. * - VertexBuffer.UV6Kind
  24341. * - VertexBuffer.ColorKind
  24342. * - VertexBuffer.MatricesIndicesKind
  24343. * - VertexBuffer.MatricesIndicesExtraKind
  24344. * - VertexBuffer.MatricesWeightsKind
  24345. * - VertexBuffer.MatricesWeightsExtraKind
  24346. * @param data defines the data source
  24347. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24348. * @param stride defines the data stride size (can be null)
  24349. * @returns the current mesh
  24350. */
  24351. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24352. /**
  24353. * Flags an associated vertex buffer as updatable
  24354. * @param kind defines which buffer to use (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 updatable defines if the updated vertex buffer must be flagged as updatable
  24368. */
  24369. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24370. /**
  24371. * Sets the mesh global Vertex Buffer
  24372. * @param buffer defines the buffer to use
  24373. * @returns the current mesh
  24374. */
  24375. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24376. /**
  24377. * Update a specific associated vertex buffer
  24378. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24379. * - VertexBuffer.PositionKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @param data defines the data source
  24392. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24393. * @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)
  24394. * @returns the current mesh
  24395. */
  24396. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24397. /**
  24398. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24399. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24400. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24401. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24402. * @returns the current mesh
  24403. */
  24404. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24405. /**
  24406. * Creates a un-shared specific occurence of the geometry for the mesh.
  24407. * @returns the current mesh
  24408. */
  24409. makeGeometryUnique(): Mesh;
  24410. /**
  24411. * Set the index buffer of this mesh
  24412. * @param indices defines the source data
  24413. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24414. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24415. * @returns the current mesh
  24416. */
  24417. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24418. /**
  24419. * Update the current index buffer
  24420. * @param indices defines the source data
  24421. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24422. * @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)
  24423. * @returns the current mesh
  24424. */
  24425. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24426. /**
  24427. * Invert the geometry to move from a right handed system to a left handed one.
  24428. * @returns the current mesh
  24429. */
  24430. toLeftHanded(): Mesh;
  24431. /** @hidden */
  24432. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24433. /** @hidden */
  24434. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24435. /**
  24436. * Registers for this mesh a javascript function called just before the rendering process
  24437. * @param func defines the function to call before rendering this mesh
  24438. * @returns the current mesh
  24439. */
  24440. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24441. /**
  24442. * Disposes a previously registered javascript function called before the rendering
  24443. * @param func defines the function to remove
  24444. * @returns the current mesh
  24445. */
  24446. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24447. /**
  24448. * Registers for this mesh a javascript function called just after the rendering is complete
  24449. * @param func defines the function to call after rendering this mesh
  24450. * @returns the current mesh
  24451. */
  24452. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24453. /**
  24454. * Disposes a previously registered javascript function called after the rendering.
  24455. * @param func defines the function to remove
  24456. * @returns the current mesh
  24457. */
  24458. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24459. /** @hidden */
  24460. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24461. /** @hidden */
  24462. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24463. /** @hidden */
  24464. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24465. /** @hidden */
  24466. _rebuild(): void;
  24467. /** @hidden */
  24468. _freeze(): void;
  24469. /** @hidden */
  24470. _unFreeze(): void;
  24471. /**
  24472. * 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
  24473. * @param subMesh defines the subMesh to render
  24474. * @param enableAlphaMode defines if alpha mode can be changed
  24475. * @returns the current mesh
  24476. */
  24477. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24478. private _onBeforeDraw;
  24479. /**
  24480. * Renormalize the mesh and patch it up if there are no weights
  24481. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24482. * However in the case of zero weights then we set just a single influence to 1.
  24483. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24484. */
  24485. cleanMatrixWeights(): void;
  24486. private normalizeSkinFourWeights;
  24487. private normalizeSkinWeightsAndExtra;
  24488. /**
  24489. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24490. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24491. * the user know there was an issue with importing the mesh
  24492. * @returns a validation object with skinned, valid and report string
  24493. */
  24494. validateSkinning(): {
  24495. skinned: boolean;
  24496. valid: boolean;
  24497. report: string;
  24498. };
  24499. /** @hidden */
  24500. _checkDelayState(): Mesh;
  24501. private _queueLoad;
  24502. /**
  24503. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24504. * A mesh is in the frustum if its bounding box intersects the frustum
  24505. * @param frustumPlanes defines the frustum to test
  24506. * @returns true if the mesh is in the frustum planes
  24507. */
  24508. isInFrustum(frustumPlanes: Plane[]): boolean;
  24509. /**
  24510. * Sets the mesh material by the material or multiMaterial `id` property
  24511. * @param id is a string identifying the material or the multiMaterial
  24512. * @returns the current mesh
  24513. */
  24514. setMaterialByID(id: string): Mesh;
  24515. /**
  24516. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24517. * @returns an array of IAnimatable
  24518. */
  24519. getAnimatables(): IAnimatable[];
  24520. /**
  24521. * Modifies the mesh geometry according to the passed transformation matrix.
  24522. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24523. * The mesh normals are modified using the same transformation.
  24524. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24525. * @param transform defines the transform matrix to use
  24526. * @see http://doc.babylonjs.com/resources/baking_transformations
  24527. * @returns the current mesh
  24528. */
  24529. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24530. /**
  24531. * Modifies the mesh geometry according to its own current World Matrix.
  24532. * The mesh World Matrix is then reset.
  24533. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24534. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24535. * @see http://doc.babylonjs.com/resources/baking_transformations
  24536. * @returns the current mesh
  24537. */
  24538. bakeCurrentTransformIntoVertices(): Mesh;
  24539. /** @hidden */
  24540. readonly _positions: Nullable<Vector3[]>;
  24541. /** @hidden */
  24542. _resetPointsArrayCache(): Mesh;
  24543. /** @hidden */
  24544. _generatePointsArray(): boolean;
  24545. /**
  24546. * Returns a new Mesh object generated from the current mesh properties.
  24547. * This method must not get confused with createInstance()
  24548. * @param name is a string, the name given to the new mesh
  24549. * @param newParent can be any Node object (default `null`)
  24550. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24551. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24552. * @returns a new mesh
  24553. */
  24554. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24555. /**
  24556. * Releases resources associated with this mesh.
  24557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24559. */
  24560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24561. /**
  24562. * Modifies the mesh geometry according to a displacement map.
  24563. * 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.
  24564. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24565. * @param url is a string, the URL from the image file is to be downloaded.
  24566. * @param minHeight is the lower limit of the displacement.
  24567. * @param maxHeight is the upper limit of the displacement.
  24568. * @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.
  24569. * @param uvOffset is an optional vector2 used to offset UV.
  24570. * @param uvScale is an optional vector2 used to scale UV.
  24571. * @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.
  24572. * @returns the Mesh.
  24573. */
  24574. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24575. /**
  24576. * Modifies the mesh geometry according to a displacementMap buffer.
  24577. * 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.
  24578. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24579. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24580. * @param heightMapWidth is the width of the buffer image.
  24581. * @param heightMapHeight is the height of the buffer image.
  24582. * @param minHeight is the lower limit of the displacement.
  24583. * @param maxHeight is the upper limit of the displacement.
  24584. * @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.
  24585. * @param uvOffset is an optional vector2 used to offset UV.
  24586. * @param uvScale is an optional vector2 used to scale UV.
  24587. * @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.
  24588. * @returns the Mesh.
  24589. */
  24590. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24591. /**
  24592. * Modify the mesh to get a flat shading rendering.
  24593. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24594. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24595. * @returns current mesh
  24596. */
  24597. convertToFlatShadedMesh(): Mesh;
  24598. /**
  24599. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24600. * In other words, more vertices, no more indices and a single bigger VBO.
  24601. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24602. * @returns current mesh
  24603. */
  24604. convertToUnIndexedMesh(): Mesh;
  24605. /**
  24606. * Inverses facet orientations.
  24607. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24608. * @param flipNormals will also inverts the normals
  24609. * @returns current mesh
  24610. */
  24611. flipFaces(flipNormals?: boolean): Mesh;
  24612. /**
  24613. * Increase the number of facets and hence vertices in a mesh
  24614. * Vertex normals are interpolated from existing vertex normals
  24615. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24616. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24617. */
  24618. increaseVertices(numberPerEdge: number): void;
  24619. /**
  24620. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24621. * This will undo any application of covertToFlatShadedMesh
  24622. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24623. */
  24624. forceSharedVertices(): void;
  24625. /** @hidden */
  24626. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24627. /** @hidden */
  24628. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24629. /**
  24630. * Creates a new InstancedMesh object from the mesh model.
  24631. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24632. * @param name defines the name of the new instance
  24633. * @returns a new InstancedMesh
  24634. */
  24635. createInstance(name: string): InstancedMesh;
  24636. /**
  24637. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24638. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24639. * @returns the current mesh
  24640. */
  24641. synchronizeInstances(): Mesh;
  24642. /**
  24643. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24644. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24645. * This should be used together with the simplification to avoid disappearing triangles.
  24646. * @param successCallback an optional success callback to be called after the optimization finished.
  24647. * @returns the current mesh
  24648. */
  24649. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24650. /**
  24651. * Serialize current mesh
  24652. * @param serializationObject defines the object which will receive the serialization data
  24653. */
  24654. serialize(serializationObject: any): void;
  24655. /** @hidden */
  24656. _syncGeometryWithMorphTargetManager(): void;
  24657. /** @hidden */
  24658. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24659. /**
  24660. * Returns a new Mesh object parsed from the source provided.
  24661. * @param parsedMesh is the source
  24662. * @param scene defines the hosting scene
  24663. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24664. * @returns a new Mesh
  24665. */
  24666. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24667. /**
  24668. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24669. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24670. * @param name defines the name of the mesh to create
  24671. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24672. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24673. * @param closePath creates a seam between the first and the last points of each path of the path array
  24674. * @param offset is taken in account only if the `pathArray` is containing a single path
  24675. * @param scene defines the hosting scene
  24676. * @param updatable defines if the mesh must be flagged as updatable
  24677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24678. * @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)
  24679. * @returns a new Mesh
  24680. */
  24681. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24682. /**
  24683. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24684. * @param name defines the name of the mesh to create
  24685. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24686. * @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
  24687. * @param scene defines the hosting scene
  24688. * @param updatable defines if the mesh must be flagged as updatable
  24689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24690. * @returns a new Mesh
  24691. */
  24692. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24693. /**
  24694. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24695. * @param name defines the name of the mesh to create
  24696. * @param size sets the size (float) of each box side (default 1)
  24697. * @param scene defines the hosting scene
  24698. * @param updatable defines if the mesh must be flagged as updatable
  24699. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24700. * @returns a new Mesh
  24701. */
  24702. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24703. /**
  24704. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24705. * @param name defines the name of the mesh to create
  24706. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24707. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24708. * @param scene defines the hosting scene
  24709. * @param updatable defines if the mesh must be flagged as updatable
  24710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24711. * @returns a new Mesh
  24712. */
  24713. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24714. /**
  24715. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24716. * @param name defines the name of the mesh to create
  24717. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24718. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24719. * @param scene defines the hosting scene
  24720. * @returns a new Mesh
  24721. */
  24722. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24723. /**
  24724. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24725. * @param name defines the name of the mesh to create
  24726. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24727. * @param diameterTop set the top cap diameter (floats, default 1)
  24728. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24729. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24730. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24731. * @param scene defines the hosting scene
  24732. * @param updatable defines if the mesh must be flagged as updatable
  24733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24734. * @returns a new Mesh
  24735. */
  24736. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24737. /**
  24738. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24739. * @param name defines the name of the mesh to create
  24740. * @param diameter sets the diameter size (float) of the torus (default 1)
  24741. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24742. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24743. * @param scene defines the hosting scene
  24744. * @param updatable defines if the mesh must be flagged as updatable
  24745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24746. * @returns a new Mesh
  24747. */
  24748. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24749. /**
  24750. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24751. * @param name defines the name of the mesh to create
  24752. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24753. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24754. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24755. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24756. * @param p the number of windings on X axis (positive integers, default 2)
  24757. * @param q the number of windings on Y axis (positive integers, default 3)
  24758. * @param scene defines the hosting scene
  24759. * @param updatable defines if the mesh must be flagged as updatable
  24760. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24761. * @returns a new Mesh
  24762. */
  24763. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24764. /**
  24765. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24766. * @param name defines the name of the mesh to create
  24767. * @param points is an array successive Vector3
  24768. * @param scene defines the hosting scene
  24769. * @param updatable defines if the mesh must be flagged as updatable
  24770. * @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).
  24771. * @returns a new Mesh
  24772. */
  24773. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24774. /**
  24775. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24776. * @param name defines the name of the mesh to create
  24777. * @param points is an array successive Vector3
  24778. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24779. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24780. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24781. * @param scene defines the hosting scene
  24782. * @param updatable defines if the mesh must be flagged as updatable
  24783. * @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)
  24784. * @returns a new Mesh
  24785. */
  24786. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24787. /**
  24788. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24789. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24790. * 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.
  24791. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24792. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24793. * Remember you can only change the shape positions, not their number when updating a polygon.
  24794. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24795. * @param name defines the name of the mesh to create
  24796. * @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
  24797. * @param scene defines the hosting scene
  24798. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24799. * @param updatable defines if the mesh must be flagged as updatable
  24800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24801. * @param earcutInjection can be used to inject your own earcut reference
  24802. * @returns a new Mesh
  24803. */
  24804. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24805. /**
  24806. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24807. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24808. * @param name defines the name of the mesh to create
  24809. * @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
  24810. * @param depth defines the height of extrusion
  24811. * @param scene defines the hosting scene
  24812. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24813. * @param updatable defines if the mesh must be flagged as updatable
  24814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24815. * @param earcutInjection can be used to inject your own earcut reference
  24816. * @returns a new Mesh
  24817. */
  24818. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24819. /**
  24820. * Creates an extruded shape mesh.
  24821. * 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
  24822. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24823. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24824. * @param name defines the name of the mesh to create
  24825. * @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
  24826. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24827. * @param scale is the value to scale the shape
  24828. * @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
  24829. * @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
  24830. * @param scene defines the hosting scene
  24831. * @param updatable defines if the mesh must be flagged as updatable
  24832. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24833. * @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)
  24834. * @returns a new Mesh
  24835. */
  24836. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24837. /**
  24838. * Creates an custom extruded shape mesh.
  24839. * The custom extrusion is a parametric shape.
  24840. * It has no predefined shape. Its final shape will depend on the input parameters.
  24841. * Please consider using the same method from the MeshBuilder class instead
  24842. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24843. * @param name defines the name of the mesh to create
  24844. * @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
  24845. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24846. * @param scaleFunction is a custom Javascript function called on each path point
  24847. * @param rotationFunction is a custom Javascript function called on each path point
  24848. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24849. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24850. * @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
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24854. * @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)
  24855. * @returns a new Mesh
  24856. */
  24857. 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;
  24858. /**
  24859. * Creates lathe mesh.
  24860. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24861. * Please consider using the same method from the MeshBuilder class instead
  24862. * @param name defines the name of the mesh to create
  24863. * @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
  24864. * @param radius is the radius value of the lathe
  24865. * @param tessellation is the side number of the lathe.
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24876. * @param scene defines the hosting scene
  24877. * @param updatable defines if the mesh must be flagged as updatable
  24878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24879. * @returns a new Mesh
  24880. */
  24881. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24882. /**
  24883. * Creates a ground mesh.
  24884. * Please consider using the same method from the MeshBuilder class instead
  24885. * @param name defines the name of the mesh to create
  24886. * @param width set the width of the ground
  24887. * @param height set the height of the ground
  24888. * @param subdivisions sets the number of subdivisions per side
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @returns a new Mesh
  24892. */
  24893. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24894. /**
  24895. * Creates a tiled ground mesh.
  24896. * Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param xmin set the ground minimum X coordinate
  24899. * @param zmin set the ground minimum Y coordinate
  24900. * @param xmax set the ground maximum X coordinate
  24901. * @param zmax set the ground maximum Z coordinate
  24902. * @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
  24903. * @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
  24904. * @param scene defines the hosting scene
  24905. * @param updatable defines if the mesh must be flagged as updatable
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24909. w: number;
  24910. h: number;
  24911. }, precision: {
  24912. w: number;
  24913. h: number;
  24914. }, scene: Scene, updatable?: boolean): Mesh;
  24915. /**
  24916. * Creates a ground mesh from a height map.
  24917. * Please consider using the same method from the MeshBuilder class instead
  24918. * @see http://doc.babylonjs.com/babylon101/height_map
  24919. * @param name defines the name of the mesh to create
  24920. * @param url sets the URL of the height map image resource
  24921. * @param width set the ground width size
  24922. * @param height set the ground height size
  24923. * @param subdivisions sets the number of subdivision per side
  24924. * @param minHeight is the minimum altitude on the ground
  24925. * @param maxHeight is the maximum altitude on the ground
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24929. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24930. * @returns a new Mesh
  24931. */
  24932. 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;
  24933. /**
  24934. * Creates a tube mesh.
  24935. * The tube is a parametric shape.
  24936. * It has no predefined shape. Its final shape will depend on the input parameters.
  24937. * Please consider using the same method from the MeshBuilder class instead
  24938. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24939. * @param name defines the name of the mesh to create
  24940. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24941. * @param radius sets the tube radius size
  24942. * @param tessellation is the number of sides on the tubular surface
  24943. * @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
  24944. * @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
  24945. * @param scene defines the hosting scene
  24946. * @param updatable defines if the mesh must be flagged as updatable
  24947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24948. * @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)
  24949. * @returns a new Mesh
  24950. */
  24951. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24952. (i: number, distance: number): number;
  24953. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24954. /**
  24955. * Creates a polyhedron mesh.
  24956. * Please consider using the same method from the MeshBuilder class instead.
  24957. * * 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
  24958. * * The parameter `size` (positive float, default 1) sets the polygon size
  24959. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24960. * * 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`
  24961. * * 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
  24962. * * 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)`)
  24963. * * 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
  24964. * * 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
  24965. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24966. * * If you create a double-sided mesh, you can choose what parts of 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
  24967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24968. * @param name defines the name of the mesh to create
  24969. * @param options defines the options used to create the mesh
  24970. * @param scene defines the hosting scene
  24971. * @returns a new Mesh
  24972. */
  24973. static CreatePolyhedron(name: string, options: {
  24974. type?: number;
  24975. size?: number;
  24976. sizeX?: number;
  24977. sizeY?: number;
  24978. sizeZ?: number;
  24979. custom?: any;
  24980. faceUV?: Vector4[];
  24981. faceColors?: Color4[];
  24982. updatable?: boolean;
  24983. sideOrientation?: number;
  24984. }, scene: Scene): Mesh;
  24985. /**
  24986. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24987. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24988. * * 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`)
  24989. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24990. * * 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
  24991. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24992. * * If you create a double-sided mesh, you can choose what parts of 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
  24993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24994. * @param name defines the name of the mesh
  24995. * @param options defines the options used to create the mesh
  24996. * @param scene defines the hosting scene
  24997. * @returns a new Mesh
  24998. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24999. */
  25000. static CreateIcoSphere(name: string, options: {
  25001. radius?: number;
  25002. flat?: boolean;
  25003. subdivisions?: number;
  25004. sideOrientation?: number;
  25005. updatable?: boolean;
  25006. }, scene: Scene): Mesh;
  25007. /**
  25008. * Creates a decal mesh.
  25009. * Please consider using the same method from the MeshBuilder class instead.
  25010. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25011. * @param name defines the name of the mesh
  25012. * @param sourceMesh defines the mesh receiving the decal
  25013. * @param position sets the position of the decal in world coordinates
  25014. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25015. * @param size sets the decal scaling
  25016. * @param angle sets the angle to rotate the decal
  25017. * @returns a new Mesh
  25018. */
  25019. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25020. /**
  25021. * Prepare internal position array for software CPU skinning
  25022. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25023. */
  25024. setPositionsForCPUSkinning(): Float32Array;
  25025. /**
  25026. * Prepare internal normal array for software CPU skinning
  25027. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25028. */
  25029. setNormalsForCPUSkinning(): Float32Array;
  25030. /**
  25031. * Updates the vertex buffer by applying transformation from the bones
  25032. * @param skeleton defines the skeleton to apply to current mesh
  25033. * @returns the current mesh
  25034. */
  25035. applySkeleton(skeleton: Skeleton): Mesh;
  25036. /**
  25037. * 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
  25038. * @param meshes defines the list of meshes to scan
  25039. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25040. */
  25041. static MinMax(meshes: AbstractMesh[]): {
  25042. min: Vector3;
  25043. max: Vector3;
  25044. };
  25045. /**
  25046. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25047. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25048. * @returns a vector3
  25049. */
  25050. static Center(meshesOrMinMaxVector: {
  25051. min: Vector3;
  25052. max: Vector3;
  25053. } | AbstractMesh[]): Vector3;
  25054. /**
  25055. * Merge the array of meshes into a single mesh for performance reasons.
  25056. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25057. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25058. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25059. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25060. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25061. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25062. * @returns a new mesh
  25063. */
  25064. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25065. /** @hidden */
  25066. addInstance(instance: InstancedMesh): void;
  25067. /** @hidden */
  25068. removeInstance(instance: InstancedMesh): void;
  25069. }
  25070. }
  25071. declare module "babylonjs/Cameras/camera" {
  25072. import { SmartArray } from "babylonjs/Misc/smartArray";
  25073. import { Observable } from "babylonjs/Misc/observable";
  25074. import { Nullable } from "babylonjs/types";
  25075. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25076. import { Scene } from "babylonjs/scene";
  25077. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25078. import { Node } from "babylonjs/node";
  25079. import { Mesh } from "babylonjs/Meshes/mesh";
  25080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25081. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25082. import { Viewport } from "babylonjs/Maths/math.viewport";
  25083. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25085. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25086. import { Ray } from "babylonjs/Culling/ray";
  25087. /**
  25088. * This is the base class of all the camera used in the application.
  25089. * @see http://doc.babylonjs.com/features/cameras
  25090. */
  25091. export class Camera extends Node {
  25092. /** @hidden */
  25093. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25094. /**
  25095. * This is the default projection mode used by the cameras.
  25096. * It helps recreating a feeling of perspective and better appreciate depth.
  25097. * This is the best way to simulate real life cameras.
  25098. */
  25099. static readonly PERSPECTIVE_CAMERA: number;
  25100. /**
  25101. * This helps creating camera with an orthographic mode.
  25102. * 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.
  25103. */
  25104. static readonly ORTHOGRAPHIC_CAMERA: number;
  25105. /**
  25106. * This is the default FOV mode for perspective cameras.
  25107. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25108. */
  25109. static readonly FOVMODE_VERTICAL_FIXED: number;
  25110. /**
  25111. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25112. */
  25113. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25114. /**
  25115. * This specifies ther is no need for a camera rig.
  25116. * Basically only one eye is rendered corresponding to the camera.
  25117. */
  25118. static readonly RIG_MODE_NONE: number;
  25119. /**
  25120. * Simulates a camera Rig with one blue eye and one red eye.
  25121. * This can be use with 3d blue and red glasses.
  25122. */
  25123. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25124. /**
  25125. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25126. */
  25127. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25128. /**
  25129. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25130. */
  25131. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25132. /**
  25133. * Defines that both eyes of the camera will be rendered over under each other.
  25134. */
  25135. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25136. /**
  25137. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25138. */
  25139. static readonly RIG_MODE_VR: number;
  25140. /**
  25141. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25142. */
  25143. static readonly RIG_MODE_WEBVR: number;
  25144. /**
  25145. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25146. */
  25147. static readonly RIG_MODE_CUSTOM: number;
  25148. /**
  25149. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25150. */
  25151. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25152. /**
  25153. * Define the input manager associated with the camera.
  25154. */
  25155. inputs: CameraInputsManager<Camera>;
  25156. /** @hidden */
  25157. _position: Vector3;
  25158. /**
  25159. * Define the current local position of the camera in the scene
  25160. */
  25161. position: Vector3;
  25162. /**
  25163. * The vector the camera should consider as up.
  25164. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25165. */
  25166. upVector: Vector3;
  25167. /**
  25168. * Define the current limit on the left side for an orthographic camera
  25169. * In scene unit
  25170. */
  25171. orthoLeft: Nullable<number>;
  25172. /**
  25173. * Define the current limit on the right side for an orthographic camera
  25174. * In scene unit
  25175. */
  25176. orthoRight: Nullable<number>;
  25177. /**
  25178. * Define the current limit on the bottom side for an orthographic camera
  25179. * In scene unit
  25180. */
  25181. orthoBottom: Nullable<number>;
  25182. /**
  25183. * Define the current limit on the top side for an orthographic camera
  25184. * In scene unit
  25185. */
  25186. orthoTop: Nullable<number>;
  25187. /**
  25188. * Field Of View is set in Radians. (default is 0.8)
  25189. */
  25190. fov: number;
  25191. /**
  25192. * Define the minimum distance the camera can see from.
  25193. * This is important to note that the depth buffer are not infinite and the closer it starts
  25194. * the more your scene might encounter depth fighting issue.
  25195. */
  25196. minZ: number;
  25197. /**
  25198. * Define the maximum distance the camera can see to.
  25199. * This is important to note that the depth buffer are not infinite and the further it end
  25200. * the more your scene might encounter depth fighting issue.
  25201. */
  25202. maxZ: number;
  25203. /**
  25204. * Define the default inertia of the camera.
  25205. * This helps giving a smooth feeling to the camera movement.
  25206. */
  25207. inertia: number;
  25208. /**
  25209. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25210. */
  25211. mode: number;
  25212. /**
  25213. * Define wether the camera is intermediate.
  25214. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25215. */
  25216. isIntermediate: boolean;
  25217. /**
  25218. * Define the viewport of the camera.
  25219. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25220. */
  25221. viewport: Viewport;
  25222. /**
  25223. * Restricts the camera to viewing objects with the same layerMask.
  25224. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25225. */
  25226. layerMask: number;
  25227. /**
  25228. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25229. */
  25230. fovMode: number;
  25231. /**
  25232. * Rig mode of the camera.
  25233. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25234. * This is normally controlled byt the camera themselves as internal use.
  25235. */
  25236. cameraRigMode: number;
  25237. /**
  25238. * Defines the distance between both "eyes" in case of a RIG
  25239. */
  25240. interaxialDistance: number;
  25241. /**
  25242. * Defines if stereoscopic rendering is done side by side or over under.
  25243. */
  25244. isStereoscopicSideBySide: boolean;
  25245. /**
  25246. * 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
  25247. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25248. * else in the scene. (Eg. security camera)
  25249. *
  25250. * 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)
  25251. */
  25252. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25253. /**
  25254. * When set, the camera will render to this render target instead of the default canvas
  25255. *
  25256. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25257. */
  25258. outputRenderTarget: Nullable<RenderTargetTexture>;
  25259. /**
  25260. * Observable triggered when the camera view matrix has changed.
  25261. */
  25262. onViewMatrixChangedObservable: Observable<Camera>;
  25263. /**
  25264. * Observable triggered when the camera Projection matrix has changed.
  25265. */
  25266. onProjectionMatrixChangedObservable: Observable<Camera>;
  25267. /**
  25268. * Observable triggered when the inputs have been processed.
  25269. */
  25270. onAfterCheckInputsObservable: Observable<Camera>;
  25271. /**
  25272. * Observable triggered when reset has been called and applied to the camera.
  25273. */
  25274. onRestoreStateObservable: Observable<Camera>;
  25275. /** @hidden */
  25276. _cameraRigParams: any;
  25277. /** @hidden */
  25278. _rigCameras: Camera[];
  25279. /** @hidden */
  25280. _rigPostProcess: Nullable<PostProcess>;
  25281. protected _webvrViewMatrix: Matrix;
  25282. /** @hidden */
  25283. _skipRendering: boolean;
  25284. /** @hidden */
  25285. _projectionMatrix: Matrix;
  25286. /** @hidden */
  25287. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25288. /** @hidden */
  25289. _activeMeshes: SmartArray<AbstractMesh>;
  25290. protected _globalPosition: Vector3;
  25291. /** @hidden */
  25292. _computedViewMatrix: Matrix;
  25293. private _doNotComputeProjectionMatrix;
  25294. private _transformMatrix;
  25295. private _frustumPlanes;
  25296. private _refreshFrustumPlanes;
  25297. private _storedFov;
  25298. private _stateStored;
  25299. /**
  25300. * Instantiates a new camera object.
  25301. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25302. * @see http://doc.babylonjs.com/features/cameras
  25303. * @param name Defines the name of the camera in the scene
  25304. * @param position Defines the position of the camera
  25305. * @param scene Defines the scene the camera belongs too
  25306. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25307. */
  25308. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25309. /**
  25310. * Store current camera state (fov, position, etc..)
  25311. * @returns the camera
  25312. */
  25313. storeState(): Camera;
  25314. /**
  25315. * Restores the camera state values if it has been stored. You must call storeState() first
  25316. */
  25317. protected _restoreStateValues(): boolean;
  25318. /**
  25319. * Restored camera state. You must call storeState() first.
  25320. * @returns true if restored and false otherwise
  25321. */
  25322. restoreState(): boolean;
  25323. /**
  25324. * Gets the class name of the camera.
  25325. * @returns the class name
  25326. */
  25327. getClassName(): string;
  25328. /** @hidden */
  25329. readonly _isCamera: boolean;
  25330. /**
  25331. * Gets a string representation of the camera useful for debug purpose.
  25332. * @param fullDetails Defines that a more verboe level of logging is required
  25333. * @returns the string representation
  25334. */
  25335. toString(fullDetails?: boolean): string;
  25336. /**
  25337. * Gets the current world space position of the camera.
  25338. */
  25339. readonly globalPosition: Vector3;
  25340. /**
  25341. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25342. * @returns the active meshe list
  25343. */
  25344. getActiveMeshes(): SmartArray<AbstractMesh>;
  25345. /**
  25346. * Check wether a mesh is part of the current active mesh list of the camera
  25347. * @param mesh Defines the mesh to check
  25348. * @returns true if active, false otherwise
  25349. */
  25350. isActiveMesh(mesh: Mesh): boolean;
  25351. /**
  25352. * Is this camera ready to be used/rendered
  25353. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25354. * @return true if the camera is ready
  25355. */
  25356. isReady(completeCheck?: boolean): boolean;
  25357. /** @hidden */
  25358. _initCache(): void;
  25359. /** @hidden */
  25360. _updateCache(ignoreParentClass?: boolean): void;
  25361. /** @hidden */
  25362. _isSynchronized(): boolean;
  25363. /** @hidden */
  25364. _isSynchronizedViewMatrix(): boolean;
  25365. /** @hidden */
  25366. _isSynchronizedProjectionMatrix(): boolean;
  25367. /**
  25368. * Attach the input controls to a specific dom element to get the input from.
  25369. * @param element Defines the element the controls should be listened from
  25370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25371. */
  25372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25373. /**
  25374. * Detach the current controls from the specified dom element.
  25375. * @param element Defines the element to stop listening the inputs from
  25376. */
  25377. detachControl(element: HTMLElement): void;
  25378. /**
  25379. * Update the camera state according to the different inputs gathered during the frame.
  25380. */
  25381. update(): void;
  25382. /** @hidden */
  25383. _checkInputs(): void;
  25384. /** @hidden */
  25385. readonly rigCameras: Camera[];
  25386. /**
  25387. * Gets the post process used by the rig cameras
  25388. */
  25389. readonly rigPostProcess: Nullable<PostProcess>;
  25390. /**
  25391. * Internal, gets the first post proces.
  25392. * @returns the first post process to be run on this camera.
  25393. */
  25394. _getFirstPostProcess(): Nullable<PostProcess>;
  25395. private _cascadePostProcessesToRigCams;
  25396. /**
  25397. * Attach a post process to the camera.
  25398. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25399. * @param postProcess The post process to attach to the camera
  25400. * @param insertAt The position of the post process in case several of them are in use in the scene
  25401. * @returns the position the post process has been inserted at
  25402. */
  25403. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25404. /**
  25405. * Detach a post process to the camera.
  25406. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25407. * @param postProcess The post process to detach from the camera
  25408. */
  25409. detachPostProcess(postProcess: PostProcess): void;
  25410. /**
  25411. * Gets the current world matrix of the camera
  25412. */
  25413. getWorldMatrix(): Matrix;
  25414. /** @hidden */
  25415. _getViewMatrix(): Matrix;
  25416. /**
  25417. * Gets the current view matrix of the camera.
  25418. * @param force forces the camera to recompute the matrix without looking at the cached state
  25419. * @returns the view matrix
  25420. */
  25421. getViewMatrix(force?: boolean): Matrix;
  25422. /**
  25423. * Freeze the projection matrix.
  25424. * It will prevent the cache check of the camera projection compute and can speed up perf
  25425. * if no parameter of the camera are meant to change
  25426. * @param projection Defines manually a projection if necessary
  25427. */
  25428. freezeProjectionMatrix(projection?: Matrix): void;
  25429. /**
  25430. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25431. */
  25432. unfreezeProjectionMatrix(): void;
  25433. /**
  25434. * Gets the current projection matrix of the camera.
  25435. * @param force forces the camera to recompute the matrix without looking at the cached state
  25436. * @returns the projection matrix
  25437. */
  25438. getProjectionMatrix(force?: boolean): Matrix;
  25439. /**
  25440. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25441. * @returns a Matrix
  25442. */
  25443. getTransformationMatrix(): Matrix;
  25444. private _updateFrustumPlanes;
  25445. /**
  25446. * Checks if a cullable object (mesh...) is in the camera frustum
  25447. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25448. * @param target The object to check
  25449. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25450. * @returns true if the object is in frustum otherwise false
  25451. */
  25452. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25453. /**
  25454. * Checks if a cullable object (mesh...) is in the camera frustum
  25455. * Unlike isInFrustum this cheks the full bounding box
  25456. * @param target The object to check
  25457. * @returns true if the object is in frustum otherwise false
  25458. */
  25459. isCompletelyInFrustum(target: ICullable): boolean;
  25460. /**
  25461. * Gets a ray in the forward direction from the camera.
  25462. * @param length Defines the length of the ray to create
  25463. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25464. * @param origin Defines the start point of the ray which defaults to the camera position
  25465. * @returns the forward ray
  25466. */
  25467. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25468. /**
  25469. * Releases resources associated with this node.
  25470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25472. */
  25473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25474. /** @hidden */
  25475. _isLeftCamera: boolean;
  25476. /**
  25477. * Gets the left camera of a rig setup in case of Rigged Camera
  25478. */
  25479. readonly isLeftCamera: boolean;
  25480. /** @hidden */
  25481. _isRightCamera: boolean;
  25482. /**
  25483. * Gets the right camera of a rig setup in case of Rigged Camera
  25484. */
  25485. readonly isRightCamera: boolean;
  25486. /**
  25487. * Gets the left camera of a rig setup in case of Rigged Camera
  25488. */
  25489. readonly leftCamera: Nullable<FreeCamera>;
  25490. /**
  25491. * Gets the right camera of a rig setup in case of Rigged Camera
  25492. */
  25493. readonly rightCamera: Nullable<FreeCamera>;
  25494. /**
  25495. * Gets the left camera target of a rig setup in case of Rigged Camera
  25496. * @returns the target position
  25497. */
  25498. getLeftTarget(): Nullable<Vector3>;
  25499. /**
  25500. * Gets the right camera target of a rig setup in case of Rigged Camera
  25501. * @returns the target position
  25502. */
  25503. getRightTarget(): Nullable<Vector3>;
  25504. /**
  25505. * @hidden
  25506. */
  25507. setCameraRigMode(mode: number, rigParams: any): void;
  25508. /** @hidden */
  25509. static _setStereoscopicRigMode(camera: Camera): void;
  25510. /** @hidden */
  25511. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25512. /** @hidden */
  25513. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25514. /** @hidden */
  25515. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25516. /** @hidden */
  25517. _getVRProjectionMatrix(): Matrix;
  25518. protected _updateCameraRotationMatrix(): void;
  25519. protected _updateWebVRCameraRotationMatrix(): void;
  25520. /**
  25521. * This function MUST be overwritten by the different WebVR cameras available.
  25522. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25523. * @hidden
  25524. */
  25525. _getWebVRProjectionMatrix(): Matrix;
  25526. /**
  25527. * This function MUST be overwritten by the different WebVR cameras available.
  25528. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25529. * @hidden
  25530. */
  25531. _getWebVRViewMatrix(): Matrix;
  25532. /** @hidden */
  25533. setCameraRigParameter(name: string, value: any): void;
  25534. /**
  25535. * needs to be overridden by children so sub has required properties to be copied
  25536. * @hidden
  25537. */
  25538. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25539. /**
  25540. * May need to be overridden by children
  25541. * @hidden
  25542. */
  25543. _updateRigCameras(): void;
  25544. /** @hidden */
  25545. _setupInputs(): void;
  25546. /**
  25547. * Serialiaze the camera setup to a json represention
  25548. * @returns the JSON representation
  25549. */
  25550. serialize(): any;
  25551. /**
  25552. * Clones the current camera.
  25553. * @param name The cloned camera name
  25554. * @returns the cloned camera
  25555. */
  25556. clone(name: string): Camera;
  25557. /**
  25558. * Gets the direction of the camera relative to a given local axis.
  25559. * @param localAxis Defines the reference axis to provide a relative direction.
  25560. * @return the direction
  25561. */
  25562. getDirection(localAxis: Vector3): Vector3;
  25563. /**
  25564. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25565. * @param localAxis Defines the reference axis to provide a relative direction.
  25566. * @param result Defines the vector to store the result in
  25567. */
  25568. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25569. /**
  25570. * Gets a camera constructor for a given camera type
  25571. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25572. * @param name The name of the camera the result will be able to instantiate
  25573. * @param scene The scene the result will construct the camera in
  25574. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25575. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25576. * @returns a factory method to construc the camera
  25577. */
  25578. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25579. /**
  25580. * Compute the world matrix of the camera.
  25581. * @returns the camera workd matrix
  25582. */
  25583. computeWorldMatrix(): Matrix;
  25584. /**
  25585. * Parse a JSON and creates the camera from the parsed information
  25586. * @param parsedCamera The JSON to parse
  25587. * @param scene The scene to instantiate the camera in
  25588. * @returns the newly constructed camera
  25589. */
  25590. static Parse(parsedCamera: any, scene: Scene): Camera;
  25591. }
  25592. }
  25593. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25594. import { Nullable } from "babylonjs/types";
  25595. import { Scene } from "babylonjs/scene";
  25596. import { Vector4 } from "babylonjs/Maths/math.vector";
  25597. import { Mesh } from "babylonjs/Meshes/mesh";
  25598. /**
  25599. * Class containing static functions to help procedurally build meshes
  25600. */
  25601. export class DiscBuilder {
  25602. /**
  25603. * Creates a plane polygonal mesh. By default, this is a disc
  25604. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25605. * * 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
  25606. * * 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
  25607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25610. * @param name defines the name of the mesh
  25611. * @param options defines the options used to create the mesh
  25612. * @param scene defines the hosting scene
  25613. * @returns the plane polygonal mesh
  25614. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25615. */
  25616. static CreateDisc(name: string, options: {
  25617. radius?: number;
  25618. tessellation?: number;
  25619. arc?: number;
  25620. updatable?: boolean;
  25621. sideOrientation?: number;
  25622. frontUVs?: Vector4;
  25623. backUVs?: Vector4;
  25624. }, scene?: Nullable<Scene>): Mesh;
  25625. }
  25626. }
  25627. declare module "babylonjs/Particles/solidParticleSystem" {
  25628. import { Vector3 } from "babylonjs/Maths/math.vector";
  25629. import { Mesh } from "babylonjs/Meshes/mesh";
  25630. import { Scene, IDisposable } from "babylonjs/scene";
  25631. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25632. /**
  25633. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25634. *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.
  25635. * The SPS is also a particle system. It provides some methods to manage the particles.
  25636. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25637. *
  25638. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25639. */
  25640. export class SolidParticleSystem implements IDisposable {
  25641. /**
  25642. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25643. * Example : var p = SPS.particles[i];
  25644. */
  25645. particles: SolidParticle[];
  25646. /**
  25647. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25648. */
  25649. nbParticles: number;
  25650. /**
  25651. * If the particles must ever face the camera (default false). Useful for planar particles.
  25652. */
  25653. billboard: boolean;
  25654. /**
  25655. * Recompute normals when adding a shape
  25656. */
  25657. recomputeNormals: boolean;
  25658. /**
  25659. * This a counter ofr your own usage. It's not set by any SPS functions.
  25660. */
  25661. counter: number;
  25662. /**
  25663. * The SPS name. This name is also given to the underlying mesh.
  25664. */
  25665. name: string;
  25666. /**
  25667. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25668. */
  25669. mesh: Mesh;
  25670. /**
  25671. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25672. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25673. */
  25674. vars: any;
  25675. /**
  25676. * This array is populated when the SPS is set as 'pickable'.
  25677. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25678. * Each element of this array is an object `{idx: int, faceId: int}`.
  25679. * `idx` is the picked particle index in the `SPS.particles` array
  25680. * `faceId` is the picked face index counted within this particle.
  25681. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25682. */
  25683. pickedParticles: {
  25684. idx: number;
  25685. faceId: number;
  25686. }[];
  25687. /**
  25688. * This array is populated when `enableDepthSort` is set to true.
  25689. * Each element of this array is an instance of the class DepthSortedParticle.
  25690. */
  25691. depthSortedParticles: DepthSortedParticle[];
  25692. /**
  25693. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25694. * @hidden
  25695. */
  25696. _bSphereOnly: boolean;
  25697. /**
  25698. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25699. * @hidden
  25700. */
  25701. _bSphereRadiusFactor: number;
  25702. private _scene;
  25703. private _positions;
  25704. private _indices;
  25705. private _normals;
  25706. private _colors;
  25707. private _uvs;
  25708. private _indices32;
  25709. private _positions32;
  25710. private _normals32;
  25711. private _fixedNormal32;
  25712. private _colors32;
  25713. private _uvs32;
  25714. private _index;
  25715. private _updatable;
  25716. private _pickable;
  25717. private _isVisibilityBoxLocked;
  25718. private _alwaysVisible;
  25719. private _depthSort;
  25720. private _shapeCounter;
  25721. private _copy;
  25722. private _color;
  25723. private _computeParticleColor;
  25724. private _computeParticleTexture;
  25725. private _computeParticleRotation;
  25726. private _computeParticleVertex;
  25727. private _computeBoundingBox;
  25728. private _depthSortParticles;
  25729. private _camera;
  25730. private _mustUnrotateFixedNormals;
  25731. private _particlesIntersect;
  25732. private _needs32Bits;
  25733. /**
  25734. * Creates a SPS (Solid Particle System) object.
  25735. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25736. * @param scene (Scene) is the scene in which the SPS is added.
  25737. * @param options defines the options of the sps e.g.
  25738. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25739. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25740. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25741. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25742. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25743. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25744. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25745. */
  25746. constructor(name: string, scene: Scene, options?: {
  25747. updatable?: boolean;
  25748. isPickable?: boolean;
  25749. enableDepthSort?: boolean;
  25750. particleIntersection?: boolean;
  25751. boundingSphereOnly?: boolean;
  25752. bSphereRadiusFactor?: number;
  25753. });
  25754. /**
  25755. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25756. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25757. * @returns the created mesh
  25758. */
  25759. buildMesh(): Mesh;
  25760. /**
  25761. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25762. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25763. * Thus the particles generated from `digest()` have their property `position` set yet.
  25764. * @param mesh ( Mesh ) is the mesh to be digested
  25765. * @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
  25766. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25767. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25768. * @returns the current SPS
  25769. */
  25770. digest(mesh: Mesh, options?: {
  25771. facetNb?: number;
  25772. number?: number;
  25773. delta?: number;
  25774. }): SolidParticleSystem;
  25775. private _unrotateFixedNormals;
  25776. private _resetCopy;
  25777. private _meshBuilder;
  25778. private _posToShape;
  25779. private _uvsToShapeUV;
  25780. private _addParticle;
  25781. /**
  25782. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25783. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25784. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25785. * @param nb (positive integer) the number of particles to be created from this model
  25786. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25787. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25788. * @returns the number of shapes in the system
  25789. */
  25790. addShape(mesh: Mesh, nb: number, options?: {
  25791. positionFunction?: any;
  25792. vertexFunction?: any;
  25793. }): number;
  25794. private _rebuildParticle;
  25795. /**
  25796. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25797. * @returns the SPS.
  25798. */
  25799. rebuildMesh(): SolidParticleSystem;
  25800. /**
  25801. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25802. * This method calls `updateParticle()` for each particle of the SPS.
  25803. * For an animated SPS, it is usually called within the render loop.
  25804. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25805. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25806. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25807. * @returns the SPS.
  25808. */
  25809. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25810. /**
  25811. * Disposes the SPS.
  25812. */
  25813. dispose(): void;
  25814. /**
  25815. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25816. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25817. * @returns the SPS.
  25818. */
  25819. refreshVisibleSize(): SolidParticleSystem;
  25820. /**
  25821. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25822. * @param size the size (float) of the visibility box
  25823. * note : this doesn't lock the SPS mesh bounding box.
  25824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25825. */
  25826. setVisibilityBox(size: number): void;
  25827. /**
  25828. * Gets whether the SPS as always visible or not
  25829. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25830. */
  25831. /**
  25832. * Sets the SPS as always visible or not
  25833. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25834. */
  25835. isAlwaysVisible: boolean;
  25836. /**
  25837. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25838. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25839. */
  25840. /**
  25841. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25842. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25843. */
  25844. isVisibilityBoxLocked: boolean;
  25845. /**
  25846. * Tells to `setParticles()` to compute the particle rotations or not.
  25847. * Default value : true. The SPS is faster when it's set to false.
  25848. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25849. */
  25850. /**
  25851. * Gets if `setParticles()` computes the particle rotations or not.
  25852. * Default value : true. The SPS is faster when it's set to false.
  25853. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25854. */
  25855. computeParticleRotation: boolean;
  25856. /**
  25857. * Tells to `setParticles()` to compute the particle colors or not.
  25858. * Default value : true. The SPS is faster when it's set to false.
  25859. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25860. */
  25861. /**
  25862. * Gets if `setParticles()` computes the particle colors or not.
  25863. * Default value : true. The SPS is faster when it's set to false.
  25864. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25865. */
  25866. computeParticleColor: boolean;
  25867. /**
  25868. * Gets if `setParticles()` computes the particle textures or not.
  25869. * Default value : true. The SPS is faster when it's set to false.
  25870. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25871. */
  25872. computeParticleTexture: boolean;
  25873. /**
  25874. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25875. * Default value : false. The SPS is faster when it's set to false.
  25876. * Note : the particle custom vertex positions aren't stored values.
  25877. */
  25878. /**
  25879. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25880. * Default value : false. The SPS is faster when it's set to false.
  25881. * Note : the particle custom vertex positions aren't stored values.
  25882. */
  25883. computeParticleVertex: boolean;
  25884. /**
  25885. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25886. */
  25887. /**
  25888. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25889. */
  25890. computeBoundingBox: boolean;
  25891. /**
  25892. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25893. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25894. * Default : `true`
  25895. */
  25896. /**
  25897. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25898. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25899. * Default : `true`
  25900. */
  25901. depthSortParticles: boolean;
  25902. /**
  25903. * This function does nothing. It may be overwritten to set all the particle first values.
  25904. * The SPS doesn't call this function, you may have to call it by your own.
  25905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25906. */
  25907. initParticles(): void;
  25908. /**
  25909. * This function does nothing. It may be overwritten to recycle a particle.
  25910. * The SPS doesn't call this function, you may have to call it by your own.
  25911. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25912. * @param particle The particle to recycle
  25913. * @returns the recycled particle
  25914. */
  25915. recycleParticle(particle: SolidParticle): SolidParticle;
  25916. /**
  25917. * Updates a particle : this function should be overwritten by the user.
  25918. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25919. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25920. * @example : just set a particle position or velocity and recycle conditions
  25921. * @param particle The particle to update
  25922. * @returns the updated particle
  25923. */
  25924. updateParticle(particle: SolidParticle): SolidParticle;
  25925. /**
  25926. * Updates a vertex of a particle : it can be overwritten by the user.
  25927. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25928. * @param particle the current particle
  25929. * @param vertex the current index of the current particle
  25930. * @param pt the index of the current vertex in the particle shape
  25931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25932. * @example : just set a vertex particle position
  25933. * @returns the updated vertex
  25934. */
  25935. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25936. /**
  25937. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25938. * This does nothing and may be overwritten by the user.
  25939. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25940. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25941. * @param update the boolean update value actually passed to setParticles()
  25942. */
  25943. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25944. /**
  25945. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25946. * This will be passed three parameters.
  25947. * This does nothing and may be overwritten by the user.
  25948. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25949. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25950. * @param update the boolean update value actually passed to setParticles()
  25951. */
  25952. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25953. }
  25954. }
  25955. declare module "babylonjs/Particles/solidParticle" {
  25956. import { Nullable } from "babylonjs/types";
  25957. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25958. import { Color4 } from "babylonjs/Maths/math.color";
  25959. import { Mesh } from "babylonjs/Meshes/mesh";
  25960. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25961. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25962. import { Plane } from "babylonjs/Maths/math.plane";
  25963. /**
  25964. * Represents one particle of a solid particle system.
  25965. */
  25966. export class SolidParticle {
  25967. /**
  25968. * particle global index
  25969. */
  25970. idx: number;
  25971. /**
  25972. * The color of the particle
  25973. */
  25974. color: Nullable<Color4>;
  25975. /**
  25976. * The world space position of the particle.
  25977. */
  25978. position: Vector3;
  25979. /**
  25980. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25981. */
  25982. rotation: Vector3;
  25983. /**
  25984. * The world space rotation quaternion of the particle.
  25985. */
  25986. rotationQuaternion: Nullable<Quaternion>;
  25987. /**
  25988. * The scaling of the particle.
  25989. */
  25990. scaling: Vector3;
  25991. /**
  25992. * The uvs of the particle.
  25993. */
  25994. uvs: Vector4;
  25995. /**
  25996. * The current speed of the particle.
  25997. */
  25998. velocity: Vector3;
  25999. /**
  26000. * The pivot point in the particle local space.
  26001. */
  26002. pivot: Vector3;
  26003. /**
  26004. * Must the particle be translated from its pivot point in its local space ?
  26005. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26006. * Default : false
  26007. */
  26008. translateFromPivot: boolean;
  26009. /**
  26010. * Is the particle active or not ?
  26011. */
  26012. alive: boolean;
  26013. /**
  26014. * Is the particle visible or not ?
  26015. */
  26016. isVisible: boolean;
  26017. /**
  26018. * Index of this particle in the global "positions" array (Internal use)
  26019. * @hidden
  26020. */
  26021. _pos: number;
  26022. /**
  26023. * @hidden Index of this particle in the global "indices" array (Internal use)
  26024. */
  26025. _ind: number;
  26026. /**
  26027. * @hidden ModelShape of this particle (Internal use)
  26028. */
  26029. _model: ModelShape;
  26030. /**
  26031. * ModelShape id of this particle
  26032. */
  26033. shapeId: number;
  26034. /**
  26035. * Index of the particle in its shape id (Internal use)
  26036. */
  26037. idxInShape: number;
  26038. /**
  26039. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26040. */
  26041. _modelBoundingInfo: BoundingInfo;
  26042. /**
  26043. * @hidden Particle BoundingInfo object (Internal use)
  26044. */
  26045. _boundingInfo: BoundingInfo;
  26046. /**
  26047. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26048. */
  26049. _sps: SolidParticleSystem;
  26050. /**
  26051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26052. */
  26053. _stillInvisible: boolean;
  26054. /**
  26055. * @hidden Last computed particle rotation matrix
  26056. */
  26057. _rotationMatrix: number[];
  26058. /**
  26059. * Parent particle Id, if any.
  26060. * Default null.
  26061. */
  26062. parentId: Nullable<number>;
  26063. /**
  26064. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26065. * The possible values are :
  26066. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26067. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26070. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26071. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26072. * */
  26073. cullingStrategy: number;
  26074. /**
  26075. * @hidden Internal global position in the SPS.
  26076. */
  26077. _globalPosition: Vector3;
  26078. /**
  26079. * Creates a Solid Particle object.
  26080. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26081. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26082. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26083. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26084. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26085. * @param shapeId (integer) is the model shape identifier in the SPS.
  26086. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26087. * @param sps defines the sps it is associated to
  26088. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26089. */
  26090. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26091. /**
  26092. * Legacy support, changed scale to scaling
  26093. */
  26094. /**
  26095. * Legacy support, changed scale to scaling
  26096. */
  26097. scale: Vector3;
  26098. /**
  26099. * Legacy support, changed quaternion to rotationQuaternion
  26100. */
  26101. /**
  26102. * Legacy support, changed quaternion to rotationQuaternion
  26103. */
  26104. quaternion: Nullable<Quaternion>;
  26105. /**
  26106. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26107. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26108. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26109. * @returns true if it intersects
  26110. */
  26111. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26112. /**
  26113. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26114. * A particle is in the frustum if its bounding box intersects the frustum
  26115. * @param frustumPlanes defines the frustum to test
  26116. * @returns true if the particle is in the frustum planes
  26117. */
  26118. isInFrustum(frustumPlanes: Plane[]): boolean;
  26119. /**
  26120. * get the rotation matrix of the particle
  26121. * @hidden
  26122. */
  26123. getRotationMatrix(m: Matrix): void;
  26124. }
  26125. /**
  26126. * Represents the shape of the model used by one particle of a solid particle system.
  26127. * SPS internal tool, don't use it manually.
  26128. */
  26129. export class ModelShape {
  26130. /**
  26131. * The shape id
  26132. * @hidden
  26133. */
  26134. shapeID: number;
  26135. /**
  26136. * flat array of model positions (internal use)
  26137. * @hidden
  26138. */
  26139. _shape: Vector3[];
  26140. /**
  26141. * flat array of model UVs (internal use)
  26142. * @hidden
  26143. */
  26144. _shapeUV: number[];
  26145. /**
  26146. * length of the shape in the model indices array (internal use)
  26147. * @hidden
  26148. */
  26149. _indicesLength: number;
  26150. /**
  26151. * Custom position function (internal use)
  26152. * @hidden
  26153. */
  26154. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26155. /**
  26156. * Custom vertex function (internal use)
  26157. * @hidden
  26158. */
  26159. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26160. /**
  26161. * 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.
  26162. * SPS internal tool, don't use it manually.
  26163. * @hidden
  26164. */
  26165. 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>);
  26166. }
  26167. /**
  26168. * Represents a Depth Sorted Particle in the solid particle system.
  26169. */
  26170. export class DepthSortedParticle {
  26171. /**
  26172. * Index of the particle in the "indices" array
  26173. */
  26174. ind: number;
  26175. /**
  26176. * Length of the particle shape in the "indices" array
  26177. */
  26178. indicesLength: number;
  26179. /**
  26180. * Squared distance from the particle to the camera
  26181. */
  26182. sqDistance: number;
  26183. }
  26184. }
  26185. declare module "babylonjs/Collisions/meshCollisionData" {
  26186. import { Collider } from "babylonjs/Collisions/collider";
  26187. import { Vector3 } from "babylonjs/Maths/math.vector";
  26188. import { Nullable } from "babylonjs/types";
  26189. import { Observer } from "babylonjs/Misc/observable";
  26190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26191. /**
  26192. * @hidden
  26193. */
  26194. export class _MeshCollisionData {
  26195. _checkCollisions: boolean;
  26196. _collisionMask: number;
  26197. _collisionGroup: number;
  26198. _collider: Nullable<Collider>;
  26199. _oldPositionForCollisions: Vector3;
  26200. _diffPositionForCollisions: Vector3;
  26201. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26202. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26203. }
  26204. }
  26205. declare module "babylonjs/Meshes/abstractMesh" {
  26206. import { Observable } from "babylonjs/Misc/observable";
  26207. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26208. import { Camera } from "babylonjs/Cameras/camera";
  26209. import { Scene, IDisposable } from "babylonjs/scene";
  26210. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26211. import { Node } from "babylonjs/node";
  26212. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26215. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26216. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26217. import { Material } from "babylonjs/Materials/material";
  26218. import { Light } from "babylonjs/Lights/light";
  26219. import { Skeleton } from "babylonjs/Bones/skeleton";
  26220. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26221. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26222. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26223. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26224. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26225. import { Plane } from "babylonjs/Maths/math.plane";
  26226. import { Ray } from "babylonjs/Culling/ray";
  26227. import { Collider } from "babylonjs/Collisions/collider";
  26228. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26229. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26230. /** @hidden */
  26231. class _FacetDataStorage {
  26232. facetPositions: Vector3[];
  26233. facetNormals: Vector3[];
  26234. facetPartitioning: number[][];
  26235. facetNb: number;
  26236. partitioningSubdivisions: number;
  26237. partitioningBBoxRatio: number;
  26238. facetDataEnabled: boolean;
  26239. facetParameters: any;
  26240. bbSize: Vector3;
  26241. subDiv: {
  26242. max: number;
  26243. X: number;
  26244. Y: number;
  26245. Z: number;
  26246. };
  26247. facetDepthSort: boolean;
  26248. facetDepthSortEnabled: boolean;
  26249. depthSortedIndices: IndicesArray;
  26250. depthSortedFacets: {
  26251. ind: number;
  26252. sqDistance: number;
  26253. }[];
  26254. facetDepthSortFunction: (f1: {
  26255. ind: number;
  26256. sqDistance: number;
  26257. }, f2: {
  26258. ind: number;
  26259. sqDistance: number;
  26260. }) => number;
  26261. facetDepthSortFrom: Vector3;
  26262. facetDepthSortOrigin: Vector3;
  26263. invertedMatrix: Matrix;
  26264. }
  26265. /**
  26266. * @hidden
  26267. **/
  26268. class _InternalAbstractMeshDataInfo {
  26269. _hasVertexAlpha: boolean;
  26270. _useVertexColors: boolean;
  26271. _numBoneInfluencers: number;
  26272. _applyFog: boolean;
  26273. _receiveShadows: boolean;
  26274. _facetData: _FacetDataStorage;
  26275. _visibility: number;
  26276. _skeleton: Nullable<Skeleton>;
  26277. _layerMask: number;
  26278. _computeBonesUsingShaders: boolean;
  26279. _isActive: boolean;
  26280. _onlyForInstances: boolean;
  26281. _isActiveIntermediate: boolean;
  26282. _onlyForInstancesIntermediate: boolean;
  26283. }
  26284. /**
  26285. * Class used to store all common mesh properties
  26286. */
  26287. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26288. /** No occlusion */
  26289. static OCCLUSION_TYPE_NONE: number;
  26290. /** Occlusion set to optimisitic */
  26291. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26292. /** Occlusion set to strict */
  26293. static OCCLUSION_TYPE_STRICT: number;
  26294. /** Use an accurante occlusion algorithm */
  26295. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26296. /** Use a conservative occlusion algorithm */
  26297. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26298. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26299. * Test order :
  26300. * Is the bounding sphere outside the frustum ?
  26301. * If not, are the bounding box vertices outside the frustum ?
  26302. * It not, then the cullable object is in the frustum.
  26303. */
  26304. static readonly CULLINGSTRATEGY_STANDARD: number;
  26305. /** Culling strategy : Bounding Sphere Only.
  26306. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26307. * It's also less accurate than the standard because some not visible objects can still be selected.
  26308. * Test : is the bounding sphere outside the frustum ?
  26309. * If not, then the cullable object is in the frustum.
  26310. */
  26311. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26312. /** Culling strategy : Optimistic Inclusion.
  26313. * This in an inclusion test first, then the standard exclusion test.
  26314. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26315. * 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.
  26316. * Anyway, it's as accurate as the standard strategy.
  26317. * Test :
  26318. * Is the cullable object bounding sphere center in the frustum ?
  26319. * If not, apply the default culling strategy.
  26320. */
  26321. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26322. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26323. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26324. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26325. * 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.
  26326. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26327. * Test :
  26328. * Is the cullable object bounding sphere center in the frustum ?
  26329. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26330. */
  26331. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26332. /**
  26333. * No billboard
  26334. */
  26335. static readonly BILLBOARDMODE_NONE: number;
  26336. /** Billboard on X axis */
  26337. static readonly BILLBOARDMODE_X: number;
  26338. /** Billboard on Y axis */
  26339. static readonly BILLBOARDMODE_Y: number;
  26340. /** Billboard on Z axis */
  26341. static readonly BILLBOARDMODE_Z: number;
  26342. /** Billboard on all axes */
  26343. static readonly BILLBOARDMODE_ALL: number;
  26344. /** Billboard on using position instead of orientation */
  26345. static readonly BILLBOARDMODE_USE_POSITION: number;
  26346. /** @hidden */
  26347. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26348. /**
  26349. * The culling strategy to use to check whether the mesh must be rendered or not.
  26350. * This value can be changed at any time and will be used on the next render mesh selection.
  26351. * The possible values are :
  26352. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26353. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26354. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26356. * Please read each static variable documentation to get details about the culling process.
  26357. * */
  26358. cullingStrategy: number;
  26359. /**
  26360. * Gets the number of facets in the mesh
  26361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26362. */
  26363. readonly facetNb: number;
  26364. /**
  26365. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26367. */
  26368. partitioningSubdivisions: number;
  26369. /**
  26370. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26371. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26373. */
  26374. partitioningBBoxRatio: number;
  26375. /**
  26376. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26377. * Works only for updatable meshes.
  26378. * Doesn't work with multi-materials
  26379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26380. */
  26381. mustDepthSortFacets: boolean;
  26382. /**
  26383. * The location (Vector3) where the facet depth sort must be computed from.
  26384. * By default, the active camera position.
  26385. * Used only when facet depth sort is enabled
  26386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26387. */
  26388. facetDepthSortFrom: Vector3;
  26389. /**
  26390. * gets a boolean indicating if facetData is enabled
  26391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26392. */
  26393. readonly isFacetDataEnabled: boolean;
  26394. /** @hidden */
  26395. _updateNonUniformScalingState(value: boolean): boolean;
  26396. /**
  26397. * An event triggered when this mesh collides with another one
  26398. */
  26399. onCollideObservable: Observable<AbstractMesh>;
  26400. /** Set a function to call when this mesh collides with another one */
  26401. onCollide: () => void;
  26402. /**
  26403. * An event triggered when the collision's position changes
  26404. */
  26405. onCollisionPositionChangeObservable: Observable<Vector3>;
  26406. /** Set a function to call when the collision's position changes */
  26407. onCollisionPositionChange: () => void;
  26408. /**
  26409. * An event triggered when material is changed
  26410. */
  26411. onMaterialChangedObservable: Observable<AbstractMesh>;
  26412. /**
  26413. * Gets or sets the orientation for POV movement & rotation
  26414. */
  26415. definedFacingForward: boolean;
  26416. /** @hidden */
  26417. _occlusionQuery: Nullable<WebGLQuery>;
  26418. /** @hidden */
  26419. _renderingGroup: Nullable<RenderingGroup>;
  26420. /**
  26421. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26422. */
  26423. /**
  26424. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26425. */
  26426. visibility: number;
  26427. /** Gets or sets the alpha index used to sort transparent meshes
  26428. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26429. */
  26430. alphaIndex: number;
  26431. /**
  26432. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26433. */
  26434. isVisible: boolean;
  26435. /**
  26436. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26437. */
  26438. isPickable: boolean;
  26439. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26440. showSubMeshesBoundingBox: boolean;
  26441. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26443. */
  26444. isBlocker: boolean;
  26445. /**
  26446. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26447. */
  26448. enablePointerMoveEvents: boolean;
  26449. /**
  26450. * Specifies the rendering group id for this mesh (0 by default)
  26451. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26452. */
  26453. renderingGroupId: number;
  26454. private _material;
  26455. /** Gets or sets current material */
  26456. material: Nullable<Material>;
  26457. /**
  26458. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26459. * @see http://doc.babylonjs.com/babylon101/shadows
  26460. */
  26461. receiveShadows: boolean;
  26462. /** Defines color to use when rendering outline */
  26463. outlineColor: Color3;
  26464. /** Define width to use when rendering outline */
  26465. outlineWidth: number;
  26466. /** Defines color to use when rendering overlay */
  26467. overlayColor: Color3;
  26468. /** Defines alpha to use when rendering overlay */
  26469. overlayAlpha: number;
  26470. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26471. hasVertexAlpha: boolean;
  26472. /** 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) */
  26473. useVertexColors: boolean;
  26474. /**
  26475. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26476. */
  26477. computeBonesUsingShaders: boolean;
  26478. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26479. numBoneInfluencers: number;
  26480. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26481. applyFog: boolean;
  26482. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26483. useOctreeForRenderingSelection: boolean;
  26484. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26485. useOctreeForPicking: boolean;
  26486. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26487. useOctreeForCollisions: boolean;
  26488. /**
  26489. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26490. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26491. */
  26492. layerMask: number;
  26493. /**
  26494. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26495. */
  26496. alwaysSelectAsActiveMesh: boolean;
  26497. /**
  26498. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26499. */
  26500. doNotSyncBoundingInfo: boolean;
  26501. /**
  26502. * Gets or sets the current action manager
  26503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26504. */
  26505. actionManager: Nullable<AbstractActionManager>;
  26506. private _meshCollisionData;
  26507. /**
  26508. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26510. */
  26511. ellipsoid: Vector3;
  26512. /**
  26513. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26515. */
  26516. ellipsoidOffset: Vector3;
  26517. /**
  26518. * Gets or sets a collision mask used to mask collisions (default is -1).
  26519. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26520. */
  26521. collisionMask: number;
  26522. /**
  26523. * Gets or sets the current collision group mask (-1 by default).
  26524. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26525. */
  26526. collisionGroup: number;
  26527. /**
  26528. * Defines edge width used when edgesRenderer is enabled
  26529. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26530. */
  26531. edgesWidth: number;
  26532. /**
  26533. * Defines edge color used when edgesRenderer is enabled
  26534. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26535. */
  26536. edgesColor: Color4;
  26537. /** @hidden */
  26538. _edgesRenderer: Nullable<IEdgesRenderer>;
  26539. /** @hidden */
  26540. _masterMesh: Nullable<AbstractMesh>;
  26541. /** @hidden */
  26542. _boundingInfo: Nullable<BoundingInfo>;
  26543. /** @hidden */
  26544. _renderId: number;
  26545. /**
  26546. * Gets or sets the list of subMeshes
  26547. * @see http://doc.babylonjs.com/how_to/multi_materials
  26548. */
  26549. subMeshes: SubMesh[];
  26550. /** @hidden */
  26551. _intersectionsInProgress: AbstractMesh[];
  26552. /** @hidden */
  26553. _unIndexed: boolean;
  26554. /** @hidden */
  26555. _lightSources: Light[];
  26556. /** Gets the list of lights affecting that mesh */
  26557. readonly lightSources: Light[];
  26558. /** @hidden */
  26559. readonly _positions: Nullable<Vector3[]>;
  26560. /** @hidden */
  26561. _waitingData: {
  26562. lods: Nullable<any>;
  26563. actions: Nullable<any>;
  26564. freezeWorldMatrix: Nullable<boolean>;
  26565. };
  26566. /** @hidden */
  26567. _bonesTransformMatrices: Nullable<Float32Array>;
  26568. /** @hidden */
  26569. _transformMatrixTexture: Nullable<RawTexture>;
  26570. /**
  26571. * Gets or sets a skeleton to apply skining transformations
  26572. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26573. */
  26574. skeleton: Nullable<Skeleton>;
  26575. /**
  26576. * An event triggered when the mesh is rebuilt.
  26577. */
  26578. onRebuildObservable: Observable<AbstractMesh>;
  26579. /**
  26580. * Creates a new AbstractMesh
  26581. * @param name defines the name of the mesh
  26582. * @param scene defines the hosting scene
  26583. */
  26584. constructor(name: string, scene?: Nullable<Scene>);
  26585. /**
  26586. * Returns the string "AbstractMesh"
  26587. * @returns "AbstractMesh"
  26588. */
  26589. getClassName(): string;
  26590. /**
  26591. * Gets a string representation of the current mesh
  26592. * @param fullDetails defines a boolean indicating if full details must be included
  26593. * @returns a string representation of the current mesh
  26594. */
  26595. toString(fullDetails?: boolean): string;
  26596. /**
  26597. * @hidden
  26598. */
  26599. protected _getEffectiveParent(): Nullable<Node>;
  26600. /** @hidden */
  26601. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26602. /** @hidden */
  26603. _rebuild(): void;
  26604. /** @hidden */
  26605. _resyncLightSources(): void;
  26606. /** @hidden */
  26607. _resyncLighSource(light: Light): void;
  26608. /** @hidden */
  26609. _unBindEffect(): void;
  26610. /** @hidden */
  26611. _removeLightSource(light: Light): void;
  26612. private _markSubMeshesAsDirty;
  26613. /** @hidden */
  26614. _markSubMeshesAsLightDirty(): void;
  26615. /** @hidden */
  26616. _markSubMeshesAsAttributesDirty(): void;
  26617. /** @hidden */
  26618. _markSubMeshesAsMiscDirty(): void;
  26619. /**
  26620. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26621. */
  26622. scaling: Vector3;
  26623. /**
  26624. * Returns true if the mesh is blocked. Implemented by child classes
  26625. */
  26626. readonly isBlocked: boolean;
  26627. /**
  26628. * Returns the mesh itself by default. Implemented by child classes
  26629. * @param camera defines the camera to use to pick the right LOD level
  26630. * @returns the currentAbstractMesh
  26631. */
  26632. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26633. /**
  26634. * Returns 0 by default. Implemented by child classes
  26635. * @returns an integer
  26636. */
  26637. getTotalVertices(): number;
  26638. /**
  26639. * Returns a positive integer : the total number of indices in this mesh geometry.
  26640. * @returns the numner of indices or zero if the mesh has no geometry.
  26641. */
  26642. getTotalIndices(): number;
  26643. /**
  26644. * Returns null by default. Implemented by child classes
  26645. * @returns null
  26646. */
  26647. getIndices(): Nullable<IndicesArray>;
  26648. /**
  26649. * Returns the array of the requested vertex data kind. Implemented by child classes
  26650. * @param kind defines the vertex data kind to use
  26651. * @returns null
  26652. */
  26653. getVerticesData(kind: string): Nullable<FloatArray>;
  26654. /**
  26655. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26656. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26657. * Note that a new underlying VertexBuffer object is created each call.
  26658. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26659. * @param kind defines vertex data kind:
  26660. * * VertexBuffer.PositionKind
  26661. * * VertexBuffer.UVKind
  26662. * * VertexBuffer.UV2Kind
  26663. * * VertexBuffer.UV3Kind
  26664. * * VertexBuffer.UV4Kind
  26665. * * VertexBuffer.UV5Kind
  26666. * * VertexBuffer.UV6Kind
  26667. * * VertexBuffer.ColorKind
  26668. * * VertexBuffer.MatricesIndicesKind
  26669. * * VertexBuffer.MatricesIndicesExtraKind
  26670. * * VertexBuffer.MatricesWeightsKind
  26671. * * VertexBuffer.MatricesWeightsExtraKind
  26672. * @param data defines the data source
  26673. * @param updatable defines if the data must be flagged as updatable (or static)
  26674. * @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
  26675. * @returns the current mesh
  26676. */
  26677. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26678. /**
  26679. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26680. * If the mesh has no geometry, it is simply returned as it is.
  26681. * @param kind defines vertex data kind:
  26682. * * VertexBuffer.PositionKind
  26683. * * VertexBuffer.UVKind
  26684. * * VertexBuffer.UV2Kind
  26685. * * VertexBuffer.UV3Kind
  26686. * * VertexBuffer.UV4Kind
  26687. * * VertexBuffer.UV5Kind
  26688. * * VertexBuffer.UV6Kind
  26689. * * VertexBuffer.ColorKind
  26690. * * VertexBuffer.MatricesIndicesKind
  26691. * * VertexBuffer.MatricesIndicesExtraKind
  26692. * * VertexBuffer.MatricesWeightsKind
  26693. * * VertexBuffer.MatricesWeightsExtraKind
  26694. * @param data defines the data source
  26695. * @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
  26696. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26697. * @returns the current mesh
  26698. */
  26699. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26700. /**
  26701. * Sets the mesh indices,
  26702. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26703. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26704. * @param totalVertices Defines the total number of vertices
  26705. * @returns the current mesh
  26706. */
  26707. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26708. /**
  26709. * Gets a boolean indicating if specific vertex data is present
  26710. * @param kind defines the vertex data kind to use
  26711. * @returns true is data kind is present
  26712. */
  26713. isVerticesDataPresent(kind: string): boolean;
  26714. /**
  26715. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26716. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26717. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26718. * @returns a BoundingInfo
  26719. */
  26720. getBoundingInfo(): BoundingInfo;
  26721. /**
  26722. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26723. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26724. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26725. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26726. * @returns the current mesh
  26727. */
  26728. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26729. /**
  26730. * Overwrite the current bounding info
  26731. * @param boundingInfo defines the new bounding info
  26732. * @returns the current mesh
  26733. */
  26734. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26735. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26736. readonly useBones: boolean;
  26737. /** @hidden */
  26738. _preActivate(): void;
  26739. /** @hidden */
  26740. _preActivateForIntermediateRendering(renderId: number): void;
  26741. /** @hidden */
  26742. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26743. /** @hidden */
  26744. _postActivate(): void;
  26745. /** @hidden */
  26746. _freeze(): void;
  26747. /** @hidden */
  26748. _unFreeze(): void;
  26749. /**
  26750. * Gets the current world matrix
  26751. * @returns a Matrix
  26752. */
  26753. getWorldMatrix(): Matrix;
  26754. /** @hidden */
  26755. _getWorldMatrixDeterminant(): number;
  26756. /**
  26757. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26758. */
  26759. readonly isAnInstance: boolean;
  26760. /**
  26761. * Perform relative position change from the point of view of behind the front of the mesh.
  26762. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26763. * Supports definition of mesh facing forward or backward
  26764. * @param amountRight defines the distance on the right axis
  26765. * @param amountUp defines the distance on the up axis
  26766. * @param amountForward defines the distance on the forward axis
  26767. * @returns the current mesh
  26768. */
  26769. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26770. /**
  26771. * Calculate relative position change from the point of view of behind the front of the mesh.
  26772. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26773. * Supports definition of mesh facing forward or backward
  26774. * @param amountRight defines the distance on the right axis
  26775. * @param amountUp defines the distance on the up axis
  26776. * @param amountForward defines the distance on the forward axis
  26777. * @returns the new displacement vector
  26778. */
  26779. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26780. /**
  26781. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26782. * Supports definition of mesh facing forward or backward
  26783. * @param flipBack defines the flip
  26784. * @param twirlClockwise defines the twirl
  26785. * @param tiltRight defines the tilt
  26786. * @returns the current mesh
  26787. */
  26788. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26789. /**
  26790. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26791. * Supports definition of mesh facing forward or backward.
  26792. * @param flipBack defines the flip
  26793. * @param twirlClockwise defines the twirl
  26794. * @param tiltRight defines the tilt
  26795. * @returns the new rotation vector
  26796. */
  26797. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26798. /**
  26799. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26800. * This means the mesh underlying bounding box and sphere are recomputed.
  26801. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26802. * @returns the current mesh
  26803. */
  26804. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26805. /** @hidden */
  26806. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26807. /** @hidden */
  26808. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26809. /** @hidden */
  26810. _updateBoundingInfo(): AbstractMesh;
  26811. /** @hidden */
  26812. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26813. /** @hidden */
  26814. protected _afterComputeWorldMatrix(): void;
  26815. /** @hidden */
  26816. readonly _effectiveMesh: AbstractMesh;
  26817. /**
  26818. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26819. * A mesh is in the frustum if its bounding box intersects the frustum
  26820. * @param frustumPlanes defines the frustum to test
  26821. * @returns true if the mesh is in the frustum planes
  26822. */
  26823. isInFrustum(frustumPlanes: Plane[]): boolean;
  26824. /**
  26825. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26826. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26827. * @param frustumPlanes defines the frustum to test
  26828. * @returns true if the mesh is completely in the frustum planes
  26829. */
  26830. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26831. /**
  26832. * True if the mesh intersects another mesh or a SolidParticle object
  26833. * @param mesh defines a target mesh or SolidParticle to test
  26834. * @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)
  26835. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26836. * @returns true if there is an intersection
  26837. */
  26838. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26839. /**
  26840. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26841. * @param point defines the point to test
  26842. * @returns true if there is an intersection
  26843. */
  26844. intersectsPoint(point: Vector3): boolean;
  26845. /**
  26846. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26847. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26848. */
  26849. checkCollisions: boolean;
  26850. /**
  26851. * Gets Collider object used to compute collisions (not physics)
  26852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26853. */
  26854. readonly collider: Nullable<Collider>;
  26855. /**
  26856. * Move the mesh using collision engine
  26857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26858. * @param displacement defines the requested displacement vector
  26859. * @returns the current mesh
  26860. */
  26861. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26862. private _onCollisionPositionChange;
  26863. /** @hidden */
  26864. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26865. /** @hidden */
  26866. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26867. /** @hidden */
  26868. _checkCollision(collider: Collider): AbstractMesh;
  26869. /** @hidden */
  26870. _generatePointsArray(): boolean;
  26871. /**
  26872. * Checks if the passed Ray intersects with the mesh
  26873. * @param ray defines the ray to use
  26874. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26876. * @returns the picking info
  26877. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26878. */
  26879. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26880. /**
  26881. * Clones the current mesh
  26882. * @param name defines the mesh name
  26883. * @param newParent defines the new mesh parent
  26884. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26885. * @returns the new mesh
  26886. */
  26887. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26888. /**
  26889. * Disposes all the submeshes of the current meshnp
  26890. * @returns the current mesh
  26891. */
  26892. releaseSubMeshes(): AbstractMesh;
  26893. /**
  26894. * Releases resources associated with this abstract mesh.
  26895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26897. */
  26898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26899. /**
  26900. * Adds the passed mesh as a child to the current mesh
  26901. * @param mesh defines the child mesh
  26902. * @returns the current mesh
  26903. */
  26904. addChild(mesh: AbstractMesh): AbstractMesh;
  26905. /**
  26906. * Removes the passed mesh from the current mesh children list
  26907. * @param mesh defines the child mesh
  26908. * @returns the current mesh
  26909. */
  26910. removeChild(mesh: AbstractMesh): AbstractMesh;
  26911. /** @hidden */
  26912. private _initFacetData;
  26913. /**
  26914. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26915. * This method can be called within the render loop.
  26916. * 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
  26917. * @returns the current mesh
  26918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26919. */
  26920. updateFacetData(): AbstractMesh;
  26921. /**
  26922. * Returns the facetLocalNormals array.
  26923. * The normals are expressed in the mesh local spac
  26924. * @returns an array of Vector3
  26925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26926. */
  26927. getFacetLocalNormals(): Vector3[];
  26928. /**
  26929. * Returns the facetLocalPositions array.
  26930. * The facet positions are expressed in the mesh local space
  26931. * @returns an array of Vector3
  26932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26933. */
  26934. getFacetLocalPositions(): Vector3[];
  26935. /**
  26936. * Returns the facetLocalPartioning array
  26937. * @returns an array of array of numbers
  26938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26939. */
  26940. getFacetLocalPartitioning(): number[][];
  26941. /**
  26942. * Returns the i-th facet position in the world system.
  26943. * This method allocates a new Vector3 per call
  26944. * @param i defines the facet index
  26945. * @returns a new Vector3
  26946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26947. */
  26948. getFacetPosition(i: number): Vector3;
  26949. /**
  26950. * Sets the reference Vector3 with the i-th facet position in the world system
  26951. * @param i defines the facet index
  26952. * @param ref defines the target vector
  26953. * @returns the current mesh
  26954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26955. */
  26956. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26957. /**
  26958. * Returns the i-th facet normal in the world system.
  26959. * This method allocates a new Vector3 per call
  26960. * @param i defines the facet index
  26961. * @returns a new Vector3
  26962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26963. */
  26964. getFacetNormal(i: number): Vector3;
  26965. /**
  26966. * Sets the reference Vector3 with the i-th facet normal in the world system
  26967. * @param i defines the facet index
  26968. * @param ref defines the target vector
  26969. * @returns the current mesh
  26970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26971. */
  26972. getFacetNormalToRef(i: number, ref: Vector3): this;
  26973. /**
  26974. * 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)
  26975. * @param x defines x coordinate
  26976. * @param y defines y coordinate
  26977. * @param z defines z coordinate
  26978. * @returns the array of facet indexes
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26980. */
  26981. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26982. /**
  26983. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26984. * @param projected sets as the (x,y,z) world projection on the facet
  26985. * @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
  26986. * @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
  26987. * @param x defines x coordinate
  26988. * @param y defines y coordinate
  26989. * @param z defines z coordinate
  26990. * @returns the face index if found (or null instead)
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26994. /**
  26995. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26996. * @param projected sets as the (x,y,z) local projection on the facet
  26997. * @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
  26998. * @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
  26999. * @param x defines x coordinate
  27000. * @param y defines y coordinate
  27001. * @param z defines z coordinate
  27002. * @returns the face index if found (or null instead)
  27003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27004. */
  27005. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27006. /**
  27007. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27008. * @returns the parameters
  27009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27010. */
  27011. getFacetDataParameters(): any;
  27012. /**
  27013. * Disables the feature FacetData and frees the related memory
  27014. * @returns the current mesh
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27016. */
  27017. disableFacetData(): AbstractMesh;
  27018. /**
  27019. * Updates the AbstractMesh indices array
  27020. * @param indices defines the data source
  27021. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27022. * @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)
  27023. * @returns the current mesh
  27024. */
  27025. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27026. /**
  27027. * Creates new normals data for the mesh
  27028. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27029. * @returns the current mesh
  27030. */
  27031. createNormals(updatable: boolean): AbstractMesh;
  27032. /**
  27033. * Align the mesh with a normal
  27034. * @param normal defines the normal to use
  27035. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27036. * @returns the current mesh
  27037. */
  27038. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27039. /** @hidden */
  27040. _checkOcclusionQuery(): boolean;
  27041. /**
  27042. * Disables the mesh edge rendering mode
  27043. * @returns the currentAbstractMesh
  27044. */
  27045. disableEdgesRendering(): AbstractMesh;
  27046. /**
  27047. * Enables the edge rendering mode on the mesh.
  27048. * This mode makes the mesh edges visible
  27049. * @param epsilon defines the maximal distance between two angles to detect a face
  27050. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27051. * @returns the currentAbstractMesh
  27052. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27053. */
  27054. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27055. }
  27056. }
  27057. declare module "babylonjs/Actions/actionEvent" {
  27058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27059. import { Nullable } from "babylonjs/types";
  27060. import { Sprite } from "babylonjs/Sprites/sprite";
  27061. import { Scene } from "babylonjs/scene";
  27062. import { Vector2 } from "babylonjs/Maths/math.vector";
  27063. /**
  27064. * Interface used to define ActionEvent
  27065. */
  27066. export interface IActionEvent {
  27067. /** The mesh or sprite that triggered the action */
  27068. source: any;
  27069. /** The X mouse cursor position at the time of the event */
  27070. pointerX: number;
  27071. /** The Y mouse cursor position at the time of the event */
  27072. pointerY: number;
  27073. /** The mesh that is currently pointed at (can be null) */
  27074. meshUnderPointer: Nullable<AbstractMesh>;
  27075. /** the original (browser) event that triggered the ActionEvent */
  27076. sourceEvent?: any;
  27077. /** additional data for the event */
  27078. additionalData?: any;
  27079. }
  27080. /**
  27081. * ActionEvent is the event being sent when an action is triggered.
  27082. */
  27083. export class ActionEvent implements IActionEvent {
  27084. /** The mesh or sprite that triggered the action */
  27085. source: any;
  27086. /** The X mouse cursor position at the time of the event */
  27087. pointerX: number;
  27088. /** The Y mouse cursor position at the time of the event */
  27089. pointerY: number;
  27090. /** The mesh that is currently pointed at (can be null) */
  27091. meshUnderPointer: Nullable<AbstractMesh>;
  27092. /** the original (browser) event that triggered the ActionEvent */
  27093. sourceEvent?: any;
  27094. /** additional data for the event */
  27095. additionalData?: any;
  27096. /**
  27097. * Creates a new ActionEvent
  27098. * @param source The mesh or sprite that triggered the action
  27099. * @param pointerX The X mouse cursor position at the time of the event
  27100. * @param pointerY The Y mouse cursor position at the time of the event
  27101. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27102. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27103. * @param additionalData additional data for the event
  27104. */
  27105. constructor(
  27106. /** The mesh or sprite that triggered the action */
  27107. source: any,
  27108. /** The X mouse cursor position at the time of the event */
  27109. pointerX: number,
  27110. /** The Y mouse cursor position at the time of the event */
  27111. pointerY: number,
  27112. /** The mesh that is currently pointed at (can be null) */
  27113. meshUnderPointer: Nullable<AbstractMesh>,
  27114. /** the original (browser) event that triggered the ActionEvent */
  27115. sourceEvent?: any,
  27116. /** additional data for the event */
  27117. additionalData?: any);
  27118. /**
  27119. * Helper function to auto-create an ActionEvent from a source mesh.
  27120. * @param source The source mesh that triggered the event
  27121. * @param evt The original (browser) event
  27122. * @param additionalData additional data for the event
  27123. * @returns the new ActionEvent
  27124. */
  27125. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27126. /**
  27127. * Helper function to auto-create an ActionEvent from a source sprite
  27128. * @param source The source sprite that triggered the event
  27129. * @param scene Scene associated with the sprite
  27130. * @param evt The original (browser) event
  27131. * @param additionalData additional data for the event
  27132. * @returns the new ActionEvent
  27133. */
  27134. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27135. /**
  27136. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27137. * @param scene the scene where the event occurred
  27138. * @param evt The original (browser) event
  27139. * @returns the new ActionEvent
  27140. */
  27141. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27142. /**
  27143. * Helper function to auto-create an ActionEvent from a primitive
  27144. * @param prim defines the target primitive
  27145. * @param pointerPos defines the pointer position
  27146. * @param evt The original (browser) event
  27147. * @param additionalData additional data for the event
  27148. * @returns the new ActionEvent
  27149. */
  27150. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27151. }
  27152. }
  27153. declare module "babylonjs/Actions/abstractActionManager" {
  27154. import { IDisposable } from "babylonjs/scene";
  27155. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27156. import { IAction } from "babylonjs/Actions/action";
  27157. import { Nullable } from "babylonjs/types";
  27158. /**
  27159. * Abstract class used to decouple action Manager from scene and meshes.
  27160. * Do not instantiate.
  27161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27162. */
  27163. export abstract class AbstractActionManager implements IDisposable {
  27164. /** Gets the list of active triggers */
  27165. static Triggers: {
  27166. [key: string]: number;
  27167. };
  27168. /** Gets the cursor to use when hovering items */
  27169. hoverCursor: string;
  27170. /** Gets the list of actions */
  27171. actions: IAction[];
  27172. /**
  27173. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27174. */
  27175. isRecursive: boolean;
  27176. /**
  27177. * Releases all associated resources
  27178. */
  27179. abstract dispose(): void;
  27180. /**
  27181. * Does this action manager has pointer triggers
  27182. */
  27183. abstract readonly hasPointerTriggers: boolean;
  27184. /**
  27185. * Does this action manager has pick triggers
  27186. */
  27187. abstract readonly hasPickTriggers: boolean;
  27188. /**
  27189. * Process a specific trigger
  27190. * @param trigger defines the trigger to process
  27191. * @param evt defines the event details to be processed
  27192. */
  27193. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27194. /**
  27195. * Does this action manager handles actions of any of the given triggers
  27196. * @param triggers defines the triggers to be tested
  27197. * @return a boolean indicating whether one (or more) of the triggers is handled
  27198. */
  27199. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27200. /**
  27201. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27202. * speed.
  27203. * @param triggerA defines the trigger to be tested
  27204. * @param triggerB defines the trigger to be tested
  27205. * @return a boolean indicating whether one (or more) of the triggers is handled
  27206. */
  27207. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27208. /**
  27209. * Does this action manager handles actions of a given trigger
  27210. * @param trigger defines the trigger to be tested
  27211. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27212. * @return whether the trigger is handled
  27213. */
  27214. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27215. /**
  27216. * Serialize this manager to a JSON object
  27217. * @param name defines the property name to store this manager
  27218. * @returns a JSON representation of this manager
  27219. */
  27220. abstract serialize(name: string): any;
  27221. /**
  27222. * Registers an action to this action manager
  27223. * @param action defines the action to be registered
  27224. * @return the action amended (prepared) after registration
  27225. */
  27226. abstract registerAction(action: IAction): Nullable<IAction>;
  27227. /**
  27228. * Unregisters an action to this action manager
  27229. * @param action defines the action to be unregistered
  27230. * @return a boolean indicating whether the action has been unregistered
  27231. */
  27232. abstract unregisterAction(action: IAction): Boolean;
  27233. /**
  27234. * Does exist one action manager with at least one trigger
  27235. **/
  27236. static readonly HasTriggers: boolean;
  27237. /**
  27238. * Does exist one action manager with at least one pick trigger
  27239. **/
  27240. static readonly HasPickTriggers: boolean;
  27241. /**
  27242. * Does exist one action manager that handles actions of a given trigger
  27243. * @param trigger defines the trigger to be tested
  27244. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27245. **/
  27246. static HasSpecificTrigger(trigger: number): boolean;
  27247. }
  27248. }
  27249. declare module "babylonjs/node" {
  27250. import { Scene } from "babylonjs/scene";
  27251. import { Nullable } from "babylonjs/types";
  27252. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27253. import { Engine } from "babylonjs/Engines/engine";
  27254. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27255. import { Observable } from "babylonjs/Misc/observable";
  27256. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27257. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27258. import { Animatable } from "babylonjs/Animations/animatable";
  27259. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27260. import { Animation } from "babylonjs/Animations/animation";
  27261. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27263. /**
  27264. * Defines how a node can be built from a string name.
  27265. */
  27266. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27267. /**
  27268. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27269. */
  27270. export class Node implements IBehaviorAware<Node> {
  27271. /** @hidden */
  27272. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27273. private static _NodeConstructors;
  27274. /**
  27275. * Add a new node constructor
  27276. * @param type defines the type name of the node to construct
  27277. * @param constructorFunc defines the constructor function
  27278. */
  27279. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27280. /**
  27281. * Returns a node constructor based on type name
  27282. * @param type defines the type name
  27283. * @param name defines the new node name
  27284. * @param scene defines the hosting scene
  27285. * @param options defines optional options to transmit to constructors
  27286. * @returns the new constructor or null
  27287. */
  27288. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27289. /**
  27290. * Gets or sets the name of the node
  27291. */
  27292. name: string;
  27293. /**
  27294. * Gets or sets the id of the node
  27295. */
  27296. id: string;
  27297. /**
  27298. * Gets or sets the unique id of the node
  27299. */
  27300. uniqueId: number;
  27301. /**
  27302. * Gets or sets a string used to store user defined state for the node
  27303. */
  27304. state: string;
  27305. /**
  27306. * Gets or sets an object used to store user defined information for the node
  27307. */
  27308. metadata: any;
  27309. /**
  27310. * For internal use only. Please do not use.
  27311. */
  27312. reservedDataStore: any;
  27313. /**
  27314. * List of inspectable custom properties (used by the Inspector)
  27315. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27316. */
  27317. inspectableCustomProperties: IInspectable[];
  27318. /**
  27319. * Gets or sets a boolean used to define if the node must be serialized
  27320. */
  27321. doNotSerialize: boolean;
  27322. /** @hidden */
  27323. _isDisposed: boolean;
  27324. /**
  27325. * Gets a list of Animations associated with the node
  27326. */
  27327. animations: import("babylonjs/Animations/animation").Animation[];
  27328. protected _ranges: {
  27329. [name: string]: Nullable<AnimationRange>;
  27330. };
  27331. /**
  27332. * Callback raised when the node is ready to be used
  27333. */
  27334. onReady: Nullable<(node: Node) => void>;
  27335. private _isEnabled;
  27336. private _isParentEnabled;
  27337. private _isReady;
  27338. /** @hidden */
  27339. _currentRenderId: number;
  27340. private _parentUpdateId;
  27341. /** @hidden */
  27342. _childUpdateId: number;
  27343. /** @hidden */
  27344. _waitingParentId: Nullable<string>;
  27345. /** @hidden */
  27346. _scene: Scene;
  27347. /** @hidden */
  27348. _cache: any;
  27349. private _parentNode;
  27350. private _children;
  27351. /** @hidden */
  27352. _worldMatrix: Matrix;
  27353. /** @hidden */
  27354. _worldMatrixDeterminant: number;
  27355. /** @hidden */
  27356. _worldMatrixDeterminantIsDirty: boolean;
  27357. /** @hidden */
  27358. private _sceneRootNodesIndex;
  27359. /**
  27360. * Gets a boolean indicating if the node has been disposed
  27361. * @returns true if the node was disposed
  27362. */
  27363. isDisposed(): boolean;
  27364. /**
  27365. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27366. * @see https://doc.babylonjs.com/how_to/parenting
  27367. */
  27368. parent: Nullable<Node>;
  27369. private addToSceneRootNodes;
  27370. private removeFromSceneRootNodes;
  27371. private _animationPropertiesOverride;
  27372. /**
  27373. * Gets or sets the animation properties override
  27374. */
  27375. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27376. /**
  27377. * Gets a string idenfifying the name of the class
  27378. * @returns "Node" string
  27379. */
  27380. getClassName(): string;
  27381. /** @hidden */
  27382. readonly _isNode: boolean;
  27383. /**
  27384. * An event triggered when the mesh is disposed
  27385. */
  27386. onDisposeObservable: Observable<Node>;
  27387. private _onDisposeObserver;
  27388. /**
  27389. * Sets a callback that will be raised when the node will be disposed
  27390. */
  27391. onDispose: () => void;
  27392. /**
  27393. * Creates a new Node
  27394. * @param name the name and id to be given to this node
  27395. * @param scene the scene this node will be added to
  27396. * @param addToRootNodes the node will be added to scene.rootNodes
  27397. */
  27398. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27399. /**
  27400. * Gets the scene of the node
  27401. * @returns a scene
  27402. */
  27403. getScene(): Scene;
  27404. /**
  27405. * Gets the engine of the node
  27406. * @returns a Engine
  27407. */
  27408. getEngine(): Engine;
  27409. private _behaviors;
  27410. /**
  27411. * Attach a behavior to the node
  27412. * @see http://doc.babylonjs.com/features/behaviour
  27413. * @param behavior defines the behavior to attach
  27414. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27415. * @returns the current Node
  27416. */
  27417. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27418. /**
  27419. * Remove an attached behavior
  27420. * @see http://doc.babylonjs.com/features/behaviour
  27421. * @param behavior defines the behavior to attach
  27422. * @returns the current Node
  27423. */
  27424. removeBehavior(behavior: Behavior<Node>): Node;
  27425. /**
  27426. * Gets the list of attached behaviors
  27427. * @see http://doc.babylonjs.com/features/behaviour
  27428. */
  27429. readonly behaviors: Behavior<Node>[];
  27430. /**
  27431. * Gets an attached behavior by name
  27432. * @param name defines the name of the behavior to look for
  27433. * @see http://doc.babylonjs.com/features/behaviour
  27434. * @returns null if behavior was not found else the requested behavior
  27435. */
  27436. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27437. /**
  27438. * Returns the latest update of the World matrix
  27439. * @returns a Matrix
  27440. */
  27441. getWorldMatrix(): Matrix;
  27442. /** @hidden */
  27443. _getWorldMatrixDeterminant(): number;
  27444. /**
  27445. * Returns directly the latest state of the mesh World matrix.
  27446. * A Matrix is returned.
  27447. */
  27448. readonly worldMatrixFromCache: Matrix;
  27449. /** @hidden */
  27450. _initCache(): void;
  27451. /** @hidden */
  27452. updateCache(force?: boolean): void;
  27453. /** @hidden */
  27454. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27455. /** @hidden */
  27456. _updateCache(ignoreParentClass?: boolean): void;
  27457. /** @hidden */
  27458. _isSynchronized(): boolean;
  27459. /** @hidden */
  27460. _markSyncedWithParent(): void;
  27461. /** @hidden */
  27462. isSynchronizedWithParent(): boolean;
  27463. /** @hidden */
  27464. isSynchronized(): boolean;
  27465. /**
  27466. * Is this node ready to be used/rendered
  27467. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27468. * @return true if the node is ready
  27469. */
  27470. isReady(completeCheck?: boolean): boolean;
  27471. /**
  27472. * Is this node enabled?
  27473. * 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
  27474. * @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
  27475. * @return whether this node (and its parent) is enabled
  27476. */
  27477. isEnabled(checkAncestors?: boolean): boolean;
  27478. /** @hidden */
  27479. protected _syncParentEnabledState(): void;
  27480. /**
  27481. * Set the enabled state of this node
  27482. * @param value defines the new enabled state
  27483. */
  27484. setEnabled(value: boolean): void;
  27485. /**
  27486. * Is this node a descendant of the given node?
  27487. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27488. * @param ancestor defines the parent node to inspect
  27489. * @returns a boolean indicating if this node is a descendant of the given node
  27490. */
  27491. isDescendantOf(ancestor: Node): boolean;
  27492. /** @hidden */
  27493. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27494. /**
  27495. * Will return all nodes that have this node as ascendant
  27496. * @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
  27497. * @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
  27498. * @return all children nodes of all types
  27499. */
  27500. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27501. /**
  27502. * Get all child-meshes of this node
  27503. * @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)
  27504. * @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
  27505. * @returns an array of AbstractMesh
  27506. */
  27507. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27508. /**
  27509. * Get all direct children of this node
  27510. * @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
  27511. * @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)
  27512. * @returns an array of Node
  27513. */
  27514. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27515. /** @hidden */
  27516. _setReady(state: boolean): void;
  27517. /**
  27518. * Get an animation by name
  27519. * @param name defines the name of the animation to look for
  27520. * @returns null if not found else the requested animation
  27521. */
  27522. getAnimationByName(name: string): Nullable<Animation>;
  27523. /**
  27524. * Creates an animation range for this node
  27525. * @param name defines the name of the range
  27526. * @param from defines the starting key
  27527. * @param to defines the end key
  27528. */
  27529. createAnimationRange(name: string, from: number, to: number): void;
  27530. /**
  27531. * Delete a specific animation range
  27532. * @param name defines the name of the range to delete
  27533. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27534. */
  27535. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27536. /**
  27537. * Get an animation range by name
  27538. * @param name defines the name of the animation range to look for
  27539. * @returns null if not found else the requested animation range
  27540. */
  27541. getAnimationRange(name: string): Nullable<AnimationRange>;
  27542. /**
  27543. * Gets the list of all animation ranges defined on this node
  27544. * @returns an array
  27545. */
  27546. getAnimationRanges(): Nullable<AnimationRange>[];
  27547. /**
  27548. * Will start the animation sequence
  27549. * @param name defines the range frames for animation sequence
  27550. * @param loop defines if the animation should loop (false by default)
  27551. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27552. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27553. * @returns the object created for this animation. If range does not exist, it will return null
  27554. */
  27555. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27556. /**
  27557. * Serialize animation ranges into a JSON compatible object
  27558. * @returns serialization object
  27559. */
  27560. serializeAnimationRanges(): any;
  27561. /**
  27562. * Computes the world matrix of the node
  27563. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27564. * @returns the world matrix
  27565. */
  27566. computeWorldMatrix(force?: boolean): Matrix;
  27567. /**
  27568. * Releases resources associated with this node.
  27569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27571. */
  27572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27573. /**
  27574. * Parse animation range data from a serialization object and store them into a given node
  27575. * @param node defines where to store the animation ranges
  27576. * @param parsedNode defines the serialization object to read data from
  27577. * @param scene defines the hosting scene
  27578. */
  27579. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27580. /**
  27581. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27582. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27583. * @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
  27584. * @returns the new bounding vectors
  27585. */
  27586. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27587. min: Vector3;
  27588. max: Vector3;
  27589. };
  27590. }
  27591. }
  27592. declare module "babylonjs/Animations/animation" {
  27593. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27594. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27595. import { Color3 } from "babylonjs/Maths/math.color";
  27596. import { Nullable } from "babylonjs/types";
  27597. import { Scene } from "babylonjs/scene";
  27598. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27599. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27600. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27601. import { Node } from "babylonjs/node";
  27602. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27603. import { Size } from "babylonjs/Maths/math.size";
  27604. import { Animatable } from "babylonjs/Animations/animatable";
  27605. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27606. /**
  27607. * @hidden
  27608. */
  27609. export class _IAnimationState {
  27610. key: number;
  27611. repeatCount: number;
  27612. workValue?: any;
  27613. loopMode?: number;
  27614. offsetValue?: any;
  27615. highLimitValue?: any;
  27616. }
  27617. /**
  27618. * Class used to store any kind of animation
  27619. */
  27620. export class Animation {
  27621. /**Name of the animation */
  27622. name: string;
  27623. /**Property to animate */
  27624. targetProperty: string;
  27625. /**The frames per second of the animation */
  27626. framePerSecond: number;
  27627. /**The data type of the animation */
  27628. dataType: number;
  27629. /**The loop mode of the animation */
  27630. loopMode?: number | undefined;
  27631. /**Specifies if blending should be enabled */
  27632. enableBlending?: boolean | undefined;
  27633. /**
  27634. * Use matrix interpolation instead of using direct key value when animating matrices
  27635. */
  27636. static AllowMatricesInterpolation: boolean;
  27637. /**
  27638. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27639. */
  27640. static AllowMatrixDecomposeForInterpolation: boolean;
  27641. /**
  27642. * Stores the key frames of the animation
  27643. */
  27644. private _keys;
  27645. /**
  27646. * Stores the easing function of the animation
  27647. */
  27648. private _easingFunction;
  27649. /**
  27650. * @hidden Internal use only
  27651. */
  27652. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27653. /**
  27654. * The set of event that will be linked to this animation
  27655. */
  27656. private _events;
  27657. /**
  27658. * Stores an array of target property paths
  27659. */
  27660. targetPropertyPath: string[];
  27661. /**
  27662. * Stores the blending speed of the animation
  27663. */
  27664. blendingSpeed: number;
  27665. /**
  27666. * Stores the animation ranges for the animation
  27667. */
  27668. private _ranges;
  27669. /**
  27670. * @hidden Internal use
  27671. */
  27672. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27673. /**
  27674. * Sets up an animation
  27675. * @param property The property to animate
  27676. * @param animationType The animation type to apply
  27677. * @param framePerSecond The frames per second of the animation
  27678. * @param easingFunction The easing function used in the animation
  27679. * @returns The created animation
  27680. */
  27681. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27682. /**
  27683. * Create and start an animation on a node
  27684. * @param name defines the name of the global animation that will be run on all nodes
  27685. * @param node defines the root node where the animation will take place
  27686. * @param targetProperty defines property to animate
  27687. * @param framePerSecond defines the number of frame per second yo use
  27688. * @param totalFrame defines the number of frames in total
  27689. * @param from defines the initial value
  27690. * @param to defines the final value
  27691. * @param loopMode defines which loop mode you want to use (off by default)
  27692. * @param easingFunction defines the easing function to use (linear by default)
  27693. * @param onAnimationEnd defines the callback to call when animation end
  27694. * @returns the animatable created for this animation
  27695. */
  27696. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27697. /**
  27698. * Create and start an animation on a node and its descendants
  27699. * @param name defines the name of the global animation that will be run on all nodes
  27700. * @param node defines the root node where the animation will take place
  27701. * @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
  27702. * @param targetProperty defines property to animate
  27703. * @param framePerSecond defines the number of frame per second to use
  27704. * @param totalFrame defines the number of frames in total
  27705. * @param from defines the initial value
  27706. * @param to defines the final value
  27707. * @param loopMode defines which loop mode you want to use (off by default)
  27708. * @param easingFunction defines the easing function to use (linear by default)
  27709. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27710. * @returns the list of animatables created for all nodes
  27711. * @example https://www.babylonjs-playground.com/#MH0VLI
  27712. */
  27713. 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[]>;
  27714. /**
  27715. * Creates a new animation, merges it with the existing animations and starts it
  27716. * @param name Name of the animation
  27717. * @param node Node which contains the scene that begins the animations
  27718. * @param targetProperty Specifies which property to animate
  27719. * @param framePerSecond The frames per second of the animation
  27720. * @param totalFrame The total number of frames
  27721. * @param from The frame at the beginning of the animation
  27722. * @param to The frame at the end of the animation
  27723. * @param loopMode Specifies the loop mode of the animation
  27724. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27725. * @param onAnimationEnd Callback to run once the animation is complete
  27726. * @returns Nullable animation
  27727. */
  27728. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27729. /**
  27730. * Transition property of an host to the target Value
  27731. * @param property The property to transition
  27732. * @param targetValue The target Value of the property
  27733. * @param host The object where the property to animate belongs
  27734. * @param scene Scene used to run the animation
  27735. * @param frameRate Framerate (in frame/s) to use
  27736. * @param transition The transition type we want to use
  27737. * @param duration The duration of the animation, in milliseconds
  27738. * @param onAnimationEnd Callback trigger at the end of the animation
  27739. * @returns Nullable animation
  27740. */
  27741. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27742. /**
  27743. * Return the array of runtime animations currently using this animation
  27744. */
  27745. readonly runtimeAnimations: RuntimeAnimation[];
  27746. /**
  27747. * Specifies if any of the runtime animations are currently running
  27748. */
  27749. readonly hasRunningRuntimeAnimations: boolean;
  27750. /**
  27751. * Initializes the animation
  27752. * @param name Name of the animation
  27753. * @param targetProperty Property to animate
  27754. * @param framePerSecond The frames per second of the animation
  27755. * @param dataType The data type of the animation
  27756. * @param loopMode The loop mode of the animation
  27757. * @param enableBlending Specifies if blending should be enabled
  27758. */
  27759. constructor(
  27760. /**Name of the animation */
  27761. name: string,
  27762. /**Property to animate */
  27763. targetProperty: string,
  27764. /**The frames per second of the animation */
  27765. framePerSecond: number,
  27766. /**The data type of the animation */
  27767. dataType: number,
  27768. /**The loop mode of the animation */
  27769. loopMode?: number | undefined,
  27770. /**Specifies if blending should be enabled */
  27771. enableBlending?: boolean | undefined);
  27772. /**
  27773. * Converts the animation to a string
  27774. * @param fullDetails support for multiple levels of logging within scene loading
  27775. * @returns String form of the animation
  27776. */
  27777. toString(fullDetails?: boolean): string;
  27778. /**
  27779. * Add an event to this animation
  27780. * @param event Event to add
  27781. */
  27782. addEvent(event: AnimationEvent): void;
  27783. /**
  27784. * Remove all events found at the given frame
  27785. * @param frame The frame to remove events from
  27786. */
  27787. removeEvents(frame: number): void;
  27788. /**
  27789. * Retrieves all the events from the animation
  27790. * @returns Events from the animation
  27791. */
  27792. getEvents(): AnimationEvent[];
  27793. /**
  27794. * Creates an animation range
  27795. * @param name Name of the animation range
  27796. * @param from Starting frame of the animation range
  27797. * @param to Ending frame of the animation
  27798. */
  27799. createRange(name: string, from: number, to: number): void;
  27800. /**
  27801. * Deletes an animation range by name
  27802. * @param name Name of the animation range to delete
  27803. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27804. */
  27805. deleteRange(name: string, deleteFrames?: boolean): void;
  27806. /**
  27807. * Gets the animation range by name, or null if not defined
  27808. * @param name Name of the animation range
  27809. * @returns Nullable animation range
  27810. */
  27811. getRange(name: string): Nullable<AnimationRange>;
  27812. /**
  27813. * Gets the key frames from the animation
  27814. * @returns The key frames of the animation
  27815. */
  27816. getKeys(): Array<IAnimationKey>;
  27817. /**
  27818. * Gets the highest frame rate of the animation
  27819. * @returns Highest frame rate of the animation
  27820. */
  27821. getHighestFrame(): number;
  27822. /**
  27823. * Gets the easing function of the animation
  27824. * @returns Easing function of the animation
  27825. */
  27826. getEasingFunction(): IEasingFunction;
  27827. /**
  27828. * Sets the easing function of the animation
  27829. * @param easingFunction A custom mathematical formula for animation
  27830. */
  27831. setEasingFunction(easingFunction: EasingFunction): void;
  27832. /**
  27833. * Interpolates a scalar linearly
  27834. * @param startValue Start value of the animation curve
  27835. * @param endValue End value of the animation curve
  27836. * @param gradient Scalar amount to interpolate
  27837. * @returns Interpolated scalar value
  27838. */
  27839. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27840. /**
  27841. * Interpolates a scalar cubically
  27842. * @param startValue Start value of the animation curve
  27843. * @param outTangent End tangent of the animation
  27844. * @param endValue End value of the animation curve
  27845. * @param inTangent Start tangent of the animation curve
  27846. * @param gradient Scalar amount to interpolate
  27847. * @returns Interpolated scalar value
  27848. */
  27849. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27850. /**
  27851. * Interpolates a quaternion using a spherical linear interpolation
  27852. * @param startValue Start value of the animation curve
  27853. * @param endValue End value of the animation curve
  27854. * @param gradient Scalar amount to interpolate
  27855. * @returns Interpolated quaternion value
  27856. */
  27857. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27858. /**
  27859. * Interpolates a quaternion cubically
  27860. * @param startValue Start value of the animation curve
  27861. * @param outTangent End tangent of the animation curve
  27862. * @param endValue End value of the animation curve
  27863. * @param inTangent Start tangent of the animation curve
  27864. * @param gradient Scalar amount to interpolate
  27865. * @returns Interpolated quaternion value
  27866. */
  27867. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27868. /**
  27869. * Interpolates a Vector3 linearl
  27870. * @param startValue Start value of the animation curve
  27871. * @param endValue End value of the animation curve
  27872. * @param gradient Scalar amount to interpolate
  27873. * @returns Interpolated scalar value
  27874. */
  27875. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27876. /**
  27877. * Interpolates a Vector3 cubically
  27878. * @param startValue Start value of the animation curve
  27879. * @param outTangent End tangent of the animation
  27880. * @param endValue End value of the animation curve
  27881. * @param inTangent Start tangent of the animation curve
  27882. * @param gradient Scalar amount to interpolate
  27883. * @returns InterpolatedVector3 value
  27884. */
  27885. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27886. /**
  27887. * Interpolates a Vector2 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 Vector2 value
  27892. */
  27893. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27894. /**
  27895. * Interpolates a Vector2 cubically
  27896. * @param startValue Start value of the animation curve
  27897. * @param outTangent End tangent of the animation
  27898. * @param endValue End value of the animation curve
  27899. * @param inTangent Start tangent of the animation curve
  27900. * @param gradient Scalar amount to interpolate
  27901. * @returns Interpolated Vector2 value
  27902. */
  27903. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27904. /**
  27905. * Interpolates a size linearly
  27906. * @param startValue Start value of the animation curve
  27907. * @param endValue End value of the animation curve
  27908. * @param gradient Scalar amount to interpolate
  27909. * @returns Interpolated Size value
  27910. */
  27911. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27912. /**
  27913. * Interpolates a Color3 linearly
  27914. * @param startValue Start value of the animation curve
  27915. * @param endValue End value of the animation curve
  27916. * @param gradient Scalar amount to interpolate
  27917. * @returns Interpolated Color3 value
  27918. */
  27919. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27920. /**
  27921. * @hidden Internal use only
  27922. */
  27923. _getKeyValue(value: any): any;
  27924. /**
  27925. * @hidden Internal use only
  27926. */
  27927. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27928. /**
  27929. * Defines the function to use to interpolate matrices
  27930. * @param startValue defines the start matrix
  27931. * @param endValue defines the end matrix
  27932. * @param gradient defines the gradient between both matrices
  27933. * @param result defines an optional target matrix where to store the interpolation
  27934. * @returns the interpolated matrix
  27935. */
  27936. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27937. /**
  27938. * Makes a copy of the animation
  27939. * @returns Cloned animation
  27940. */
  27941. clone(): Animation;
  27942. /**
  27943. * Sets the key frames of the animation
  27944. * @param values The animation key frames to set
  27945. */
  27946. setKeys(values: Array<IAnimationKey>): void;
  27947. /**
  27948. * Serializes the animation to an object
  27949. * @returns Serialized object
  27950. */
  27951. serialize(): any;
  27952. /**
  27953. * Float animation type
  27954. */
  27955. private static _ANIMATIONTYPE_FLOAT;
  27956. /**
  27957. * Vector3 animation type
  27958. */
  27959. private static _ANIMATIONTYPE_VECTOR3;
  27960. /**
  27961. * Quaternion animation type
  27962. */
  27963. private static _ANIMATIONTYPE_QUATERNION;
  27964. /**
  27965. * Matrix animation type
  27966. */
  27967. private static _ANIMATIONTYPE_MATRIX;
  27968. /**
  27969. * Color3 animation type
  27970. */
  27971. private static _ANIMATIONTYPE_COLOR3;
  27972. /**
  27973. * Vector2 animation type
  27974. */
  27975. private static _ANIMATIONTYPE_VECTOR2;
  27976. /**
  27977. * Size animation type
  27978. */
  27979. private static _ANIMATIONTYPE_SIZE;
  27980. /**
  27981. * Relative Loop Mode
  27982. */
  27983. private static _ANIMATIONLOOPMODE_RELATIVE;
  27984. /**
  27985. * Cycle Loop Mode
  27986. */
  27987. private static _ANIMATIONLOOPMODE_CYCLE;
  27988. /**
  27989. * Constant Loop Mode
  27990. */
  27991. private static _ANIMATIONLOOPMODE_CONSTANT;
  27992. /**
  27993. * Get the float animation type
  27994. */
  27995. static readonly ANIMATIONTYPE_FLOAT: number;
  27996. /**
  27997. * Get the Vector3 animation type
  27998. */
  27999. static readonly ANIMATIONTYPE_VECTOR3: number;
  28000. /**
  28001. * Get the Vector2 animation type
  28002. */
  28003. static readonly ANIMATIONTYPE_VECTOR2: number;
  28004. /**
  28005. * Get the Size animation type
  28006. */
  28007. static readonly ANIMATIONTYPE_SIZE: number;
  28008. /**
  28009. * Get the Quaternion animation type
  28010. */
  28011. static readonly ANIMATIONTYPE_QUATERNION: number;
  28012. /**
  28013. * Get the Matrix animation type
  28014. */
  28015. static readonly ANIMATIONTYPE_MATRIX: number;
  28016. /**
  28017. * Get the Color3 animation type
  28018. */
  28019. static readonly ANIMATIONTYPE_COLOR3: number;
  28020. /**
  28021. * Get the Relative Loop Mode
  28022. */
  28023. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28024. /**
  28025. * Get the Cycle Loop Mode
  28026. */
  28027. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28028. /**
  28029. * Get the Constant Loop Mode
  28030. */
  28031. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28032. /** @hidden */
  28033. static _UniversalLerp(left: any, right: any, amount: number): any;
  28034. /**
  28035. * Parses an animation object and creates an animation
  28036. * @param parsedAnimation Parsed animation object
  28037. * @returns Animation object
  28038. */
  28039. static Parse(parsedAnimation: any): Animation;
  28040. /**
  28041. * Appends the serialized animations from the source animations
  28042. * @param source Source containing the animations
  28043. * @param destination Target to store the animations
  28044. */
  28045. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28046. }
  28047. }
  28048. declare module "babylonjs/Animations/animatable.interface" {
  28049. import { Nullable } from "babylonjs/types";
  28050. import { Animation } from "babylonjs/Animations/animation";
  28051. /**
  28052. * Interface containing an array of animations
  28053. */
  28054. export interface IAnimatable {
  28055. /**
  28056. * Array of animations
  28057. */
  28058. animations: Nullable<Array<Animation>>;
  28059. }
  28060. }
  28061. declare module "babylonjs/Materials/fresnelParameters" {
  28062. import { Color3 } from "babylonjs/Maths/math.color";
  28063. /**
  28064. * This represents all the required information to add a fresnel effect on a material:
  28065. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28066. */
  28067. export class FresnelParameters {
  28068. private _isEnabled;
  28069. /**
  28070. * Define if the fresnel effect is enable or not.
  28071. */
  28072. isEnabled: boolean;
  28073. /**
  28074. * Define the color used on edges (grazing angle)
  28075. */
  28076. leftColor: Color3;
  28077. /**
  28078. * Define the color used on center
  28079. */
  28080. rightColor: Color3;
  28081. /**
  28082. * Define bias applied to computed fresnel term
  28083. */
  28084. bias: number;
  28085. /**
  28086. * Defined the power exponent applied to fresnel term
  28087. */
  28088. power: number;
  28089. /**
  28090. * Clones the current fresnel and its valuues
  28091. * @returns a clone fresnel configuration
  28092. */
  28093. clone(): FresnelParameters;
  28094. /**
  28095. * Serializes the current fresnel parameters to a JSON representation.
  28096. * @return the JSON serialization
  28097. */
  28098. serialize(): any;
  28099. /**
  28100. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28101. * @param parsedFresnelParameters Define the JSON representation
  28102. * @returns the parsed parameters
  28103. */
  28104. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28105. }
  28106. }
  28107. declare module "babylonjs/Misc/decorators" {
  28108. import { Nullable } from "babylonjs/types";
  28109. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28110. import { Scene } from "babylonjs/scene";
  28111. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28112. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28113. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28114. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28115. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28116. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28117. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28118. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28119. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28120. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28121. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28122. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28123. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28124. /**
  28125. * Decorator used to define property that can be serialized as reference to a camera
  28126. * @param sourceName defines the name of the property to decorate
  28127. */
  28128. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28129. /**
  28130. * Class used to help serialization objects
  28131. */
  28132. export class SerializationHelper {
  28133. /** @hidden */
  28134. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28135. /** @hidden */
  28136. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28137. /** @hidden */
  28138. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28139. /** @hidden */
  28140. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28141. /**
  28142. * Appends the serialized animations from the source animations
  28143. * @param source Source containing the animations
  28144. * @param destination Target to store the animations
  28145. */
  28146. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28147. /**
  28148. * Static function used to serialized a specific entity
  28149. * @param entity defines the entity to serialize
  28150. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28151. * @returns a JSON compatible object representing the serialization of the entity
  28152. */
  28153. static Serialize<T>(entity: T, serializationObject?: any): any;
  28154. /**
  28155. * Creates a new entity from a serialization data object
  28156. * @param creationFunction defines a function used to instanciated the new entity
  28157. * @param source defines the source serialization data
  28158. * @param scene defines the hosting scene
  28159. * @param rootUrl defines the root url for resources
  28160. * @returns a new entity
  28161. */
  28162. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28163. /**
  28164. * Clones an object
  28165. * @param creationFunction defines the function used to instanciate the new object
  28166. * @param source defines the source object
  28167. * @returns the cloned object
  28168. */
  28169. static Clone<T>(creationFunction: () => T, source: T): T;
  28170. /**
  28171. * Instanciates a new object based on a source one (some data will be shared between both object)
  28172. * @param creationFunction defines the function used to instanciate the new object
  28173. * @param source defines the source object
  28174. * @returns the new object
  28175. */
  28176. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28177. }
  28178. }
  28179. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28180. import { Nullable } from "babylonjs/types";
  28181. /**
  28182. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28183. */
  28184. export interface CubeMapInfo {
  28185. /**
  28186. * The pixel array for the front face.
  28187. * This is stored in format, left to right, up to down format.
  28188. */
  28189. front: Nullable<ArrayBufferView>;
  28190. /**
  28191. * The pixel array for the back face.
  28192. * This is stored in format, left to right, up to down format.
  28193. */
  28194. back: Nullable<ArrayBufferView>;
  28195. /**
  28196. * The pixel array for the left face.
  28197. * This is stored in format, left to right, up to down format.
  28198. */
  28199. left: Nullable<ArrayBufferView>;
  28200. /**
  28201. * The pixel array for the right face.
  28202. * This is stored in format, left to right, up to down format.
  28203. */
  28204. right: Nullable<ArrayBufferView>;
  28205. /**
  28206. * The pixel array for the up face.
  28207. * This is stored in format, left to right, up to down format.
  28208. */
  28209. up: Nullable<ArrayBufferView>;
  28210. /**
  28211. * The pixel array for the down face.
  28212. * This is stored in format, left to right, up to down format.
  28213. */
  28214. down: Nullable<ArrayBufferView>;
  28215. /**
  28216. * The size of the cubemap stored.
  28217. *
  28218. * Each faces will be size * size pixels.
  28219. */
  28220. size: number;
  28221. /**
  28222. * The format of the texture.
  28223. *
  28224. * RGBA, RGB.
  28225. */
  28226. format: number;
  28227. /**
  28228. * The type of the texture data.
  28229. *
  28230. * UNSIGNED_INT, FLOAT.
  28231. */
  28232. type: number;
  28233. /**
  28234. * Specifies whether the texture is in gamma space.
  28235. */
  28236. gammaSpace: boolean;
  28237. }
  28238. /**
  28239. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28240. */
  28241. export class PanoramaToCubeMapTools {
  28242. private static FACE_FRONT;
  28243. private static FACE_BACK;
  28244. private static FACE_RIGHT;
  28245. private static FACE_LEFT;
  28246. private static FACE_DOWN;
  28247. private static FACE_UP;
  28248. /**
  28249. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28250. *
  28251. * @param float32Array The source data.
  28252. * @param inputWidth The width of the input panorama.
  28253. * @param inputHeight The height of the input panorama.
  28254. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28255. * @return The cubemap data
  28256. */
  28257. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28258. private static CreateCubemapTexture;
  28259. private static CalcProjectionSpherical;
  28260. }
  28261. }
  28262. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28263. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28265. import { Nullable } from "babylonjs/types";
  28266. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28267. /**
  28268. * Helper class dealing with the extraction of spherical polynomial dataArray
  28269. * from a cube map.
  28270. */
  28271. export class CubeMapToSphericalPolynomialTools {
  28272. private static FileFaces;
  28273. /**
  28274. * Converts a texture to the according Spherical Polynomial data.
  28275. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28276. *
  28277. * @param texture The texture to extract the information from.
  28278. * @return The Spherical Polynomial data.
  28279. */
  28280. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28281. /**
  28282. * Converts a cubemap to the according Spherical Polynomial data.
  28283. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28284. *
  28285. * @param cubeInfo The Cube map to extract the information from.
  28286. * @return The Spherical Polynomial data.
  28287. */
  28288. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28289. }
  28290. }
  28291. declare module "babylonjs/Misc/guid" {
  28292. /**
  28293. * Class used to manipulate GUIDs
  28294. */
  28295. export class GUID {
  28296. /**
  28297. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28298. * Be aware Math.random() could cause collisions, but:
  28299. * "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"
  28300. * @returns a pseudo random id
  28301. */
  28302. static RandomId(): string;
  28303. }
  28304. }
  28305. declare module "babylonjs/Materials/Textures/baseTexture" {
  28306. import { Observable } from "babylonjs/Misc/observable";
  28307. import { Nullable } from "babylonjs/types";
  28308. import { Scene } from "babylonjs/scene";
  28309. import { Matrix } from "babylonjs/Maths/math.vector";
  28310. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28312. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28313. import { ISize } from "babylonjs/Maths/math.size";
  28314. /**
  28315. * Base class of all the textures in babylon.
  28316. * It groups all the common properties the materials, post process, lights... might need
  28317. * in order to make a correct use of the texture.
  28318. */
  28319. export class BaseTexture implements IAnimatable {
  28320. /**
  28321. * Default anisotropic filtering level for the application.
  28322. * It is set to 4 as a good tradeoff between perf and quality.
  28323. */
  28324. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28325. /**
  28326. * Gets or sets the unique id of the texture
  28327. */
  28328. uniqueId: number;
  28329. /**
  28330. * Define the name of the texture.
  28331. */
  28332. name: string;
  28333. /**
  28334. * Gets or sets an object used to store user defined information.
  28335. */
  28336. metadata: any;
  28337. /**
  28338. * For internal use only. Please do not use.
  28339. */
  28340. reservedDataStore: any;
  28341. private _hasAlpha;
  28342. /**
  28343. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28344. */
  28345. hasAlpha: boolean;
  28346. /**
  28347. * Defines if the alpha value should be determined via the rgb values.
  28348. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28349. */
  28350. getAlphaFromRGB: boolean;
  28351. /**
  28352. * Intensity or strength of the texture.
  28353. * It is commonly used by materials to fine tune the intensity of the texture
  28354. */
  28355. level: number;
  28356. /**
  28357. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28358. * This is part of the texture as textures usually maps to one uv set.
  28359. */
  28360. coordinatesIndex: number;
  28361. private _coordinatesMode;
  28362. /**
  28363. * How a texture is mapped.
  28364. *
  28365. * | Value | Type | Description |
  28366. * | ----- | ----------------------------------- | ----------- |
  28367. * | 0 | EXPLICIT_MODE | |
  28368. * | 1 | SPHERICAL_MODE | |
  28369. * | 2 | PLANAR_MODE | |
  28370. * | 3 | CUBIC_MODE | |
  28371. * | 4 | PROJECTION_MODE | |
  28372. * | 5 | SKYBOX_MODE | |
  28373. * | 6 | INVCUBIC_MODE | |
  28374. * | 7 | EQUIRECTANGULAR_MODE | |
  28375. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28376. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28377. */
  28378. coordinatesMode: number;
  28379. /**
  28380. * | Value | Type | Description |
  28381. * | ----- | ------------------ | ----------- |
  28382. * | 0 | CLAMP_ADDRESSMODE | |
  28383. * | 1 | WRAP_ADDRESSMODE | |
  28384. * | 2 | MIRROR_ADDRESSMODE | |
  28385. */
  28386. wrapU: number;
  28387. /**
  28388. * | Value | Type | Description |
  28389. * | ----- | ------------------ | ----------- |
  28390. * | 0 | CLAMP_ADDRESSMODE | |
  28391. * | 1 | WRAP_ADDRESSMODE | |
  28392. * | 2 | MIRROR_ADDRESSMODE | |
  28393. */
  28394. wrapV: number;
  28395. /**
  28396. * | Value | Type | Description |
  28397. * | ----- | ------------------ | ----------- |
  28398. * | 0 | CLAMP_ADDRESSMODE | |
  28399. * | 1 | WRAP_ADDRESSMODE | |
  28400. * | 2 | MIRROR_ADDRESSMODE | |
  28401. */
  28402. wrapR: number;
  28403. /**
  28404. * With compliant hardware and browser (supporting anisotropic filtering)
  28405. * this defines the level of anisotropic filtering in the texture.
  28406. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28407. */
  28408. anisotropicFilteringLevel: number;
  28409. /**
  28410. * Define if the texture is a cube texture or if false a 2d texture.
  28411. */
  28412. isCube: boolean;
  28413. /**
  28414. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28415. */
  28416. is3D: boolean;
  28417. /**
  28418. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28419. * HDR texture are usually stored in linear space.
  28420. * This only impacts the PBR and Background materials
  28421. */
  28422. gammaSpace: boolean;
  28423. /**
  28424. * Gets whether or not the texture contains RGBD data.
  28425. */
  28426. readonly isRGBD: boolean;
  28427. /**
  28428. * Is Z inverted in the texture (useful in a cube texture).
  28429. */
  28430. invertZ: boolean;
  28431. /**
  28432. * Are mip maps generated for this texture or not.
  28433. */
  28434. readonly noMipmap: boolean;
  28435. /**
  28436. * @hidden
  28437. */
  28438. lodLevelInAlpha: boolean;
  28439. /**
  28440. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28441. */
  28442. lodGenerationOffset: number;
  28443. /**
  28444. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28445. */
  28446. lodGenerationScale: number;
  28447. /**
  28448. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28449. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28450. * average roughness values.
  28451. */
  28452. linearSpecularLOD: boolean;
  28453. /**
  28454. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28455. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28456. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28457. */
  28458. irradianceTexture: Nullable<BaseTexture>;
  28459. /**
  28460. * Define if the texture is a render target.
  28461. */
  28462. isRenderTarget: boolean;
  28463. /**
  28464. * Define the unique id of the texture in the scene.
  28465. */
  28466. readonly uid: string;
  28467. /**
  28468. * Return a string representation of the texture.
  28469. * @returns the texture as a string
  28470. */
  28471. toString(): string;
  28472. /**
  28473. * Get the class name of the texture.
  28474. * @returns "BaseTexture"
  28475. */
  28476. getClassName(): string;
  28477. /**
  28478. * Define the list of animation attached to the texture.
  28479. */
  28480. animations: import("babylonjs/Animations/animation").Animation[];
  28481. /**
  28482. * An event triggered when the texture is disposed.
  28483. */
  28484. onDisposeObservable: Observable<BaseTexture>;
  28485. private _onDisposeObserver;
  28486. /**
  28487. * Callback triggered when the texture has been disposed.
  28488. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28489. */
  28490. onDispose: () => void;
  28491. /**
  28492. * Define the current state of the loading sequence when in delayed load mode.
  28493. */
  28494. delayLoadState: number;
  28495. private _scene;
  28496. /** @hidden */
  28497. _texture: Nullable<InternalTexture>;
  28498. private _uid;
  28499. /**
  28500. * Define if the texture is preventinga material to render or not.
  28501. * If not and the texture is not ready, the engine will use a default black texture instead.
  28502. */
  28503. readonly isBlocking: boolean;
  28504. /**
  28505. * Instantiates a new BaseTexture.
  28506. * Base class of all the textures in babylon.
  28507. * It groups all the common properties the materials, post process, lights... might need
  28508. * in order to make a correct use of the texture.
  28509. * @param scene Define the scene the texture blongs to
  28510. */
  28511. constructor(scene: Nullable<Scene>);
  28512. /**
  28513. * Get the scene the texture belongs to.
  28514. * @returns the scene or null if undefined
  28515. */
  28516. getScene(): Nullable<Scene>;
  28517. /**
  28518. * Get the texture transform matrix used to offset tile the texture for istance.
  28519. * @returns the transformation matrix
  28520. */
  28521. getTextureMatrix(): Matrix;
  28522. /**
  28523. * Get the texture reflection matrix used to rotate/transform the reflection.
  28524. * @returns the reflection matrix
  28525. */
  28526. getReflectionTextureMatrix(): Matrix;
  28527. /**
  28528. * Get the underlying lower level texture from Babylon.
  28529. * @returns the insternal texture
  28530. */
  28531. getInternalTexture(): Nullable<InternalTexture>;
  28532. /**
  28533. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28534. * @returns true if ready or not blocking
  28535. */
  28536. isReadyOrNotBlocking(): boolean;
  28537. /**
  28538. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28539. * @returns true if fully ready
  28540. */
  28541. isReady(): boolean;
  28542. private _cachedSize;
  28543. /**
  28544. * Get the size of the texture.
  28545. * @returns the texture size.
  28546. */
  28547. getSize(): ISize;
  28548. /**
  28549. * Get the base size of the texture.
  28550. * It can be different from the size if the texture has been resized for POT for instance
  28551. * @returns the base size
  28552. */
  28553. getBaseSize(): ISize;
  28554. /**
  28555. * Update the sampling mode of the texture.
  28556. * Default is Trilinear mode.
  28557. *
  28558. * | Value | Type | Description |
  28559. * | ----- | ------------------ | ----------- |
  28560. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28561. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28562. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28563. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28564. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28565. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28566. * | 7 | NEAREST_LINEAR | |
  28567. * | 8 | NEAREST_NEAREST | |
  28568. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28569. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28570. * | 11 | LINEAR_LINEAR | |
  28571. * | 12 | LINEAR_NEAREST | |
  28572. *
  28573. * > _mag_: magnification filter (close to the viewer)
  28574. * > _min_: minification filter (far from the viewer)
  28575. * > _mip_: filter used between mip map levels
  28576. *@param samplingMode Define the new sampling mode of the texture
  28577. */
  28578. updateSamplingMode(samplingMode: number): void;
  28579. /**
  28580. * Scales the texture if is `canRescale()`
  28581. * @param ratio the resize factor we want to use to rescale
  28582. */
  28583. scale(ratio: number): void;
  28584. /**
  28585. * Get if the texture can rescale.
  28586. */
  28587. readonly canRescale: boolean;
  28588. /** @hidden */
  28589. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28590. /** @hidden */
  28591. _rebuild(): void;
  28592. /**
  28593. * Triggers the load sequence in delayed load mode.
  28594. */
  28595. delayLoad(): void;
  28596. /**
  28597. * Clones the texture.
  28598. * @returns the cloned texture
  28599. */
  28600. clone(): Nullable<BaseTexture>;
  28601. /**
  28602. * Get the texture underlying type (INT, FLOAT...)
  28603. */
  28604. readonly textureType: number;
  28605. /**
  28606. * Get the texture underlying format (RGB, RGBA...)
  28607. */
  28608. readonly textureFormat: number;
  28609. /**
  28610. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28611. * This will returns an RGBA array buffer containing either in values (0-255) or
  28612. * float values (0-1) depending of the underlying buffer type.
  28613. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28614. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28615. * @param buffer defines a user defined buffer to fill with data (can be null)
  28616. * @returns The Array buffer containing the pixels data.
  28617. */
  28618. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28619. /**
  28620. * Release and destroy the underlying lower level texture aka internalTexture.
  28621. */
  28622. releaseInternalTexture(): void;
  28623. /**
  28624. * Get the polynomial representation of the texture data.
  28625. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28626. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28627. */
  28628. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28629. /** @hidden */
  28630. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28631. /** @hidden */
  28632. readonly _lodTextureMid: Nullable<BaseTexture>;
  28633. /** @hidden */
  28634. readonly _lodTextureLow: Nullable<BaseTexture>;
  28635. /**
  28636. * Dispose the texture and release its associated resources.
  28637. */
  28638. dispose(): void;
  28639. /**
  28640. * Serialize the texture into a JSON representation that can be parsed later on.
  28641. * @returns the JSON representation of the texture
  28642. */
  28643. serialize(): any;
  28644. /**
  28645. * Helper function to be called back once a list of texture contains only ready textures.
  28646. * @param textures Define the list of textures to wait for
  28647. * @param callback Define the callback triggered once the entire list will be ready
  28648. */
  28649. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28650. }
  28651. }
  28652. declare module "babylonjs/Materials/Textures/internalTexture" {
  28653. import { Observable } from "babylonjs/Misc/observable";
  28654. import { Nullable, int } from "babylonjs/types";
  28655. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28656. import { Engine } from "babylonjs/Engines/engine";
  28657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28658. /**
  28659. * Class used to store data associated with WebGL texture data for the engine
  28660. * This class should not be used directly
  28661. */
  28662. export class InternalTexture {
  28663. /** @hidden */
  28664. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28665. /**
  28666. * The source of the texture data is unknown
  28667. */
  28668. static DATASOURCE_UNKNOWN: number;
  28669. /**
  28670. * Texture data comes from an URL
  28671. */
  28672. static DATASOURCE_URL: number;
  28673. /**
  28674. * Texture data is only used for temporary storage
  28675. */
  28676. static DATASOURCE_TEMP: number;
  28677. /**
  28678. * Texture data comes from raw data (ArrayBuffer)
  28679. */
  28680. static DATASOURCE_RAW: number;
  28681. /**
  28682. * Texture content is dynamic (video or dynamic texture)
  28683. */
  28684. static DATASOURCE_DYNAMIC: number;
  28685. /**
  28686. * Texture content is generated by rendering to it
  28687. */
  28688. static DATASOURCE_RENDERTARGET: number;
  28689. /**
  28690. * Texture content is part of a multi render target process
  28691. */
  28692. static DATASOURCE_MULTIRENDERTARGET: number;
  28693. /**
  28694. * Texture data comes from a cube data file
  28695. */
  28696. static DATASOURCE_CUBE: number;
  28697. /**
  28698. * Texture data comes from a raw cube data
  28699. */
  28700. static DATASOURCE_CUBERAW: number;
  28701. /**
  28702. * Texture data come from a prefiltered cube data file
  28703. */
  28704. static DATASOURCE_CUBEPREFILTERED: number;
  28705. /**
  28706. * Texture content is raw 3D data
  28707. */
  28708. static DATASOURCE_RAW3D: number;
  28709. /**
  28710. * Texture content is a depth texture
  28711. */
  28712. static DATASOURCE_DEPTHTEXTURE: number;
  28713. /**
  28714. * Texture data comes from a raw cube data encoded with RGBD
  28715. */
  28716. static DATASOURCE_CUBERAW_RGBD: number;
  28717. /**
  28718. * Defines if the texture is ready
  28719. */
  28720. isReady: boolean;
  28721. /**
  28722. * Defines if the texture is a cube texture
  28723. */
  28724. isCube: boolean;
  28725. /**
  28726. * Defines if the texture contains 3D data
  28727. */
  28728. is3D: boolean;
  28729. /**
  28730. * Defines if the texture contains multiview data
  28731. */
  28732. isMultiview: boolean;
  28733. /**
  28734. * Gets the URL used to load this texture
  28735. */
  28736. url: string;
  28737. /**
  28738. * Gets the sampling mode of the texture
  28739. */
  28740. samplingMode: number;
  28741. /**
  28742. * Gets a boolean indicating if the texture needs mipmaps generation
  28743. */
  28744. generateMipMaps: boolean;
  28745. /**
  28746. * Gets the number of samples used by the texture (WebGL2+ only)
  28747. */
  28748. samples: number;
  28749. /**
  28750. * Gets the type of the texture (int, float...)
  28751. */
  28752. type: number;
  28753. /**
  28754. * Gets the format of the texture (RGB, RGBA...)
  28755. */
  28756. format: number;
  28757. /**
  28758. * Observable called when the texture is loaded
  28759. */
  28760. onLoadedObservable: Observable<InternalTexture>;
  28761. /**
  28762. * Gets the width of the texture
  28763. */
  28764. width: number;
  28765. /**
  28766. * Gets the height of the texture
  28767. */
  28768. height: number;
  28769. /**
  28770. * Gets the depth of the texture
  28771. */
  28772. depth: number;
  28773. /**
  28774. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28775. */
  28776. baseWidth: number;
  28777. /**
  28778. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28779. */
  28780. baseHeight: number;
  28781. /**
  28782. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28783. */
  28784. baseDepth: number;
  28785. /**
  28786. * Gets a boolean indicating if the texture is inverted on Y axis
  28787. */
  28788. invertY: boolean;
  28789. /** @hidden */
  28790. _invertVScale: boolean;
  28791. /** @hidden */
  28792. _associatedChannel: number;
  28793. /** @hidden */
  28794. _dataSource: number;
  28795. /** @hidden */
  28796. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28797. /** @hidden */
  28798. _bufferView: Nullable<ArrayBufferView>;
  28799. /** @hidden */
  28800. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28801. /** @hidden */
  28802. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28803. /** @hidden */
  28804. _size: number;
  28805. /** @hidden */
  28806. _extension: string;
  28807. /** @hidden */
  28808. _files: Nullable<string[]>;
  28809. /** @hidden */
  28810. _workingCanvas: Nullable<HTMLCanvasElement>;
  28811. /** @hidden */
  28812. _workingContext: Nullable<CanvasRenderingContext2D>;
  28813. /** @hidden */
  28814. _framebuffer: Nullable<WebGLFramebuffer>;
  28815. /** @hidden */
  28816. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28817. /** @hidden */
  28818. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28819. /** @hidden */
  28820. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28821. /** @hidden */
  28822. _attachments: Nullable<number[]>;
  28823. /** @hidden */
  28824. _cachedCoordinatesMode: Nullable<number>;
  28825. /** @hidden */
  28826. _cachedWrapU: Nullable<number>;
  28827. /** @hidden */
  28828. _cachedWrapV: Nullable<number>;
  28829. /** @hidden */
  28830. _cachedWrapR: Nullable<number>;
  28831. /** @hidden */
  28832. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28833. /** @hidden */
  28834. _isDisabled: boolean;
  28835. /** @hidden */
  28836. _compression: Nullable<string>;
  28837. /** @hidden */
  28838. _generateStencilBuffer: boolean;
  28839. /** @hidden */
  28840. _generateDepthBuffer: boolean;
  28841. /** @hidden */
  28842. _comparisonFunction: number;
  28843. /** @hidden */
  28844. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28845. /** @hidden */
  28846. _lodGenerationScale: number;
  28847. /** @hidden */
  28848. _lodGenerationOffset: number;
  28849. /** @hidden */
  28850. _colorTextureArray: Nullable<WebGLTexture>;
  28851. /** @hidden */
  28852. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28853. /** @hidden */
  28854. _lodTextureHigh: Nullable<BaseTexture>;
  28855. /** @hidden */
  28856. _lodTextureMid: Nullable<BaseTexture>;
  28857. /** @hidden */
  28858. _lodTextureLow: Nullable<BaseTexture>;
  28859. /** @hidden */
  28860. _isRGBD: boolean;
  28861. /** @hidden */
  28862. _linearSpecularLOD: boolean;
  28863. /** @hidden */
  28864. _irradianceTexture: Nullable<BaseTexture>;
  28865. /** @hidden */
  28866. _webGLTexture: Nullable<WebGLTexture>;
  28867. /** @hidden */
  28868. _references: number;
  28869. private _engine;
  28870. /**
  28871. * Gets the Engine the texture belongs to.
  28872. * @returns The babylon engine
  28873. */
  28874. getEngine(): Engine;
  28875. /**
  28876. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28877. */
  28878. readonly dataSource: number;
  28879. /**
  28880. * Creates a new InternalTexture
  28881. * @param engine defines the engine to use
  28882. * @param dataSource defines the type of data that will be used
  28883. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28884. */
  28885. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28886. /**
  28887. * Increments the number of references (ie. the number of Texture that point to it)
  28888. */
  28889. incrementReferences(): void;
  28890. /**
  28891. * Change the size of the texture (not the size of the content)
  28892. * @param width defines the new width
  28893. * @param height defines the new height
  28894. * @param depth defines the new depth (1 by default)
  28895. */
  28896. updateSize(width: int, height: int, depth?: int): void;
  28897. /** @hidden */
  28898. _rebuild(): void;
  28899. /** @hidden */
  28900. _swapAndDie(target: InternalTexture): void;
  28901. /**
  28902. * Dispose the current allocated resources
  28903. */
  28904. dispose(): void;
  28905. }
  28906. }
  28907. declare module "babylonjs/Materials/effect" {
  28908. import { Observable } from "babylonjs/Misc/observable";
  28909. import { Nullable } from "babylonjs/types";
  28910. import { IDisposable } from "babylonjs/scene";
  28911. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28913. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28914. import { Engine } from "babylonjs/Engines/engine";
  28915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28918. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28920. /**
  28921. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28922. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28923. */
  28924. export class EffectFallbacks {
  28925. private _defines;
  28926. private _currentRank;
  28927. private _maxRank;
  28928. private _mesh;
  28929. /**
  28930. * Removes the fallback from the bound mesh.
  28931. */
  28932. unBindMesh(): void;
  28933. /**
  28934. * Adds a fallback on the specified property.
  28935. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28936. * @param define The name of the define in the shader
  28937. */
  28938. addFallback(rank: number, define: string): void;
  28939. /**
  28940. * Sets the mesh to use CPU skinning when needing to fallback.
  28941. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28942. * @param mesh The mesh to use the fallbacks.
  28943. */
  28944. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28945. /**
  28946. * Checks to see if more fallbacks are still availible.
  28947. */
  28948. readonly isMoreFallbacks: boolean;
  28949. /**
  28950. * Removes the defines that should be removed when falling back.
  28951. * @param currentDefines defines the current define statements for the shader.
  28952. * @param effect defines the current effect we try to compile
  28953. * @returns The resulting defines with defines of the current rank removed.
  28954. */
  28955. reduce(currentDefines: string, effect: Effect): string;
  28956. }
  28957. /**
  28958. * Options to be used when creating an effect.
  28959. */
  28960. export class EffectCreationOptions {
  28961. /**
  28962. * Atrributes that will be used in the shader.
  28963. */
  28964. attributes: string[];
  28965. /**
  28966. * Uniform varible names that will be set in the shader.
  28967. */
  28968. uniformsNames: string[];
  28969. /**
  28970. * Uniform buffer varible names that will be set in the shader.
  28971. */
  28972. uniformBuffersNames: string[];
  28973. /**
  28974. * Sampler texture variable names that will be set in the shader.
  28975. */
  28976. samplers: string[];
  28977. /**
  28978. * Define statements that will be set in the shader.
  28979. */
  28980. defines: any;
  28981. /**
  28982. * Possible fallbacks for this effect to improve performance when needed.
  28983. */
  28984. fallbacks: Nullable<EffectFallbacks>;
  28985. /**
  28986. * Callback that will be called when the shader is compiled.
  28987. */
  28988. onCompiled: Nullable<(effect: Effect) => void>;
  28989. /**
  28990. * Callback that will be called if an error occurs during shader compilation.
  28991. */
  28992. onError: Nullable<(effect: Effect, errors: string) => void>;
  28993. /**
  28994. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28995. */
  28996. indexParameters: any;
  28997. /**
  28998. * Max number of lights that can be used in the shader.
  28999. */
  29000. maxSimultaneousLights: number;
  29001. /**
  29002. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29003. */
  29004. transformFeedbackVaryings: Nullable<string[]>;
  29005. }
  29006. /**
  29007. * Effect containing vertex and fragment shader that can be executed on an object.
  29008. */
  29009. export class Effect implements IDisposable {
  29010. /**
  29011. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29012. */
  29013. static ShadersRepository: string;
  29014. /**
  29015. * Name of the effect.
  29016. */
  29017. name: any;
  29018. /**
  29019. * String container all the define statements that should be set on the shader.
  29020. */
  29021. defines: string;
  29022. /**
  29023. * Callback that will be called when the shader is compiled.
  29024. */
  29025. onCompiled: Nullable<(effect: Effect) => void>;
  29026. /**
  29027. * Callback that will be called if an error occurs during shader compilation.
  29028. */
  29029. onError: Nullable<(effect: Effect, errors: string) => void>;
  29030. /**
  29031. * Callback that will be called when effect is bound.
  29032. */
  29033. onBind: Nullable<(effect: Effect) => void>;
  29034. /**
  29035. * Unique ID of the effect.
  29036. */
  29037. uniqueId: number;
  29038. /**
  29039. * Observable that will be called when the shader is compiled.
  29040. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29041. */
  29042. onCompileObservable: Observable<Effect>;
  29043. /**
  29044. * Observable that will be called if an error occurs during shader compilation.
  29045. */
  29046. onErrorObservable: Observable<Effect>;
  29047. /** @hidden */
  29048. _onBindObservable: Nullable<Observable<Effect>>;
  29049. /**
  29050. * Observable that will be called when effect is bound.
  29051. */
  29052. readonly onBindObservable: Observable<Effect>;
  29053. /** @hidden */
  29054. _bonesComputationForcedToCPU: boolean;
  29055. private static _uniqueIdSeed;
  29056. private _engine;
  29057. private _uniformBuffersNames;
  29058. private _uniformsNames;
  29059. private _samplerList;
  29060. private _samplers;
  29061. private _isReady;
  29062. private _compilationError;
  29063. private _attributesNames;
  29064. private _attributes;
  29065. private _uniforms;
  29066. /**
  29067. * Key for the effect.
  29068. * @hidden
  29069. */
  29070. _key: string;
  29071. private _indexParameters;
  29072. private _fallbacks;
  29073. private _vertexSourceCode;
  29074. private _fragmentSourceCode;
  29075. private _vertexSourceCodeOverride;
  29076. private _fragmentSourceCodeOverride;
  29077. private _transformFeedbackVaryings;
  29078. /**
  29079. * Compiled shader to webGL program.
  29080. * @hidden
  29081. */
  29082. _pipelineContext: Nullable<IPipelineContext>;
  29083. private _valueCache;
  29084. private static _baseCache;
  29085. /**
  29086. * Instantiates an effect.
  29087. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29088. * @param baseName Name of the effect.
  29089. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29090. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29091. * @param samplers List of sampler variables that will be passed to the shader.
  29092. * @param engine Engine to be used to render the effect
  29093. * @param defines Define statements to be added to the shader.
  29094. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29095. * @param onCompiled Callback that will be called when the shader is compiled.
  29096. * @param onError Callback that will be called if an error occurs during shader compilation.
  29097. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29098. */
  29099. 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);
  29100. private _useFinalCode;
  29101. /**
  29102. * Unique key for this effect
  29103. */
  29104. readonly key: string;
  29105. /**
  29106. * If the effect has been compiled and prepared.
  29107. * @returns if the effect is compiled and prepared.
  29108. */
  29109. isReady(): boolean;
  29110. /**
  29111. * The engine the effect was initialized with.
  29112. * @returns the engine.
  29113. */
  29114. getEngine(): Engine;
  29115. /**
  29116. * The pipeline context for this effect
  29117. * @returns the associated pipeline context
  29118. */
  29119. getPipelineContext(): Nullable<IPipelineContext>;
  29120. /**
  29121. * The set of names of attribute variables for the shader.
  29122. * @returns An array of attribute names.
  29123. */
  29124. getAttributesNames(): string[];
  29125. /**
  29126. * Returns the attribute at the given index.
  29127. * @param index The index of the attribute.
  29128. * @returns The location of the attribute.
  29129. */
  29130. getAttributeLocation(index: number): number;
  29131. /**
  29132. * Returns the attribute based on the name of the variable.
  29133. * @param name of the attribute to look up.
  29134. * @returns the attribute location.
  29135. */
  29136. getAttributeLocationByName(name: string): number;
  29137. /**
  29138. * The number of attributes.
  29139. * @returns the numnber of attributes.
  29140. */
  29141. getAttributesCount(): number;
  29142. /**
  29143. * Gets the index of a uniform variable.
  29144. * @param uniformName of the uniform to look up.
  29145. * @returns the index.
  29146. */
  29147. getUniformIndex(uniformName: string): number;
  29148. /**
  29149. * Returns the attribute based on the name of the variable.
  29150. * @param uniformName of the uniform to look up.
  29151. * @returns the location of the uniform.
  29152. */
  29153. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29154. /**
  29155. * Returns an array of sampler variable names
  29156. * @returns The array of sampler variable neames.
  29157. */
  29158. getSamplers(): string[];
  29159. /**
  29160. * The error from the last compilation.
  29161. * @returns the error string.
  29162. */
  29163. getCompilationError(): string;
  29164. /**
  29165. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29166. * @param func The callback to be used.
  29167. */
  29168. executeWhenCompiled(func: (effect: Effect) => void): void;
  29169. private _checkIsReady;
  29170. /** @hidden */
  29171. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29172. /** @hidden */
  29173. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29174. /** @hidden */
  29175. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29176. /**
  29177. * Recompiles the webGL program
  29178. * @param vertexSourceCode The source code for the vertex shader.
  29179. * @param fragmentSourceCode The source code for the fragment shader.
  29180. * @param onCompiled Callback called when completed.
  29181. * @param onError Callback called on error.
  29182. * @hidden
  29183. */
  29184. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29185. /**
  29186. * Prepares the effect
  29187. * @hidden
  29188. */
  29189. _prepareEffect(): void;
  29190. /**
  29191. * Checks if the effect is supported. (Must be called after compilation)
  29192. */
  29193. readonly isSupported: boolean;
  29194. /**
  29195. * Binds a texture to the engine to be used as output of the shader.
  29196. * @param channel Name of the output variable.
  29197. * @param texture Texture to bind.
  29198. * @hidden
  29199. */
  29200. _bindTexture(channel: string, texture: InternalTexture): void;
  29201. /**
  29202. * Sets a texture on the engine to be used in the shader.
  29203. * @param channel Name of the sampler variable.
  29204. * @param texture Texture to set.
  29205. */
  29206. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29207. /**
  29208. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29209. * @param channel Name of the sampler variable.
  29210. * @param texture Texture to set.
  29211. */
  29212. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29213. /**
  29214. * Sets an array of textures on the engine to be used in the shader.
  29215. * @param channel Name of the variable.
  29216. * @param textures Textures to set.
  29217. */
  29218. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29219. /**
  29220. * 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)
  29221. * @param channel Name of the sampler variable.
  29222. * @param postProcess Post process to get the input texture from.
  29223. */
  29224. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29225. /**
  29226. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29227. * 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)
  29228. * @param channel Name of the sampler variable.
  29229. * @param postProcess Post process to get the output texture from.
  29230. */
  29231. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29232. /** @hidden */
  29233. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29234. /** @hidden */
  29235. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29236. /** @hidden */
  29237. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29238. /** @hidden */
  29239. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29240. /**
  29241. * Binds a buffer to a uniform.
  29242. * @param buffer Buffer to bind.
  29243. * @param name Name of the uniform variable to bind to.
  29244. */
  29245. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29246. /**
  29247. * Binds block to a uniform.
  29248. * @param blockName Name of the block to bind.
  29249. * @param index Index to bind.
  29250. */
  29251. bindUniformBlock(blockName: string, index: number): void;
  29252. /**
  29253. * Sets an interger value on a uniform variable.
  29254. * @param uniformName Name of the variable.
  29255. * @param value Value to be set.
  29256. * @returns this effect.
  29257. */
  29258. setInt(uniformName: string, value: number): Effect;
  29259. /**
  29260. * Sets an int array on a uniform variable.
  29261. * @param uniformName Name of the variable.
  29262. * @param array array to be set.
  29263. * @returns this effect.
  29264. */
  29265. setIntArray(uniformName: string, array: Int32Array): Effect;
  29266. /**
  29267. * 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)
  29268. * @param uniformName Name of the variable.
  29269. * @param array array to be set.
  29270. * @returns this effect.
  29271. */
  29272. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29273. /**
  29274. * 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)
  29275. * @param uniformName Name of the variable.
  29276. * @param array array to be set.
  29277. * @returns this effect.
  29278. */
  29279. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29280. /**
  29281. * 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)
  29282. * @param uniformName Name of the variable.
  29283. * @param array array to be set.
  29284. * @returns this effect.
  29285. */
  29286. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29287. /**
  29288. * Sets an float array on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param array array to be set.
  29291. * @returns this effect.
  29292. */
  29293. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29294. /**
  29295. * 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)
  29296. * @param uniformName Name of the variable.
  29297. * @param array array to be set.
  29298. * @returns this effect.
  29299. */
  29300. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29301. /**
  29302. * 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)
  29303. * @param uniformName Name of the variable.
  29304. * @param array array to be set.
  29305. * @returns this effect.
  29306. */
  29307. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29308. /**
  29309. * 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)
  29310. * @param uniformName Name of the variable.
  29311. * @param array array to be set.
  29312. * @returns this effect.
  29313. */
  29314. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29315. /**
  29316. * Sets an array on a uniform variable.
  29317. * @param uniformName Name of the variable.
  29318. * @param array array to be set.
  29319. * @returns this effect.
  29320. */
  29321. setArray(uniformName: string, array: number[]): Effect;
  29322. /**
  29323. * 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)
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setArray2(uniformName: string, array: number[]): Effect;
  29329. /**
  29330. * 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)
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setArray3(uniformName: string, array: number[]): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setArray4(uniformName: string, array: number[]): Effect;
  29343. /**
  29344. * Sets matrices on a uniform variable.
  29345. * @param uniformName Name of the variable.
  29346. * @param matrices matrices to be set.
  29347. * @returns this effect.
  29348. */
  29349. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29350. /**
  29351. * Sets matrix on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param matrix matrix to be set.
  29354. * @returns this effect.
  29355. */
  29356. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param matrix matrix to be set.
  29361. * @returns this effect.
  29362. */
  29363. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29364. /**
  29365. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29366. * @param uniformName Name of the variable.
  29367. * @param matrix matrix to be set.
  29368. * @returns this effect.
  29369. */
  29370. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29371. /**
  29372. * Sets a float on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param value value to be set.
  29375. * @returns this effect.
  29376. */
  29377. setFloat(uniformName: string, value: number): Effect;
  29378. /**
  29379. * Sets a boolean on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param bool value to be set.
  29382. * @returns this effect.
  29383. */
  29384. setBool(uniformName: string, bool: boolean): Effect;
  29385. /**
  29386. * Sets a Vector2 on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param vector2 vector2 to be set.
  29389. * @returns this effect.
  29390. */
  29391. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29392. /**
  29393. * Sets a float2 on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param x First float in float2.
  29396. * @param y Second float in float2.
  29397. * @returns this effect.
  29398. */
  29399. setFloat2(uniformName: string, x: number, y: number): Effect;
  29400. /**
  29401. * Sets a Vector3 on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param vector3 Value to be set.
  29404. * @returns this effect.
  29405. */
  29406. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29407. /**
  29408. * Sets a float3 on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param x First float in float3.
  29411. * @param y Second float in float3.
  29412. * @param z Third float in float3.
  29413. * @returns this effect.
  29414. */
  29415. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29416. /**
  29417. * Sets a Vector4 on a uniform variable.
  29418. * @param uniformName Name of the variable.
  29419. * @param vector4 Value to be set.
  29420. * @returns this effect.
  29421. */
  29422. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29423. /**
  29424. * Sets a float4 on a uniform variable.
  29425. * @param uniformName Name of the variable.
  29426. * @param x First float in float4.
  29427. * @param y Second float in float4.
  29428. * @param z Third float in float4.
  29429. * @param w Fourth float in float4.
  29430. * @returns this effect.
  29431. */
  29432. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29433. /**
  29434. * Sets a Color3 on a uniform variable.
  29435. * @param uniformName Name of the variable.
  29436. * @param color3 Value to be set.
  29437. * @returns this effect.
  29438. */
  29439. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29440. /**
  29441. * Sets a Color4 on a uniform variable.
  29442. * @param uniformName Name of the variable.
  29443. * @param color3 Value to be set.
  29444. * @param alpha Alpha value to be set.
  29445. * @returns this effect.
  29446. */
  29447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29448. /**
  29449. * Sets a Color4 on a uniform variable
  29450. * @param uniformName defines the name of the variable
  29451. * @param color4 defines the value to be set
  29452. * @returns this effect.
  29453. */
  29454. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29455. /** Release all associated resources */
  29456. dispose(): void;
  29457. /**
  29458. * This function will add a new shader to the shader store
  29459. * @param name the name of the shader
  29460. * @param pixelShader optional pixel shader content
  29461. * @param vertexShader optional vertex shader content
  29462. */
  29463. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29464. /**
  29465. * Store of each shader (The can be looked up using effect.key)
  29466. */
  29467. static ShadersStore: {
  29468. [key: string]: string;
  29469. };
  29470. /**
  29471. * Store of each included file for a shader (The can be looked up using effect.key)
  29472. */
  29473. static IncludesShadersStore: {
  29474. [key: string]: string;
  29475. };
  29476. /**
  29477. * Resets the cache of effects.
  29478. */
  29479. static ResetCache(): void;
  29480. }
  29481. }
  29482. declare module "babylonjs/Materials/uniformBuffer" {
  29483. import { Nullable, FloatArray } from "babylonjs/types";
  29484. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29485. import { Engine } from "babylonjs/Engines/engine";
  29486. import { Effect } from "babylonjs/Materials/effect";
  29487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29488. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29489. import { Color3 } from "babylonjs/Maths/math.color";
  29490. /**
  29491. * Uniform buffer objects.
  29492. *
  29493. * Handles blocks of uniform on the GPU.
  29494. *
  29495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29496. *
  29497. * For more information, please refer to :
  29498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29499. */
  29500. export class UniformBuffer {
  29501. private _engine;
  29502. private _buffer;
  29503. private _data;
  29504. private _bufferData;
  29505. private _dynamic?;
  29506. private _uniformLocations;
  29507. private _uniformSizes;
  29508. private _uniformLocationPointer;
  29509. private _needSync;
  29510. private _noUBO;
  29511. private _currentEffect;
  29512. private static _MAX_UNIFORM_SIZE;
  29513. private static _tempBuffer;
  29514. /**
  29515. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29516. * This is dynamic to allow compat with webgl 1 and 2.
  29517. * You will need to pass the name of the uniform as well as the value.
  29518. */
  29519. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29520. /**
  29521. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29522. * This is dynamic to allow compat with webgl 1 and 2.
  29523. * You will need to pass the name of the uniform as well as the value.
  29524. */
  29525. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29526. /**
  29527. * Lambda to Update a single float in a uniform buffer.
  29528. * This is dynamic to allow compat with webgl 1 and 2.
  29529. * You will need to pass the name of the uniform as well as the value.
  29530. */
  29531. updateFloat: (name: string, x: number) => void;
  29532. /**
  29533. * Lambda to Update a vec2 of float in a uniform buffer.
  29534. * This is dynamic to allow compat with webgl 1 and 2.
  29535. * You will need to pass the name of the uniform as well as the value.
  29536. */
  29537. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29538. /**
  29539. * Lambda to Update a vec3 of float in a uniform buffer.
  29540. * This is dynamic to allow compat with webgl 1 and 2.
  29541. * You will need to pass the name of the uniform as well as the value.
  29542. */
  29543. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29544. /**
  29545. * Lambda to Update a vec4 of float in a uniform buffer.
  29546. * This is dynamic to allow compat with webgl 1 and 2.
  29547. * You will need to pass the name of the uniform as well as the value.
  29548. */
  29549. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29550. /**
  29551. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29552. * This is dynamic to allow compat with webgl 1 and 2.
  29553. * You will need to pass the name of the uniform as well as the value.
  29554. */
  29555. updateMatrix: (name: string, mat: Matrix) => void;
  29556. /**
  29557. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29558. * This is dynamic to allow compat with webgl 1 and 2.
  29559. * You will need to pass the name of the uniform as well as the value.
  29560. */
  29561. updateVector3: (name: string, vector: Vector3) => void;
  29562. /**
  29563. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29564. * This is dynamic to allow compat with webgl 1 and 2.
  29565. * You will need to pass the name of the uniform as well as the value.
  29566. */
  29567. updateVector4: (name: string, vector: Vector4) => void;
  29568. /**
  29569. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29570. * This is dynamic to allow compat with webgl 1 and 2.
  29571. * You will need to pass the name of the uniform as well as the value.
  29572. */
  29573. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29574. /**
  29575. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29576. * This is dynamic to allow compat with webgl 1 and 2.
  29577. * You will need to pass the name of the uniform as well as the value.
  29578. */
  29579. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29580. /**
  29581. * Instantiates a new Uniform buffer objects.
  29582. *
  29583. * Handles blocks of uniform on the GPU.
  29584. *
  29585. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29586. *
  29587. * For more information, please refer to :
  29588. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29589. * @param engine Define the engine the buffer is associated with
  29590. * @param data Define the data contained in the buffer
  29591. * @param dynamic Define if the buffer is updatable
  29592. */
  29593. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29594. /**
  29595. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29596. * or just falling back on setUniformXXX calls.
  29597. */
  29598. readonly useUbo: boolean;
  29599. /**
  29600. * Indicates if the WebGL underlying uniform buffer is in sync
  29601. * with the javascript cache data.
  29602. */
  29603. readonly isSync: boolean;
  29604. /**
  29605. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29606. * Also, a dynamic UniformBuffer will disable cache verification and always
  29607. * update the underlying WebGL uniform buffer to the GPU.
  29608. * @returns if Dynamic, otherwise false
  29609. */
  29610. isDynamic(): boolean;
  29611. /**
  29612. * The data cache on JS side.
  29613. * @returns the underlying data as a float array
  29614. */
  29615. getData(): Float32Array;
  29616. /**
  29617. * The underlying WebGL Uniform buffer.
  29618. * @returns the webgl buffer
  29619. */
  29620. getBuffer(): Nullable<DataBuffer>;
  29621. /**
  29622. * std140 layout specifies how to align data within an UBO structure.
  29623. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29624. * for specs.
  29625. */
  29626. private _fillAlignment;
  29627. /**
  29628. * Adds an uniform in the buffer.
  29629. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29630. * for the layout to be correct !
  29631. * @param name Name of the uniform, as used in the uniform block in the shader.
  29632. * @param size Data size, or data directly.
  29633. */
  29634. addUniform(name: string, size: number | number[]): void;
  29635. /**
  29636. * Adds a Matrix 4x4 to the uniform buffer.
  29637. * @param name Name of the uniform, as used in the uniform block in the shader.
  29638. * @param mat A 4x4 matrix.
  29639. */
  29640. addMatrix(name: string, mat: Matrix): void;
  29641. /**
  29642. * Adds a vec2 to the uniform buffer.
  29643. * @param name Name of the uniform, as used in the uniform block in the shader.
  29644. * @param x Define the x component value of the vec2
  29645. * @param y Define the y component value of the vec2
  29646. */
  29647. addFloat2(name: string, x: number, y: number): void;
  29648. /**
  29649. * Adds a vec3 to the uniform buffer.
  29650. * @param name Name of the uniform, as used in the uniform block in the shader.
  29651. * @param x Define the x component value of the vec3
  29652. * @param y Define the y component value of the vec3
  29653. * @param z Define the z component value of the vec3
  29654. */
  29655. addFloat3(name: string, x: number, y: number, z: number): void;
  29656. /**
  29657. * Adds a vec3 to the uniform buffer.
  29658. * @param name Name of the uniform, as used in the uniform block in the shader.
  29659. * @param color Define the vec3 from a Color
  29660. */
  29661. addColor3(name: string, color: Color3): void;
  29662. /**
  29663. * Adds a vec4 to the uniform buffer.
  29664. * @param name Name of the uniform, as used in the uniform block in the shader.
  29665. * @param color Define the rgb components from a Color
  29666. * @param alpha Define the a component of the vec4
  29667. */
  29668. addColor4(name: string, color: Color3, alpha: number): void;
  29669. /**
  29670. * Adds a vec3 to the uniform buffer.
  29671. * @param name Name of the uniform, as used in the uniform block in the shader.
  29672. * @param vector Define the vec3 components from a Vector
  29673. */
  29674. addVector3(name: string, vector: Vector3): void;
  29675. /**
  29676. * Adds a Matrix 3x3 to the uniform buffer.
  29677. * @param name Name of the uniform, as used in the uniform block in the shader.
  29678. */
  29679. addMatrix3x3(name: string): void;
  29680. /**
  29681. * Adds a Matrix 2x2 to the uniform buffer.
  29682. * @param name Name of the uniform, as used in the uniform block in the shader.
  29683. */
  29684. addMatrix2x2(name: string): void;
  29685. /**
  29686. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29687. */
  29688. create(): void;
  29689. /** @hidden */
  29690. _rebuild(): void;
  29691. /**
  29692. * Updates the WebGL Uniform Buffer on the GPU.
  29693. * If the `dynamic` flag is set to true, no cache comparison is done.
  29694. * Otherwise, the buffer will be updated only if the cache differs.
  29695. */
  29696. update(): void;
  29697. /**
  29698. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29699. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29700. * @param data Define the flattened data
  29701. * @param size Define the size of the data.
  29702. */
  29703. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29704. private _updateMatrix3x3ForUniform;
  29705. private _updateMatrix3x3ForEffect;
  29706. private _updateMatrix2x2ForEffect;
  29707. private _updateMatrix2x2ForUniform;
  29708. private _updateFloatForEffect;
  29709. private _updateFloatForUniform;
  29710. private _updateFloat2ForEffect;
  29711. private _updateFloat2ForUniform;
  29712. private _updateFloat3ForEffect;
  29713. private _updateFloat3ForUniform;
  29714. private _updateFloat4ForEffect;
  29715. private _updateFloat4ForUniform;
  29716. private _updateMatrixForEffect;
  29717. private _updateMatrixForUniform;
  29718. private _updateVector3ForEffect;
  29719. private _updateVector3ForUniform;
  29720. private _updateVector4ForEffect;
  29721. private _updateVector4ForUniform;
  29722. private _updateColor3ForEffect;
  29723. private _updateColor3ForUniform;
  29724. private _updateColor4ForEffect;
  29725. private _updateColor4ForUniform;
  29726. /**
  29727. * Sets a sampler uniform on the effect.
  29728. * @param name Define the name of the sampler.
  29729. * @param texture Define the texture to set in the sampler
  29730. */
  29731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29732. /**
  29733. * Directly updates the value of the uniform in the cache AND on the GPU.
  29734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29735. * @param data Define the flattened data
  29736. */
  29737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29738. /**
  29739. * Binds this uniform buffer to an effect.
  29740. * @param effect Define the effect to bind the buffer to
  29741. * @param name Name of the uniform block in the shader.
  29742. */
  29743. bindToEffect(effect: Effect, name: string): void;
  29744. /**
  29745. * Disposes the uniform buffer.
  29746. */
  29747. dispose(): void;
  29748. }
  29749. }
  29750. declare module "babylonjs/Audio/analyser" {
  29751. import { Scene } from "babylonjs/scene";
  29752. /**
  29753. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29755. */
  29756. export class Analyser {
  29757. /**
  29758. * Gets or sets the smoothing
  29759. * @ignorenaming
  29760. */
  29761. SMOOTHING: number;
  29762. /**
  29763. * Gets or sets the FFT table size
  29764. * @ignorenaming
  29765. */
  29766. FFT_SIZE: number;
  29767. /**
  29768. * Gets or sets the bar graph amplitude
  29769. * @ignorenaming
  29770. */
  29771. BARGRAPHAMPLITUDE: number;
  29772. /**
  29773. * Gets or sets the position of the debug canvas
  29774. * @ignorenaming
  29775. */
  29776. DEBUGCANVASPOS: {
  29777. x: number;
  29778. y: number;
  29779. };
  29780. /**
  29781. * Gets or sets the debug canvas size
  29782. * @ignorenaming
  29783. */
  29784. DEBUGCANVASSIZE: {
  29785. width: number;
  29786. height: number;
  29787. };
  29788. private _byteFreqs;
  29789. private _byteTime;
  29790. private _floatFreqs;
  29791. private _webAudioAnalyser;
  29792. private _debugCanvas;
  29793. private _debugCanvasContext;
  29794. private _scene;
  29795. private _registerFunc;
  29796. private _audioEngine;
  29797. /**
  29798. * Creates a new analyser
  29799. * @param scene defines hosting scene
  29800. */
  29801. constructor(scene: Scene);
  29802. /**
  29803. * Get the number of data values you will have to play with for the visualization
  29804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29805. * @returns a number
  29806. */
  29807. getFrequencyBinCount(): number;
  29808. /**
  29809. * Gets the current frequency data as a byte array
  29810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29811. * @returns a Uint8Array
  29812. */
  29813. getByteFrequencyData(): Uint8Array;
  29814. /**
  29815. * Gets the current waveform as a byte array
  29816. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29817. * @returns a Uint8Array
  29818. */
  29819. getByteTimeDomainData(): Uint8Array;
  29820. /**
  29821. * Gets the current frequency data as a float array
  29822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29823. * @returns a Float32Array
  29824. */
  29825. getFloatFrequencyData(): Float32Array;
  29826. /**
  29827. * Renders the debug canvas
  29828. */
  29829. drawDebugCanvas(): void;
  29830. /**
  29831. * Stops rendering the debug canvas and removes it
  29832. */
  29833. stopDebugCanvas(): void;
  29834. /**
  29835. * Connects two audio nodes
  29836. * @param inputAudioNode defines first node to connect
  29837. * @param outputAudioNode defines second node to connect
  29838. */
  29839. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29840. /**
  29841. * Releases all associated resources
  29842. */
  29843. dispose(): void;
  29844. }
  29845. }
  29846. declare module "babylonjs/Audio/audioEngine" {
  29847. import { IDisposable } from "babylonjs/scene";
  29848. import { Analyser } from "babylonjs/Audio/analyser";
  29849. import { Nullable } from "babylonjs/types";
  29850. import { Observable } from "babylonjs/Misc/observable";
  29851. /**
  29852. * This represents an audio engine and it is responsible
  29853. * to play, synchronize and analyse sounds throughout the application.
  29854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29855. */
  29856. export interface IAudioEngine extends IDisposable {
  29857. /**
  29858. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29859. */
  29860. readonly canUseWebAudio: boolean;
  29861. /**
  29862. * Gets the current AudioContext if available.
  29863. */
  29864. readonly audioContext: Nullable<AudioContext>;
  29865. /**
  29866. * The master gain node defines the global audio volume of your audio engine.
  29867. */
  29868. readonly masterGain: GainNode;
  29869. /**
  29870. * Gets whether or not mp3 are supported by your browser.
  29871. */
  29872. readonly isMP3supported: boolean;
  29873. /**
  29874. * Gets whether or not ogg are supported by your browser.
  29875. */
  29876. readonly isOGGsupported: boolean;
  29877. /**
  29878. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29879. * @ignoreNaming
  29880. */
  29881. WarnedWebAudioUnsupported: boolean;
  29882. /**
  29883. * Defines if the audio engine relies on a custom unlocked button.
  29884. * In this case, the embedded button will not be displayed.
  29885. */
  29886. useCustomUnlockedButton: boolean;
  29887. /**
  29888. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29889. */
  29890. readonly unlocked: boolean;
  29891. /**
  29892. * Event raised when audio has been unlocked on the browser.
  29893. */
  29894. onAudioUnlockedObservable: Observable<AudioEngine>;
  29895. /**
  29896. * Event raised when audio has been locked on the browser.
  29897. */
  29898. onAudioLockedObservable: Observable<AudioEngine>;
  29899. /**
  29900. * Flags the audio engine in Locked state.
  29901. * This happens due to new browser policies preventing audio to autoplay.
  29902. */
  29903. lock(): void;
  29904. /**
  29905. * Unlocks the audio engine once a user action has been done on the dom.
  29906. * This is helpful to resume play once browser policies have been satisfied.
  29907. */
  29908. unlock(): void;
  29909. }
  29910. /**
  29911. * This represents the default audio engine used in babylon.
  29912. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29914. */
  29915. export class AudioEngine implements IAudioEngine {
  29916. private _audioContext;
  29917. private _audioContextInitialized;
  29918. private _muteButton;
  29919. private _hostElement;
  29920. /**
  29921. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29922. */
  29923. canUseWebAudio: boolean;
  29924. /**
  29925. * The master gain node defines the global audio volume of your audio engine.
  29926. */
  29927. masterGain: GainNode;
  29928. /**
  29929. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29930. * @ignoreNaming
  29931. */
  29932. WarnedWebAudioUnsupported: boolean;
  29933. /**
  29934. * Gets whether or not mp3 are supported by your browser.
  29935. */
  29936. isMP3supported: boolean;
  29937. /**
  29938. * Gets whether or not ogg are supported by your browser.
  29939. */
  29940. isOGGsupported: boolean;
  29941. /**
  29942. * Gets whether audio has been unlocked on the device.
  29943. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29944. * a user interaction has happened.
  29945. */
  29946. unlocked: boolean;
  29947. /**
  29948. * Defines if the audio engine relies on a custom unlocked button.
  29949. * In this case, the embedded button will not be displayed.
  29950. */
  29951. useCustomUnlockedButton: boolean;
  29952. /**
  29953. * Event raised when audio has been unlocked on the browser.
  29954. */
  29955. onAudioUnlockedObservable: Observable<AudioEngine>;
  29956. /**
  29957. * Event raised when audio has been locked on the browser.
  29958. */
  29959. onAudioLockedObservable: Observable<AudioEngine>;
  29960. /**
  29961. * Gets the current AudioContext if available.
  29962. */
  29963. readonly audioContext: Nullable<AudioContext>;
  29964. private _connectedAnalyser;
  29965. /**
  29966. * Instantiates a new audio engine.
  29967. *
  29968. * There should be only one per page as some browsers restrict the number
  29969. * of audio contexts you can create.
  29970. * @param hostElement defines the host element where to display the mute icon if necessary
  29971. */
  29972. constructor(hostElement?: Nullable<HTMLElement>);
  29973. /**
  29974. * Flags the audio engine in Locked state.
  29975. * This happens due to new browser policies preventing audio to autoplay.
  29976. */
  29977. lock(): void;
  29978. /**
  29979. * Unlocks the audio engine once a user action has been done on the dom.
  29980. * This is helpful to resume play once browser policies have been satisfied.
  29981. */
  29982. unlock(): void;
  29983. private _resumeAudioContext;
  29984. private _initializeAudioContext;
  29985. private _tryToRun;
  29986. private _triggerRunningState;
  29987. private _triggerSuspendedState;
  29988. private _displayMuteButton;
  29989. private _moveButtonToTopLeft;
  29990. private _onResize;
  29991. private _hideMuteButton;
  29992. /**
  29993. * Destroy and release the resources associated with the audio ccontext.
  29994. */
  29995. dispose(): void;
  29996. /**
  29997. * Gets the global volume sets on the master gain.
  29998. * @returns the global volume if set or -1 otherwise
  29999. */
  30000. getGlobalVolume(): number;
  30001. /**
  30002. * Sets the global volume of your experience (sets on the master gain).
  30003. * @param newVolume Defines the new global volume of the application
  30004. */
  30005. setGlobalVolume(newVolume: number): void;
  30006. /**
  30007. * Connect the audio engine to an audio analyser allowing some amazing
  30008. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30010. * @param analyser The analyser to connect to the engine
  30011. */
  30012. connectToAnalyser(analyser: Analyser): void;
  30013. }
  30014. }
  30015. declare module "babylonjs/Loading/loadingScreen" {
  30016. /**
  30017. * Interface used to present a loading screen while loading a scene
  30018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30019. */
  30020. export interface ILoadingScreen {
  30021. /**
  30022. * Function called to display the loading screen
  30023. */
  30024. displayLoadingUI: () => void;
  30025. /**
  30026. * Function called to hide the loading screen
  30027. */
  30028. hideLoadingUI: () => void;
  30029. /**
  30030. * Gets or sets the color to use for the background
  30031. */
  30032. loadingUIBackgroundColor: string;
  30033. /**
  30034. * Gets or sets the text to display while loading
  30035. */
  30036. loadingUIText: string;
  30037. }
  30038. /**
  30039. * Class used for the default loading screen
  30040. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30041. */
  30042. export class DefaultLoadingScreen implements ILoadingScreen {
  30043. private _renderingCanvas;
  30044. private _loadingText;
  30045. private _loadingDivBackgroundColor;
  30046. private _loadingDiv;
  30047. private _loadingTextDiv;
  30048. /** Gets or sets the logo url to use for the default loading screen */
  30049. static DefaultLogoUrl: string;
  30050. /** Gets or sets the spinner url to use for the default loading screen */
  30051. static DefaultSpinnerUrl: string;
  30052. /**
  30053. * Creates a new default loading screen
  30054. * @param _renderingCanvas defines the canvas used to render the scene
  30055. * @param _loadingText defines the default text to display
  30056. * @param _loadingDivBackgroundColor defines the default background color
  30057. */
  30058. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30059. /**
  30060. * Function called to display the loading screen
  30061. */
  30062. displayLoadingUI(): void;
  30063. /**
  30064. * Function called to hide the loading screen
  30065. */
  30066. hideLoadingUI(): void;
  30067. /**
  30068. * Gets or sets the text to display while loading
  30069. */
  30070. loadingUIText: string;
  30071. /**
  30072. * Gets or sets the color to use for the background
  30073. */
  30074. loadingUIBackgroundColor: string;
  30075. private _resizeLoadingUI;
  30076. }
  30077. }
  30078. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30079. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30080. import { Engine } from "babylonjs/Engines/engine";
  30081. import { Nullable } from "babylonjs/types";
  30082. /** @hidden */
  30083. export class WebGLPipelineContext implements IPipelineContext {
  30084. engine: Engine;
  30085. program: Nullable<WebGLProgram>;
  30086. context?: WebGLRenderingContext;
  30087. vertexShader?: WebGLShader;
  30088. fragmentShader?: WebGLShader;
  30089. isParallelCompiled: boolean;
  30090. onCompiled?: () => void;
  30091. transformFeedback?: WebGLTransformFeedback | null;
  30092. readonly isAsync: boolean;
  30093. readonly isReady: boolean;
  30094. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30095. }
  30096. }
  30097. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30098. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30099. /** @hidden */
  30100. export class WebGLDataBuffer extends DataBuffer {
  30101. private _buffer;
  30102. constructor(resource: WebGLBuffer);
  30103. readonly underlyingResource: any;
  30104. }
  30105. }
  30106. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30107. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30108. /** @hidden */
  30109. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30110. attributeProcessor(attribute: string): string;
  30111. varyingProcessor(varying: string, isFragment: boolean): string;
  30112. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30113. }
  30114. }
  30115. declare module "babylonjs/Misc/perfCounter" {
  30116. /**
  30117. * This class is used to track a performance counter which is number based.
  30118. * The user has access to many properties which give statistics of different nature.
  30119. *
  30120. * The implementer can track two kinds of Performance Counter: time and count.
  30121. * 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.
  30122. * 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.
  30123. */
  30124. export class PerfCounter {
  30125. /**
  30126. * Gets or sets a global boolean to turn on and off all the counters
  30127. */
  30128. static Enabled: boolean;
  30129. /**
  30130. * Returns the smallest value ever
  30131. */
  30132. readonly min: number;
  30133. /**
  30134. * Returns the biggest value ever
  30135. */
  30136. readonly max: number;
  30137. /**
  30138. * Returns the average value since the performance counter is running
  30139. */
  30140. readonly average: number;
  30141. /**
  30142. * Returns the average value of the last second the counter was monitored
  30143. */
  30144. readonly lastSecAverage: number;
  30145. /**
  30146. * Returns the current value
  30147. */
  30148. readonly current: number;
  30149. /**
  30150. * Gets the accumulated total
  30151. */
  30152. readonly total: number;
  30153. /**
  30154. * Gets the total value count
  30155. */
  30156. readonly count: number;
  30157. /**
  30158. * Creates a new counter
  30159. */
  30160. constructor();
  30161. /**
  30162. * Call this method to start monitoring a new frame.
  30163. * 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.
  30164. */
  30165. fetchNewFrame(): void;
  30166. /**
  30167. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30168. * @param newCount the count value to add to the monitored count
  30169. * @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.
  30170. */
  30171. addCount(newCount: number, fetchResult: boolean): void;
  30172. /**
  30173. * Start monitoring this performance counter
  30174. */
  30175. beginMonitoring(): void;
  30176. /**
  30177. * Compute the time lapsed since the previous beginMonitoring() call.
  30178. * @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
  30179. */
  30180. endMonitoring(newFrame?: boolean): void;
  30181. private _fetchResult;
  30182. private _startMonitoringTime;
  30183. private _min;
  30184. private _max;
  30185. private _average;
  30186. private _current;
  30187. private _totalValueCount;
  30188. private _totalAccumulated;
  30189. private _lastSecAverage;
  30190. private _lastSecAccumulated;
  30191. private _lastSecTime;
  30192. private _lastSecValueCount;
  30193. }
  30194. }
  30195. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30196. /**
  30197. * Interface for any object that can request an animation frame
  30198. */
  30199. export interface ICustomAnimationFrameRequester {
  30200. /**
  30201. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30202. */
  30203. renderFunction?: Function;
  30204. /**
  30205. * Called to request the next frame to render to
  30206. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30207. */
  30208. requestAnimationFrame: Function;
  30209. /**
  30210. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30211. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30212. */
  30213. requestID?: number;
  30214. }
  30215. }
  30216. declare module "babylonjs/Materials/Textures/videoTexture" {
  30217. import { Observable } from "babylonjs/Misc/observable";
  30218. import { Nullable } from "babylonjs/types";
  30219. import { Scene } from "babylonjs/scene";
  30220. import { Texture } from "babylonjs/Materials/Textures/texture";
  30221. /**
  30222. * Settings for finer control over video usage
  30223. */
  30224. export interface VideoTextureSettings {
  30225. /**
  30226. * Applies `autoplay` to video, if specified
  30227. */
  30228. autoPlay?: boolean;
  30229. /**
  30230. * Applies `loop` to video, if specified
  30231. */
  30232. loop?: boolean;
  30233. /**
  30234. * Automatically updates internal texture from video at every frame in the render loop
  30235. */
  30236. autoUpdateTexture: boolean;
  30237. /**
  30238. * Image src displayed during the video loading or until the user interacts with the video.
  30239. */
  30240. poster?: string;
  30241. }
  30242. /**
  30243. * If you want to display a video in your scene, this is the special texture for that.
  30244. * This special texture works similar to other textures, with the exception of a few parameters.
  30245. * @see https://doc.babylonjs.com/how_to/video_texture
  30246. */
  30247. export class VideoTexture extends Texture {
  30248. /**
  30249. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30250. */
  30251. readonly autoUpdateTexture: boolean;
  30252. /**
  30253. * The video instance used by the texture internally
  30254. */
  30255. readonly video: HTMLVideoElement;
  30256. private _onUserActionRequestedObservable;
  30257. /**
  30258. * Event triggerd when a dom action is required by the user to play the video.
  30259. * This happens due to recent changes in browser policies preventing video to auto start.
  30260. */
  30261. readonly onUserActionRequestedObservable: Observable<Texture>;
  30262. private _generateMipMaps;
  30263. private _engine;
  30264. private _stillImageCaptured;
  30265. private _displayingPosterTexture;
  30266. private _settings;
  30267. private _createInternalTextureOnEvent;
  30268. /**
  30269. * Creates a video texture.
  30270. * If you want to display a video in your scene, this is the special texture for that.
  30271. * This special texture works similar to other textures, with the exception of a few parameters.
  30272. * @see https://doc.babylonjs.com/how_to/video_texture
  30273. * @param name optional name, will detect from video source, if not defined
  30274. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30275. * @param scene is obviously the current scene.
  30276. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30277. * @param invertY is false by default but can be used to invert video on Y axis
  30278. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30279. * @param settings allows finer control over video usage
  30280. */
  30281. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30282. private _getName;
  30283. private _getVideo;
  30284. private _createInternalTexture;
  30285. private reset;
  30286. /**
  30287. * @hidden Internal method to initiate `update`.
  30288. */
  30289. _rebuild(): void;
  30290. /**
  30291. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30292. */
  30293. update(): void;
  30294. /**
  30295. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30296. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30297. */
  30298. updateTexture(isVisible: boolean): void;
  30299. protected _updateInternalTexture: () => void;
  30300. /**
  30301. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30302. * @param url New url.
  30303. */
  30304. updateURL(url: string): void;
  30305. /**
  30306. * Dispose the texture and release its associated resources.
  30307. */
  30308. dispose(): void;
  30309. /**
  30310. * Creates a video texture straight from a stream.
  30311. * @param scene Define the scene the texture should be created in
  30312. * @param stream Define the stream the texture should be created from
  30313. * @returns The created video texture as a promise
  30314. */
  30315. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30316. /**
  30317. * Creates a video texture straight from your WebCam video feed.
  30318. * @param scene Define the scene the texture should be created in
  30319. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30320. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30321. * @returns The created video texture as a promise
  30322. */
  30323. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30324. minWidth: number;
  30325. maxWidth: number;
  30326. minHeight: number;
  30327. maxHeight: number;
  30328. deviceId: string;
  30329. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30330. /**
  30331. * Creates a video texture straight from your WebCam video feed.
  30332. * @param scene Define the scene the texture should be created in
  30333. * @param onReady Define a callback to triggered once the texture will be ready
  30334. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30335. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30336. */
  30337. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30338. minWidth: number;
  30339. maxWidth: number;
  30340. minHeight: number;
  30341. maxHeight: number;
  30342. deviceId: string;
  30343. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30344. }
  30345. }
  30346. declare module "babylonjs/Engines/engine" {
  30347. import { Observable } from "babylonjs/Misc/observable";
  30348. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30349. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30350. import { Scene } from "babylonjs/scene";
  30351. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30352. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30353. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30354. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30357. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30358. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30359. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30360. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30361. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30362. import { WebRequest } from "babylonjs/Misc/webRequest";
  30363. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30364. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30365. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30366. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30367. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30368. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30369. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30370. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30371. import { Material } from "babylonjs/Materials/material";
  30372. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30373. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30374. /**
  30375. * Defines the interface used by objects containing a viewport (like a camera)
  30376. */
  30377. interface IViewportOwnerLike {
  30378. /**
  30379. * Gets or sets the viewport
  30380. */
  30381. viewport: IViewportLike;
  30382. }
  30383. /**
  30384. * Interface for attribute information associated with buffer instanciation
  30385. */
  30386. export class InstancingAttributeInfo {
  30387. /**
  30388. * Index/offset of the attribute in the vertex shader
  30389. */
  30390. index: number;
  30391. /**
  30392. * size of the attribute, 1, 2, 3 or 4
  30393. */
  30394. attributeSize: number;
  30395. /**
  30396. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30397. * default is FLOAT
  30398. */
  30399. attribyteType: number;
  30400. /**
  30401. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30402. */
  30403. normalized: boolean;
  30404. /**
  30405. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30406. */
  30407. offset: number;
  30408. /**
  30409. * Name of the GLSL attribute, for debugging purpose only
  30410. */
  30411. attributeName: string;
  30412. }
  30413. /**
  30414. * Define options used to create a depth texture
  30415. */
  30416. export class DepthTextureCreationOptions {
  30417. /** Specifies whether or not a stencil should be allocated in the texture */
  30418. generateStencil?: boolean;
  30419. /** Specifies whether or not bilinear filtering is enable on the texture */
  30420. bilinearFiltering?: boolean;
  30421. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30422. comparisonFunction?: number;
  30423. /** Specifies if the created texture is a cube texture */
  30424. isCube?: boolean;
  30425. }
  30426. /**
  30427. * Class used to describe the capabilities of the engine relatively to the current browser
  30428. */
  30429. export class EngineCapabilities {
  30430. /** Maximum textures units per fragment shader */
  30431. maxTexturesImageUnits: number;
  30432. /** Maximum texture units per vertex shader */
  30433. maxVertexTextureImageUnits: number;
  30434. /** Maximum textures units in the entire pipeline */
  30435. maxCombinedTexturesImageUnits: number;
  30436. /** Maximum texture size */
  30437. maxTextureSize: number;
  30438. /** Maximum cube texture size */
  30439. maxCubemapTextureSize: number;
  30440. /** Maximum render texture size */
  30441. maxRenderTextureSize: number;
  30442. /** Maximum number of vertex attributes */
  30443. maxVertexAttribs: number;
  30444. /** Maximum number of varyings */
  30445. maxVaryingVectors: number;
  30446. /** Maximum number of uniforms per vertex shader */
  30447. maxVertexUniformVectors: number;
  30448. /** Maximum number of uniforms per fragment shader */
  30449. maxFragmentUniformVectors: number;
  30450. /** Defines if standard derivates (dx/dy) are supported */
  30451. standardDerivatives: boolean;
  30452. /** Defines if s3tc texture compression is supported */
  30453. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30454. /** Defines if pvrtc texture compression is supported */
  30455. pvrtc: any;
  30456. /** Defines if etc1 texture compression is supported */
  30457. etc1: any;
  30458. /** Defines if etc2 texture compression is supported */
  30459. etc2: any;
  30460. /** Defines if astc texture compression is supported */
  30461. astc: any;
  30462. /** Defines if float textures are supported */
  30463. textureFloat: boolean;
  30464. /** Defines if vertex array objects are supported */
  30465. vertexArrayObject: boolean;
  30466. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30467. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30468. /** Gets the maximum level of anisotropy supported */
  30469. maxAnisotropy: number;
  30470. /** Defines if instancing is supported */
  30471. instancedArrays: boolean;
  30472. /** Defines if 32 bits indices are supported */
  30473. uintIndices: boolean;
  30474. /** Defines if high precision shaders are supported */
  30475. highPrecisionShaderSupported: boolean;
  30476. /** Defines if depth reading in the fragment shader is supported */
  30477. fragmentDepthSupported: boolean;
  30478. /** Defines if float texture linear filtering is supported*/
  30479. textureFloatLinearFiltering: boolean;
  30480. /** Defines if rendering to float textures is supported */
  30481. textureFloatRender: boolean;
  30482. /** Defines if half float textures are supported*/
  30483. textureHalfFloat: boolean;
  30484. /** Defines if half float texture linear filtering is supported*/
  30485. textureHalfFloatLinearFiltering: boolean;
  30486. /** Defines if rendering to half float textures is supported */
  30487. textureHalfFloatRender: boolean;
  30488. /** Defines if textureLOD shader command is supported */
  30489. textureLOD: boolean;
  30490. /** Defines if draw buffers extension is supported */
  30491. drawBuffersExtension: boolean;
  30492. /** Defines if depth textures are supported */
  30493. depthTextureExtension: boolean;
  30494. /** Defines if float color buffer are supported */
  30495. colorBufferFloat: boolean;
  30496. /** Gets disjoint timer query extension (null if not supported) */
  30497. timerQuery: EXT_disjoint_timer_query;
  30498. /** Defines if timestamp can be used with timer query */
  30499. canUseTimestampForTimerQuery: boolean;
  30500. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30501. multiview: any;
  30502. /** Function used to let the system compiles shaders in background */
  30503. parallelShaderCompile: {
  30504. COMPLETION_STATUS_KHR: number;
  30505. };
  30506. /** Max number of texture samples for MSAA */
  30507. maxMSAASamples: number;
  30508. }
  30509. /** Interface defining initialization parameters for Engine class */
  30510. export interface EngineOptions extends WebGLContextAttributes {
  30511. /**
  30512. * Defines if the engine should no exceed a specified device ratio
  30513. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30514. */
  30515. limitDeviceRatio?: number;
  30516. /**
  30517. * Defines if webvr should be enabled automatically
  30518. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30519. */
  30520. autoEnableWebVR?: boolean;
  30521. /**
  30522. * Defines if webgl2 should be turned off even if supported
  30523. * @see http://doc.babylonjs.com/features/webgl2
  30524. */
  30525. disableWebGL2Support?: boolean;
  30526. /**
  30527. * Defines if webaudio should be initialized as well
  30528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30529. */
  30530. audioEngine?: boolean;
  30531. /**
  30532. * Defines if animations should run using a deterministic lock step
  30533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30534. */
  30535. deterministicLockstep?: boolean;
  30536. /** Defines the maximum steps to use with deterministic lock step mode */
  30537. lockstepMaxSteps?: number;
  30538. /**
  30539. * Defines that engine should ignore context lost events
  30540. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30541. */
  30542. doNotHandleContextLost?: boolean;
  30543. /**
  30544. * Defines that engine should ignore modifying touch action attribute and style
  30545. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30546. */
  30547. doNotHandleTouchAction?: boolean;
  30548. /**
  30549. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30550. */
  30551. useHighPrecisionFloats?: boolean;
  30552. }
  30553. /**
  30554. * Defines the interface used by display changed events
  30555. */
  30556. export interface IDisplayChangedEventArgs {
  30557. /** Gets the vrDisplay object (if any) */
  30558. vrDisplay: Nullable<any>;
  30559. /** Gets a boolean indicating if webVR is supported */
  30560. vrSupported: boolean;
  30561. }
  30562. /**
  30563. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30564. */
  30565. export class Engine {
  30566. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30567. static ExceptionList: ({
  30568. key: string;
  30569. capture: string;
  30570. captureConstraint: number;
  30571. targets: string[];
  30572. } | {
  30573. key: string;
  30574. capture: null;
  30575. captureConstraint: null;
  30576. targets: string[];
  30577. })[];
  30578. /** Gets the list of created engines */
  30579. static readonly Instances: Engine[];
  30580. /**
  30581. * Gets the latest created engine
  30582. */
  30583. static readonly LastCreatedEngine: Nullable<Engine>;
  30584. /**
  30585. * Gets the latest created scene
  30586. */
  30587. static readonly LastCreatedScene: Nullable<Scene>;
  30588. /**
  30589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30590. * @param flag defines which part of the materials must be marked as dirty
  30591. * @param predicate defines a predicate used to filter which materials should be affected
  30592. */
  30593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30594. /** @hidden */
  30595. static _TextureLoaders: IInternalTextureLoader[];
  30596. /** Defines that alpha blending is disabled */
  30597. static readonly ALPHA_DISABLE: number;
  30598. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30599. static readonly ALPHA_ADD: number;
  30600. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30601. static readonly ALPHA_COMBINE: number;
  30602. /** Defines that alpha blending to DEST - SRC * DEST */
  30603. static readonly ALPHA_SUBTRACT: number;
  30604. /** Defines that alpha blending to SRC * DEST */
  30605. static readonly ALPHA_MULTIPLY: number;
  30606. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30607. static readonly ALPHA_MAXIMIZED: number;
  30608. /** Defines that alpha blending to SRC + DEST */
  30609. static readonly ALPHA_ONEONE: number;
  30610. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30611. static readonly ALPHA_PREMULTIPLIED: number;
  30612. /**
  30613. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30615. */
  30616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30617. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30618. static readonly ALPHA_INTERPOLATE: number;
  30619. /**
  30620. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30622. */
  30623. static readonly ALPHA_SCREENMODE: number;
  30624. /** Defines that the ressource is not delayed*/
  30625. static readonly DELAYLOADSTATE_NONE: number;
  30626. /** Defines that the ressource was successfully delay loaded */
  30627. static readonly DELAYLOADSTATE_LOADED: number;
  30628. /** Defines that the ressource is currently delay loading */
  30629. static readonly DELAYLOADSTATE_LOADING: number;
  30630. /** Defines that the ressource is delayed and has not started loading */
  30631. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30633. static readonly NEVER: number;
  30634. /** 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 */
  30635. static readonly ALWAYS: number;
  30636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30637. static readonly LESS: number;
  30638. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30639. static readonly EQUAL: number;
  30640. /** 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 */
  30641. static readonly LEQUAL: number;
  30642. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30643. static readonly GREATER: number;
  30644. /** 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 */
  30645. static readonly GEQUAL: number;
  30646. /** 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 */
  30647. static readonly NOTEQUAL: number;
  30648. /** Passed to stencilOperation to specify that stencil value must be kept */
  30649. static readonly KEEP: number;
  30650. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30651. static readonly REPLACE: number;
  30652. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30653. static readonly INCR: number;
  30654. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30655. static readonly DECR: number;
  30656. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30657. static readonly INVERT: number;
  30658. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30659. static readonly INCR_WRAP: number;
  30660. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30661. static readonly DECR_WRAP: number;
  30662. /** Texture is not repeating outside of 0..1 UVs */
  30663. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30664. /** Texture is repeating outside of 0..1 UVs */
  30665. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30666. /** Texture is repeating and mirrored */
  30667. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30668. /** ALPHA */
  30669. static readonly TEXTUREFORMAT_ALPHA: number;
  30670. /** LUMINANCE */
  30671. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30672. /** LUMINANCE_ALPHA */
  30673. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30674. /** RGB */
  30675. static readonly TEXTUREFORMAT_RGB: number;
  30676. /** RGBA */
  30677. static readonly TEXTUREFORMAT_RGBA: number;
  30678. /** RED */
  30679. static readonly TEXTUREFORMAT_RED: number;
  30680. /** RED (2nd reference) */
  30681. static readonly TEXTUREFORMAT_R: number;
  30682. /** RG */
  30683. static readonly TEXTUREFORMAT_RG: number;
  30684. /** RED_INTEGER */
  30685. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30686. /** RED_INTEGER (2nd reference) */
  30687. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30688. /** RG_INTEGER */
  30689. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30690. /** RGB_INTEGER */
  30691. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30692. /** RGBA_INTEGER */
  30693. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30694. /** UNSIGNED_BYTE */
  30695. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30696. /** UNSIGNED_BYTE (2nd reference) */
  30697. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30698. /** FLOAT */
  30699. static readonly TEXTURETYPE_FLOAT: number;
  30700. /** HALF_FLOAT */
  30701. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30702. /** BYTE */
  30703. static readonly TEXTURETYPE_BYTE: number;
  30704. /** SHORT */
  30705. static readonly TEXTURETYPE_SHORT: number;
  30706. /** UNSIGNED_SHORT */
  30707. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30708. /** INT */
  30709. static readonly TEXTURETYPE_INT: number;
  30710. /** UNSIGNED_INT */
  30711. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30712. /** UNSIGNED_SHORT_4_4_4_4 */
  30713. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30714. /** UNSIGNED_SHORT_5_5_5_1 */
  30715. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30716. /** UNSIGNED_SHORT_5_6_5 */
  30717. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30718. /** UNSIGNED_INT_2_10_10_10_REV */
  30719. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30720. /** UNSIGNED_INT_24_8 */
  30721. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30722. /** UNSIGNED_INT_10F_11F_11F_REV */
  30723. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30724. /** UNSIGNED_INT_5_9_9_9_REV */
  30725. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30726. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30727. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30728. /** nearest is mag = nearest and min = nearest and mip = linear */
  30729. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30731. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30732. /** Trilinear is mag = linear and min = linear and mip = linear */
  30733. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30734. /** nearest is mag = nearest and min = nearest and mip = linear */
  30735. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30736. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30737. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30738. /** Trilinear is mag = linear and min = linear and mip = linear */
  30739. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30740. /** mag = nearest and min = nearest and mip = nearest */
  30741. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30742. /** mag = nearest and min = linear and mip = nearest */
  30743. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30744. /** mag = nearest and min = linear and mip = linear */
  30745. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30746. /** mag = nearest and min = linear and mip = none */
  30747. static readonly TEXTURE_NEAREST_LINEAR: number;
  30748. /** mag = nearest and min = nearest and mip = none */
  30749. static readonly TEXTURE_NEAREST_NEAREST: number;
  30750. /** mag = linear and min = nearest and mip = nearest */
  30751. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30752. /** mag = linear and min = nearest and mip = linear */
  30753. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30754. /** mag = linear and min = linear and mip = none */
  30755. static readonly TEXTURE_LINEAR_LINEAR: number;
  30756. /** mag = linear and min = nearest and mip = none */
  30757. static readonly TEXTURE_LINEAR_NEAREST: number;
  30758. /** Explicit coordinates mode */
  30759. static readonly TEXTURE_EXPLICIT_MODE: number;
  30760. /** Spherical coordinates mode */
  30761. static readonly TEXTURE_SPHERICAL_MODE: number;
  30762. /** Planar coordinates mode */
  30763. static readonly TEXTURE_PLANAR_MODE: number;
  30764. /** Cubic coordinates mode */
  30765. static readonly TEXTURE_CUBIC_MODE: number;
  30766. /** Projection coordinates mode */
  30767. static readonly TEXTURE_PROJECTION_MODE: number;
  30768. /** Skybox coordinates mode */
  30769. static readonly TEXTURE_SKYBOX_MODE: number;
  30770. /** Inverse Cubic coordinates mode */
  30771. static readonly TEXTURE_INVCUBIC_MODE: number;
  30772. /** Equirectangular coordinates mode */
  30773. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30774. /** Equirectangular Fixed coordinates mode */
  30775. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30776. /** Equirectangular Fixed Mirrored coordinates mode */
  30777. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30778. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30779. static readonly SCALEMODE_FLOOR: number;
  30780. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30781. static readonly SCALEMODE_NEAREST: number;
  30782. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30783. static readonly SCALEMODE_CEILING: number;
  30784. /**
  30785. * Returns the current npm package of the sdk
  30786. */
  30787. static readonly NpmPackage: string;
  30788. /**
  30789. * Returns the current version of the framework
  30790. */
  30791. static readonly Version: string;
  30792. /**
  30793. * Returns a string describing the current engine
  30794. */
  30795. readonly description: string;
  30796. /**
  30797. * Gets or sets the epsilon value used by collision engine
  30798. */
  30799. static CollisionsEpsilon: number;
  30800. /**
  30801. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30802. */
  30803. static ShadersRepository: string;
  30804. /**
  30805. * Method called to create the default loading screen.
  30806. * This can be overriden in your own app.
  30807. * @param canvas The rendering canvas element
  30808. * @returns The loading screen
  30809. */
  30810. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30811. /**
  30812. * Method called to create the default rescale post process on each engine.
  30813. */
  30814. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30815. /** @hidden */
  30816. _shaderProcessor: IShaderProcessor;
  30817. /**
  30818. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30819. */
  30820. forcePOTTextures: boolean;
  30821. /**
  30822. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30823. */
  30824. isFullscreen: boolean;
  30825. /**
  30826. * Gets a boolean indicating if the pointer is currently locked
  30827. */
  30828. isPointerLock: boolean;
  30829. /**
  30830. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30831. */
  30832. cullBackFaces: boolean;
  30833. /**
  30834. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30835. */
  30836. renderEvenInBackground: boolean;
  30837. /**
  30838. * Gets or sets a boolean indicating that cache can be kept between frames
  30839. */
  30840. preventCacheWipeBetweenFrames: boolean;
  30841. /**
  30842. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30843. **/
  30844. enableOfflineSupport: boolean;
  30845. /**
  30846. * 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)
  30847. **/
  30848. disableManifestCheck: boolean;
  30849. /**
  30850. * Gets the list of created scenes
  30851. */
  30852. scenes: Scene[];
  30853. /**
  30854. * Event raised when a new scene is created
  30855. */
  30856. onNewSceneAddedObservable: Observable<Scene>;
  30857. /**
  30858. * Gets the list of created postprocesses
  30859. */
  30860. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30861. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30862. validateShaderPrograms: boolean;
  30863. /**
  30864. * Observable event triggered each time the rendering canvas is resized
  30865. */
  30866. onResizeObservable: Observable<Engine>;
  30867. /**
  30868. * Observable event triggered each time the canvas loses focus
  30869. */
  30870. onCanvasBlurObservable: Observable<Engine>;
  30871. /**
  30872. * Observable event triggered each time the canvas gains focus
  30873. */
  30874. onCanvasFocusObservable: Observable<Engine>;
  30875. /**
  30876. * Observable event triggered each time the canvas receives pointerout event
  30877. */
  30878. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30879. /**
  30880. * Observable event triggered before each texture is initialized
  30881. */
  30882. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30883. /**
  30884. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30885. */
  30886. disableUniformBuffers: boolean;
  30887. /** @hidden */
  30888. _uniformBuffers: UniformBuffer[];
  30889. /**
  30890. * Gets a boolean indicating that the engine supports uniform buffers
  30891. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30892. */
  30893. readonly supportsUniformBuffers: boolean;
  30894. /**
  30895. * Observable raised when the engine begins a new frame
  30896. */
  30897. onBeginFrameObservable: Observable<Engine>;
  30898. /**
  30899. * If set, will be used to request the next animation frame for the render loop
  30900. */
  30901. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30902. /**
  30903. * Observable raised when the engine ends the current frame
  30904. */
  30905. onEndFrameObservable: Observable<Engine>;
  30906. /**
  30907. * Observable raised when the engine is about to compile a shader
  30908. */
  30909. onBeforeShaderCompilationObservable: Observable<Engine>;
  30910. /**
  30911. * Observable raised when the engine has jsut compiled a shader
  30912. */
  30913. onAfterShaderCompilationObservable: Observable<Engine>;
  30914. /** @hidden */
  30915. _gl: WebGLRenderingContext;
  30916. private _renderingCanvas;
  30917. private _windowIsBackground;
  30918. private _webGLVersion;
  30919. protected _highPrecisionShadersAllowed: boolean;
  30920. /** @hidden */
  30921. readonly _shouldUseHighPrecisionShader: boolean;
  30922. /**
  30923. * Gets a boolean indicating that only power of 2 textures are supported
  30924. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30925. */
  30926. readonly needPOTTextures: boolean;
  30927. /** @hidden */
  30928. _badOS: boolean;
  30929. /** @hidden */
  30930. _badDesktopOS: boolean;
  30931. /**
  30932. * Gets the audio engine
  30933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30934. * @ignorenaming
  30935. */
  30936. static audioEngine: IAudioEngine;
  30937. /**
  30938. * Default AudioEngine factory responsible of creating the Audio Engine.
  30939. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30940. */
  30941. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30942. /**
  30943. * Default offline support factory responsible of creating a tool used to store data locally.
  30944. * By default, this will create a Database object if the workload has been embedded.
  30945. */
  30946. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30947. private _onFocus;
  30948. private _onBlur;
  30949. private _onCanvasPointerOut;
  30950. private _onCanvasBlur;
  30951. private _onCanvasFocus;
  30952. private _onFullscreenChange;
  30953. private _onPointerLockChange;
  30954. private _hardwareScalingLevel;
  30955. /** @hidden */
  30956. _caps: EngineCapabilities;
  30957. private _pointerLockRequested;
  30958. private _isStencilEnable;
  30959. private _colorWrite;
  30960. private _loadingScreen;
  30961. /** @hidden */
  30962. _drawCalls: PerfCounter;
  30963. private _glVersion;
  30964. private _glRenderer;
  30965. private _glVendor;
  30966. private _videoTextureSupported;
  30967. private _renderingQueueLaunched;
  30968. private _activeRenderLoops;
  30969. private _deterministicLockstep;
  30970. private _lockstepMaxSteps;
  30971. /**
  30972. * Observable signaled when a context lost event is raised
  30973. */
  30974. onContextLostObservable: Observable<Engine>;
  30975. /**
  30976. * Observable signaled when a context restored event is raised
  30977. */
  30978. onContextRestoredObservable: Observable<Engine>;
  30979. private _onContextLost;
  30980. private _onContextRestored;
  30981. private _contextWasLost;
  30982. /** @hidden */
  30983. _doNotHandleContextLost: boolean;
  30984. /**
  30985. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30987. */
  30988. doNotHandleContextLost: boolean;
  30989. private _performanceMonitor;
  30990. private _fps;
  30991. private _deltaTime;
  30992. /**
  30993. * Turn this value on if you want to pause FPS computation when in background
  30994. */
  30995. disablePerformanceMonitorInBackground: boolean;
  30996. /**
  30997. * Gets the performance monitor attached to this engine
  30998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30999. */
  31000. readonly performanceMonitor: PerformanceMonitor;
  31001. /**
  31002. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31003. */
  31004. disableVertexArrayObjects: boolean;
  31005. /** @hidden */
  31006. protected _depthCullingState: _DepthCullingState;
  31007. /** @hidden */
  31008. protected _stencilState: _StencilState;
  31009. /** @hidden */
  31010. protected _alphaState: _AlphaState;
  31011. /** @hidden */
  31012. protected _alphaMode: number;
  31013. /** @hidden */
  31014. _internalTexturesCache: InternalTexture[];
  31015. /** @hidden */
  31016. protected _activeChannel: number;
  31017. private _currentTextureChannel;
  31018. /** @hidden */
  31019. protected _boundTexturesCache: {
  31020. [key: string]: Nullable<InternalTexture>;
  31021. };
  31022. /** @hidden */
  31023. protected _currentEffect: Nullable<Effect>;
  31024. /** @hidden */
  31025. protected _currentProgram: Nullable<WebGLProgram>;
  31026. private _compiledEffects;
  31027. private _vertexAttribArraysEnabled;
  31028. /** @hidden */
  31029. protected _cachedViewport: Nullable<IViewportLike>;
  31030. private _cachedVertexArrayObject;
  31031. /** @hidden */
  31032. protected _cachedVertexBuffers: any;
  31033. /** @hidden */
  31034. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31035. /** @hidden */
  31036. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31037. /** @hidden */
  31038. _currentRenderTarget: Nullable<InternalTexture>;
  31039. private _uintIndicesCurrentlySet;
  31040. private _currentBoundBuffer;
  31041. /** @hidden */
  31042. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31043. private _currentBufferPointers;
  31044. private _currentInstanceLocations;
  31045. private _currentInstanceBuffers;
  31046. private _textureUnits;
  31047. /** @hidden */
  31048. _workingCanvas: Nullable<HTMLCanvasElement>;
  31049. /** @hidden */
  31050. _workingContext: Nullable<CanvasRenderingContext2D>;
  31051. private _rescalePostProcess;
  31052. private _dummyFramebuffer;
  31053. private _externalData;
  31054. /** @hidden */
  31055. _bindedRenderFunction: any;
  31056. private _vaoRecordInProgress;
  31057. private _mustWipeVertexAttributes;
  31058. private _emptyTexture;
  31059. private _emptyCubeTexture;
  31060. private _emptyTexture3D;
  31061. /** @hidden */
  31062. _frameHandler: number;
  31063. private _nextFreeTextureSlots;
  31064. private _maxSimultaneousTextures;
  31065. private _activeRequests;
  31066. private _texturesSupported;
  31067. /** @hidden */
  31068. _textureFormatInUse: Nullable<string>;
  31069. /**
  31070. * Gets the list of texture formats supported
  31071. */
  31072. readonly texturesSupported: Array<string>;
  31073. /**
  31074. * Gets the list of texture formats in use
  31075. */
  31076. readonly textureFormatInUse: Nullable<string>;
  31077. /**
  31078. * Gets the current viewport
  31079. */
  31080. readonly currentViewport: Nullable<IViewportLike>;
  31081. /**
  31082. * Gets the default empty texture
  31083. */
  31084. readonly emptyTexture: InternalTexture;
  31085. /**
  31086. * Gets the default empty 3D texture
  31087. */
  31088. readonly emptyTexture3D: InternalTexture;
  31089. /**
  31090. * Gets the default empty cube texture
  31091. */
  31092. readonly emptyCubeTexture: InternalTexture;
  31093. /**
  31094. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31095. */
  31096. readonly premultipliedAlpha: boolean;
  31097. /**
  31098. * Creates a new engine
  31099. * @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
  31100. * @param antialias defines enable antialiasing (default: false)
  31101. * @param options defines further options to be sent to the getContext() function
  31102. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31103. */
  31104. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31105. /**
  31106. * Initializes a webVR display and starts listening to display change events
  31107. * The onVRDisplayChangedObservable will be notified upon these changes
  31108. * @returns The onVRDisplayChangedObservable
  31109. */
  31110. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31111. /** @hidden */
  31112. _prepareVRComponent(): void;
  31113. /** @hidden */
  31114. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31115. /** @hidden */
  31116. _submitVRFrame(): void;
  31117. /**
  31118. * Call this function to leave webVR mode
  31119. * Will do nothing if webVR is not supported or if there is no webVR device
  31120. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31121. */
  31122. disableVR(): void;
  31123. /**
  31124. * Gets a boolean indicating that the system is in VR mode and is presenting
  31125. * @returns true if VR mode is engaged
  31126. */
  31127. isVRPresenting(): boolean;
  31128. /** @hidden */
  31129. _requestVRFrame(): void;
  31130. private _disableTouchAction;
  31131. private _rebuildInternalTextures;
  31132. private _rebuildEffects;
  31133. /**
  31134. * Gets a boolean indicating if all created effects are ready
  31135. * @returns true if all effects are ready
  31136. */
  31137. areAllEffectsReady(): boolean;
  31138. private _rebuildBuffers;
  31139. private _initGLContext;
  31140. /**
  31141. * Gets version of the current webGL context
  31142. */
  31143. readonly webGLVersion: number;
  31144. /**
  31145. * Gets a string idenfifying the name of the class
  31146. * @returns "Engine" string
  31147. */
  31148. getClassName(): string;
  31149. /**
  31150. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31151. */
  31152. readonly isStencilEnable: boolean;
  31153. /** @hidden */
  31154. _prepareWorkingCanvas(): void;
  31155. /**
  31156. * Reset the texture cache to empty state
  31157. */
  31158. resetTextureCache(): void;
  31159. /**
  31160. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31162. * @returns true if engine is in deterministic lock step mode
  31163. */
  31164. isDeterministicLockStep(): boolean;
  31165. /**
  31166. * Gets the max steps when engine is running in deterministic lock step
  31167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31168. * @returns the max steps
  31169. */
  31170. getLockstepMaxSteps(): number;
  31171. /**
  31172. * Gets an object containing information about the current webGL context
  31173. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31174. */
  31175. getGlInfo(): {
  31176. vendor: string;
  31177. renderer: string;
  31178. version: string;
  31179. };
  31180. /**
  31181. * Gets current aspect ratio
  31182. * @param viewportOwner defines the camera to use to get the aspect ratio
  31183. * @param useScreen defines if screen size must be used (or the current render target if any)
  31184. * @returns a number defining the aspect ratio
  31185. */
  31186. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31187. /**
  31188. * Gets current screen aspect ratio
  31189. * @returns a number defining the aspect ratio
  31190. */
  31191. getScreenAspectRatio(): number;
  31192. /**
  31193. * Gets the current render width
  31194. * @param useScreen defines if screen size must be used (or the current render target if any)
  31195. * @returns a number defining the current render width
  31196. */
  31197. getRenderWidth(useScreen?: boolean): number;
  31198. /**
  31199. * Gets the current render height
  31200. * @param useScreen defines if screen size must be used (or the current render target if any)
  31201. * @returns a number defining the current render height
  31202. */
  31203. getRenderHeight(useScreen?: boolean): number;
  31204. /**
  31205. * Gets the HTML canvas attached with the current webGL context
  31206. * @returns a HTML canvas
  31207. */
  31208. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31209. /**
  31210. * Gets host window
  31211. * @returns the host window object
  31212. */
  31213. getHostWindow(): Window;
  31214. /**
  31215. * Gets host document
  31216. * @returns the host document object
  31217. */
  31218. getHostDocument(): Document;
  31219. /**
  31220. * Gets the client rect of the HTML canvas attached with the current webGL context
  31221. * @returns a client rectanglee
  31222. */
  31223. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31224. /**
  31225. * Defines the hardware scaling level.
  31226. * By default the hardware scaling level is computed from the window device ratio.
  31227. * 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.
  31228. * @param level defines the level to use
  31229. */
  31230. setHardwareScalingLevel(level: number): void;
  31231. /**
  31232. * Gets the current hardware scaling level.
  31233. * By default the hardware scaling level is computed from the window device ratio.
  31234. * 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.
  31235. * @returns a number indicating the current hardware scaling level
  31236. */
  31237. getHardwareScalingLevel(): number;
  31238. /**
  31239. * Gets the list of loaded textures
  31240. * @returns an array containing all loaded textures
  31241. */
  31242. getLoadedTexturesCache(): InternalTexture[];
  31243. /**
  31244. * Gets the object containing all engine capabilities
  31245. * @returns the EngineCapabilities object
  31246. */
  31247. getCaps(): EngineCapabilities;
  31248. /**
  31249. * Gets the current depth function
  31250. * @returns a number defining the depth function
  31251. */
  31252. getDepthFunction(): Nullable<number>;
  31253. /**
  31254. * Sets the current depth function
  31255. * @param depthFunc defines the function to use
  31256. */
  31257. setDepthFunction(depthFunc: number): void;
  31258. /**
  31259. * Sets the current depth function to GREATER
  31260. */
  31261. setDepthFunctionToGreater(): void;
  31262. /**
  31263. * Sets the current depth function to GEQUAL
  31264. */
  31265. setDepthFunctionToGreaterOrEqual(): void;
  31266. /**
  31267. * Sets the current depth function to LESS
  31268. */
  31269. setDepthFunctionToLess(): void;
  31270. private _cachedStencilBuffer;
  31271. private _cachedStencilFunction;
  31272. private _cachedStencilMask;
  31273. private _cachedStencilOperationPass;
  31274. private _cachedStencilOperationFail;
  31275. private _cachedStencilOperationDepthFail;
  31276. private _cachedStencilReference;
  31277. /**
  31278. * Caches the the state of the stencil buffer
  31279. */
  31280. cacheStencilState(): void;
  31281. /**
  31282. * Restores the state of the stencil buffer
  31283. */
  31284. restoreStencilState(): void;
  31285. /**
  31286. * Sets the current depth function to LEQUAL
  31287. */
  31288. setDepthFunctionToLessOrEqual(): void;
  31289. /**
  31290. * Gets a boolean indicating if stencil buffer is enabled
  31291. * @returns the current stencil buffer state
  31292. */
  31293. getStencilBuffer(): boolean;
  31294. /**
  31295. * Enable or disable the stencil buffer
  31296. * @param enable defines if the stencil buffer must be enabled or disabled
  31297. */
  31298. setStencilBuffer(enable: boolean): void;
  31299. /**
  31300. * Gets the current stencil mask
  31301. * @returns a number defining the new stencil mask to use
  31302. */
  31303. getStencilMask(): number;
  31304. /**
  31305. * Sets the current stencil mask
  31306. * @param mask defines the new stencil mask to use
  31307. */
  31308. setStencilMask(mask: number): void;
  31309. /**
  31310. * Gets the current stencil function
  31311. * @returns a number defining the stencil function to use
  31312. */
  31313. getStencilFunction(): number;
  31314. /**
  31315. * Gets the current stencil reference value
  31316. * @returns a number defining the stencil reference value to use
  31317. */
  31318. getStencilFunctionReference(): number;
  31319. /**
  31320. * Gets the current stencil mask
  31321. * @returns a number defining the stencil mask to use
  31322. */
  31323. getStencilFunctionMask(): number;
  31324. /**
  31325. * Sets the current stencil function
  31326. * @param stencilFunc defines the new stencil function to use
  31327. */
  31328. setStencilFunction(stencilFunc: number): void;
  31329. /**
  31330. * Sets the current stencil reference
  31331. * @param reference defines the new stencil reference to use
  31332. */
  31333. setStencilFunctionReference(reference: number): void;
  31334. /**
  31335. * Sets the current stencil mask
  31336. * @param mask defines the new stencil mask to use
  31337. */
  31338. setStencilFunctionMask(mask: number): void;
  31339. /**
  31340. * Gets the current stencil operation when stencil fails
  31341. * @returns a number defining stencil operation to use when stencil fails
  31342. */
  31343. getStencilOperationFail(): number;
  31344. /**
  31345. * Gets the current stencil operation when depth fails
  31346. * @returns a number defining stencil operation to use when depth fails
  31347. */
  31348. getStencilOperationDepthFail(): number;
  31349. /**
  31350. * Gets the current stencil operation when stencil passes
  31351. * @returns a number defining stencil operation to use when stencil passes
  31352. */
  31353. getStencilOperationPass(): number;
  31354. /**
  31355. * Sets the stencil operation to use when stencil fails
  31356. * @param operation defines the stencil operation to use when stencil fails
  31357. */
  31358. setStencilOperationFail(operation: number): void;
  31359. /**
  31360. * Sets the stencil operation to use when depth fails
  31361. * @param operation defines the stencil operation to use when depth fails
  31362. */
  31363. setStencilOperationDepthFail(operation: number): void;
  31364. /**
  31365. * Sets the stencil operation to use when stencil passes
  31366. * @param operation defines the stencil operation to use when stencil passes
  31367. */
  31368. setStencilOperationPass(operation: number): void;
  31369. /**
  31370. * Sets a boolean indicating if the dithering state is enabled or disabled
  31371. * @param value defines the dithering state
  31372. */
  31373. setDitheringState(value: boolean): void;
  31374. /**
  31375. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31376. * @param value defines the rasterizer state
  31377. */
  31378. setRasterizerState(value: boolean): void;
  31379. /**
  31380. * stop executing a render loop function and remove it from the execution array
  31381. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31382. */
  31383. stopRenderLoop(renderFunction?: () => void): void;
  31384. /** @hidden */
  31385. _renderLoop(): void;
  31386. /**
  31387. * Register and execute a render loop. The engine can have more than one render function
  31388. * @param renderFunction defines the function to continuously execute
  31389. */
  31390. runRenderLoop(renderFunction: () => void): void;
  31391. /**
  31392. * Toggle full screen mode
  31393. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31394. */
  31395. switchFullscreen(requestPointerLock: boolean): void;
  31396. /**
  31397. * Enters full screen mode
  31398. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31399. */
  31400. enterFullscreen(requestPointerLock: boolean): void;
  31401. /**
  31402. * Exits full screen mode
  31403. */
  31404. exitFullscreen(): void;
  31405. /**
  31406. * Enters Pointerlock mode
  31407. */
  31408. enterPointerlock(): void;
  31409. /**
  31410. * Exits Pointerlock mode
  31411. */
  31412. exitPointerlock(): void;
  31413. /**
  31414. * Clear the current render buffer or the current render target (if any is set up)
  31415. * @param color defines the color to use
  31416. * @param backBuffer defines if the back buffer must be cleared
  31417. * @param depth defines if the depth buffer must be cleared
  31418. * @param stencil defines if the stencil buffer must be cleared
  31419. */
  31420. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31421. /**
  31422. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31423. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31424. * @param y defines the y-coordinate of the corner of the clear rectangle
  31425. * @param width defines the width of the clear rectangle
  31426. * @param height defines the height of the clear rectangle
  31427. * @param clearColor defines the clear color
  31428. */
  31429. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31430. /**
  31431. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31432. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31433. * @param y defines the y-coordinate of the corner of the clear rectangle
  31434. * @param width defines the width of the clear rectangle
  31435. * @param height defines the height of the clear rectangle
  31436. */
  31437. enableScissor(x: number, y: number, width: number, height: number): void;
  31438. /**
  31439. * Disable previously set scissor test rectangle
  31440. */
  31441. disableScissor(): void;
  31442. private _viewportCached;
  31443. /** @hidden */
  31444. _viewport(x: number, y: number, width: number, height: number): void;
  31445. /**
  31446. * Set the WebGL's viewport
  31447. * @param viewport defines the viewport element to be used
  31448. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31449. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31450. */
  31451. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31452. /**
  31453. * Directly set the WebGL Viewport
  31454. * @param x defines the x coordinate of the viewport (in screen space)
  31455. * @param y defines the y coordinate of the viewport (in screen space)
  31456. * @param width defines the width of the viewport (in screen space)
  31457. * @param height defines the height of the viewport (in screen space)
  31458. * @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
  31459. */
  31460. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31461. /**
  31462. * Begin a new frame
  31463. */
  31464. beginFrame(): void;
  31465. /**
  31466. * Enf the current frame
  31467. */
  31468. endFrame(): void;
  31469. /**
  31470. * Resize the view according to the canvas' size
  31471. */
  31472. resize(): void;
  31473. /**
  31474. * Force a specific size of the canvas
  31475. * @param width defines the new canvas' width
  31476. * @param height defines the new canvas' height
  31477. */
  31478. setSize(width: number, height: number): void;
  31479. /**
  31480. * Binds the frame buffer to the specified texture.
  31481. * @param texture The texture to render to or null for the default canvas
  31482. * @param faceIndex The face of the texture to render to in case of cube texture
  31483. * @param requiredWidth The width of the target to render to
  31484. * @param requiredHeight The height of the target to render to
  31485. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31486. * @param depthStencilTexture The depth stencil texture to use to render
  31487. * @param lodLevel defines le lod level to bind to the frame buffer
  31488. */
  31489. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31490. /** @hidden */
  31491. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31492. /**
  31493. * Unbind the current render target texture from the webGL context
  31494. * @param texture defines the render target texture to unbind
  31495. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31496. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31497. */
  31498. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31499. /**
  31500. * Force the mipmap generation for the given render target texture
  31501. * @param texture defines the render target texture to use
  31502. */
  31503. generateMipMapsForCubemap(texture: InternalTexture): void;
  31504. /**
  31505. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31506. */
  31507. flushFramebuffer(): void;
  31508. /**
  31509. * Unbind the current render target and bind the default framebuffer
  31510. */
  31511. restoreDefaultFramebuffer(): void;
  31512. /**
  31513. * Create an uniform buffer
  31514. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31515. * @param elements defines the content of the uniform buffer
  31516. * @returns the webGL uniform buffer
  31517. */
  31518. createUniformBuffer(elements: FloatArray): DataBuffer;
  31519. /**
  31520. * Create a dynamic uniform buffer
  31521. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31522. * @param elements defines the content of the uniform buffer
  31523. * @returns the webGL uniform buffer
  31524. */
  31525. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31526. /**
  31527. * Update an existing uniform buffer
  31528. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31529. * @param uniformBuffer defines the target uniform buffer
  31530. * @param elements defines the content to update
  31531. * @param offset defines the offset in the uniform buffer where update should start
  31532. * @param count defines the size of the data to update
  31533. */
  31534. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31535. private _resetVertexBufferBinding;
  31536. /**
  31537. * Creates a vertex buffer
  31538. * @param data the data for the vertex buffer
  31539. * @returns the new WebGL static buffer
  31540. */
  31541. createVertexBuffer(data: DataArray): DataBuffer;
  31542. /**
  31543. * Creates a dynamic vertex buffer
  31544. * @param data the data for the dynamic vertex buffer
  31545. * @returns the new WebGL dynamic buffer
  31546. */
  31547. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31548. /**
  31549. * Update a dynamic index buffer
  31550. * @param indexBuffer defines the target index buffer
  31551. * @param indices defines the data to update
  31552. * @param offset defines the offset in the target index buffer where update should start
  31553. */
  31554. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31555. /**
  31556. * Updates a dynamic vertex buffer.
  31557. * @param vertexBuffer the vertex buffer to update
  31558. * @param data the data used to update the vertex buffer
  31559. * @param byteOffset the byte offset of the data
  31560. * @param byteLength the byte length of the data
  31561. */
  31562. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31563. private _resetIndexBufferBinding;
  31564. /**
  31565. * Creates a new index buffer
  31566. * @param indices defines the content of the index buffer
  31567. * @param updatable defines if the index buffer must be updatable
  31568. * @returns a new webGL buffer
  31569. */
  31570. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31571. /**
  31572. * Bind a webGL buffer to the webGL context
  31573. * @param buffer defines the buffer to bind
  31574. */
  31575. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31576. /**
  31577. * Bind an uniform buffer to the current webGL context
  31578. * @param buffer defines the buffer to bind
  31579. */
  31580. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31581. /**
  31582. * Bind a buffer to the current webGL context at a given location
  31583. * @param buffer defines the buffer to bind
  31584. * @param location defines the index where to bind the buffer
  31585. */
  31586. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31587. /**
  31588. * Bind a specific block at a given index in a specific shader program
  31589. * @param pipelineContext defines the pipeline context to use
  31590. * @param blockName defines the block name
  31591. * @param index defines the index where to bind the block
  31592. */
  31593. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31594. private bindIndexBuffer;
  31595. private bindBuffer;
  31596. /**
  31597. * update the bound buffer with the given data
  31598. * @param data defines the data to update
  31599. */
  31600. updateArrayBuffer(data: Float32Array): void;
  31601. private _vertexAttribPointer;
  31602. private _bindIndexBufferWithCache;
  31603. private _bindVertexBuffersAttributes;
  31604. /**
  31605. * Records a vertex array object
  31606. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31607. * @param vertexBuffers defines the list of vertex buffers to store
  31608. * @param indexBuffer defines the index buffer to store
  31609. * @param effect defines the effect to store
  31610. * @returns the new vertex array object
  31611. */
  31612. recordVertexArrayObject(vertexBuffers: {
  31613. [key: string]: VertexBuffer;
  31614. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31615. /**
  31616. * Bind a specific vertex array object
  31617. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31618. * @param vertexArrayObject defines the vertex array object to bind
  31619. * @param indexBuffer defines the index buffer to bind
  31620. */
  31621. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31622. /**
  31623. * Bind webGl buffers directly to the webGL context
  31624. * @param vertexBuffer defines the vertex buffer to bind
  31625. * @param indexBuffer defines the index buffer to bind
  31626. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31627. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31628. * @param effect defines the effect associated with the vertex buffer
  31629. */
  31630. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31631. private _unbindVertexArrayObject;
  31632. /**
  31633. * Bind a list of vertex buffers to the webGL context
  31634. * @param vertexBuffers defines the list of vertex buffers to bind
  31635. * @param indexBuffer defines the index buffer to bind
  31636. * @param effect defines the effect associated with the vertex buffers
  31637. */
  31638. bindBuffers(vertexBuffers: {
  31639. [key: string]: Nullable<VertexBuffer>;
  31640. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31641. /**
  31642. * Unbind all instance attributes
  31643. */
  31644. unbindInstanceAttributes(): void;
  31645. /**
  31646. * Release and free the memory of a vertex array object
  31647. * @param vao defines the vertex array object to delete
  31648. */
  31649. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31650. /** @hidden */
  31651. _releaseBuffer(buffer: DataBuffer): boolean;
  31652. /**
  31653. * Creates a webGL buffer to use with instanciation
  31654. * @param capacity defines the size of the buffer
  31655. * @returns the webGL buffer
  31656. */
  31657. createInstancesBuffer(capacity: number): DataBuffer;
  31658. /**
  31659. * Delete a webGL buffer used with instanciation
  31660. * @param buffer defines the webGL buffer to delete
  31661. */
  31662. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31663. /**
  31664. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31665. * @param instancesBuffer defines the webGL buffer to update and bind
  31666. * @param data defines the data to store in the buffer
  31667. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31668. */
  31669. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31670. /**
  31671. * Apply all cached states (depth, culling, stencil and alpha)
  31672. */
  31673. applyStates(): void;
  31674. /**
  31675. * Send a draw order
  31676. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31677. * @param indexStart defines the starting index
  31678. * @param indexCount defines the number of index to draw
  31679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31680. */
  31681. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31682. /**
  31683. * Draw a list of points
  31684. * @param verticesStart defines the index of first vertex to draw
  31685. * @param verticesCount defines the count of vertices to draw
  31686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31687. */
  31688. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31689. /**
  31690. * Draw a list of unindexed primitives
  31691. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31692. * @param verticesStart defines the index of first vertex to draw
  31693. * @param verticesCount defines the count of vertices to draw
  31694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31695. */
  31696. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31697. /**
  31698. * Draw a list of indexed primitives
  31699. * @param fillMode defines the primitive to use
  31700. * @param indexStart defines the starting index
  31701. * @param indexCount defines the number of index to draw
  31702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31703. */
  31704. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31705. /**
  31706. * Draw a list of unindexed primitives
  31707. * @param fillMode defines the primitive to use
  31708. * @param verticesStart defines the index of first vertex to draw
  31709. * @param verticesCount defines the count of vertices to draw
  31710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31711. */
  31712. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31713. private _drawMode;
  31714. /** @hidden */
  31715. _releaseEffect(effect: Effect): void;
  31716. /** @hidden */
  31717. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31718. /**
  31719. * Create a new effect (used to store vertex/fragment shaders)
  31720. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31721. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31722. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31723. * @param samplers defines an array of string used to represent textures
  31724. * @param defines defines the string containing the defines to use to compile the shaders
  31725. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31726. * @param onCompiled defines a function to call when the effect creation is successful
  31727. * @param onError defines a function to call when the effect creation has failed
  31728. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31729. * @returns the new Effect
  31730. */
  31731. 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;
  31732. private _compileShader;
  31733. private _compileRawShader;
  31734. /**
  31735. * Directly creates a webGL program
  31736. * @param pipelineContext defines the pipeline context to attach to
  31737. * @param vertexCode defines the vertex shader code to use
  31738. * @param fragmentCode defines the fragment shader code to use
  31739. * @param context defines the webGL context to use (if not set, the current one will be used)
  31740. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31741. * @returns the new webGL program
  31742. */
  31743. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31744. /**
  31745. * Creates a webGL program
  31746. * @param pipelineContext defines the pipeline context to attach to
  31747. * @param vertexCode defines the vertex shader code to use
  31748. * @param fragmentCode defines the fragment shader code to use
  31749. * @param defines defines the string containing the defines to use to compile the shaders
  31750. * @param context defines the webGL context to use (if not set, the current one will be used)
  31751. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31752. * @returns the new webGL program
  31753. */
  31754. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31755. /**
  31756. * Creates a new pipeline context
  31757. * @returns the new pipeline
  31758. */
  31759. createPipelineContext(): WebGLPipelineContext;
  31760. private _createShaderProgram;
  31761. private _finalizePipelineContext;
  31762. /** @hidden */
  31763. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31764. /** @hidden */
  31765. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31766. /** @hidden */
  31767. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31768. /**
  31769. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31770. * @param pipelineContext defines the pipeline context to use
  31771. * @param uniformsNames defines the list of uniform names
  31772. * @returns an array of webGL uniform locations
  31773. */
  31774. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31775. /**
  31776. * Gets the lsit of active attributes for a given webGL program
  31777. * @param pipelineContext defines the pipeline context to use
  31778. * @param attributesNames defines the list of attribute names to get
  31779. * @returns an array of indices indicating the offset of each attribute
  31780. */
  31781. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31782. /**
  31783. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31784. * @param effect defines the effect to activate
  31785. */
  31786. enableEffect(effect: Nullable<Effect>): void;
  31787. /**
  31788. * Set the value of an uniform to an array of int32
  31789. * @param uniform defines the webGL uniform location where to store the value
  31790. * @param array defines the array of int32 to store
  31791. */
  31792. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31793. /**
  31794. * Set the value of an uniform to an array of int32 (stored as vec2)
  31795. * @param uniform defines the webGL uniform location where to store the value
  31796. * @param array defines the array of int32 to store
  31797. */
  31798. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31799. /**
  31800. * Set the value of an uniform to an array of int32 (stored as vec3)
  31801. * @param uniform defines the webGL uniform location where to store the value
  31802. * @param array defines the array of int32 to store
  31803. */
  31804. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31805. /**
  31806. * Set the value of an uniform to an array of int32 (stored as vec4)
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param array defines the array of int32 to store
  31809. */
  31810. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31811. /**
  31812. * Set the value of an uniform to an array of float32
  31813. * @param uniform defines the webGL uniform location where to store the value
  31814. * @param array defines the array of float32 to store
  31815. */
  31816. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31817. /**
  31818. * Set the value of an uniform to an array of float32 (stored as vec2)
  31819. * @param uniform defines the webGL uniform location where to store the value
  31820. * @param array defines the array of float32 to store
  31821. */
  31822. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31823. /**
  31824. * Set the value of an uniform to an array of float32 (stored as vec3)
  31825. * @param uniform defines the webGL uniform location where to store the value
  31826. * @param array defines the array of float32 to store
  31827. */
  31828. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31829. /**
  31830. * Set the value of an uniform to an array of float32 (stored as vec4)
  31831. * @param uniform defines the webGL uniform location where to store the value
  31832. * @param array defines the array of float32 to store
  31833. */
  31834. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31835. /**
  31836. * Set the value of an uniform to an array of number
  31837. * @param uniform defines the webGL uniform location where to store the value
  31838. * @param array defines the array of number to store
  31839. */
  31840. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31841. /**
  31842. * Set the value of an uniform to an array of number (stored as vec2)
  31843. * @param uniform defines the webGL uniform location where to store the value
  31844. * @param array defines the array of number to store
  31845. */
  31846. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31847. /**
  31848. * Set the value of an uniform to an array of number (stored as vec3)
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param array defines the array of number to store
  31851. */
  31852. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31853. /**
  31854. * Set the value of an uniform to an array of number (stored as vec4)
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param array defines the array of number to store
  31857. */
  31858. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31859. /**
  31860. * Set the value of an uniform to an array of float32 (stored as matrices)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param matrices defines the array of float32 to store
  31863. */
  31864. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31865. /**
  31866. * Set the value of an uniform to a matrix (3x3)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31869. */
  31870. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31871. /**
  31872. * Set the value of an uniform to a matrix (2x2)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31875. */
  31876. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31877. /**
  31878. * Set the value of an uniform to a number (int)
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param value defines the int number to store
  31881. */
  31882. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31883. /**
  31884. * Set the value of an uniform to a number (float)
  31885. * @param uniform defines the webGL uniform location where to store the value
  31886. * @param value defines the float number to store
  31887. */
  31888. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31889. /**
  31890. * Set the value of an uniform to a vec2
  31891. * @param uniform defines the webGL uniform location where to store the value
  31892. * @param x defines the 1st component of the value
  31893. * @param y defines the 2nd component of the value
  31894. */
  31895. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31896. /**
  31897. * Set the value of an uniform to a vec3
  31898. * @param uniform defines the webGL uniform location where to store the value
  31899. * @param x defines the 1st component of the value
  31900. * @param y defines the 2nd component of the value
  31901. * @param z defines the 3rd component of the value
  31902. */
  31903. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31904. /**
  31905. * Set the value of an uniform to a boolean
  31906. * @param uniform defines the webGL uniform location where to store the value
  31907. * @param bool defines the boolean to store
  31908. */
  31909. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31910. /**
  31911. * Set the value of an uniform to a vec4
  31912. * @param uniform defines the webGL uniform location where to store the value
  31913. * @param x defines the 1st component of the value
  31914. * @param y defines the 2nd component of the value
  31915. * @param z defines the 3rd component of the value
  31916. * @param w defines the 4th component of the value
  31917. */
  31918. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31919. /**
  31920. * Sets a Color4 on a uniform variable
  31921. * @param uniform defines the uniform location
  31922. * @param color4 defines the value to be set
  31923. */
  31924. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31925. /**
  31926. * Set various states to the webGL context
  31927. * @param culling defines backface culling state
  31928. * @param zOffset defines the value to apply to zOffset (0 by default)
  31929. * @param force defines if states must be applied even if cache is up to date
  31930. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31931. */
  31932. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31933. /**
  31934. * Set the z offset to apply to current rendering
  31935. * @param value defines the offset to apply
  31936. */
  31937. setZOffset(value: number): void;
  31938. /**
  31939. * Gets the current value of the zOffset
  31940. * @returns the current zOffset state
  31941. */
  31942. getZOffset(): number;
  31943. /**
  31944. * Enable or disable depth buffering
  31945. * @param enable defines the state to set
  31946. */
  31947. setDepthBuffer(enable: boolean): void;
  31948. /**
  31949. * Gets a boolean indicating if depth writing is enabled
  31950. * @returns the current depth writing state
  31951. */
  31952. getDepthWrite(): boolean;
  31953. /**
  31954. * Enable or disable depth writing
  31955. * @param enable defines the state to set
  31956. */
  31957. setDepthWrite(enable: boolean): void;
  31958. /**
  31959. * Enable or disable color writing
  31960. * @param enable defines the state to set
  31961. */
  31962. setColorWrite(enable: boolean): void;
  31963. /**
  31964. * Gets a boolean indicating if color writing is enabled
  31965. * @returns the current color writing state
  31966. */
  31967. getColorWrite(): boolean;
  31968. /**
  31969. * Sets alpha constants used by some alpha blending modes
  31970. * @param r defines the red component
  31971. * @param g defines the green component
  31972. * @param b defines the blue component
  31973. * @param a defines the alpha component
  31974. */
  31975. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31976. /**
  31977. * Sets the current alpha mode
  31978. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31979. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31981. */
  31982. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31983. /**
  31984. * Gets the current alpha mode
  31985. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31986. * @returns the current alpha mode
  31987. */
  31988. getAlphaMode(): number;
  31989. /**
  31990. * Clears the list of texture accessible through engine.
  31991. * This can help preventing texture load conflict due to name collision.
  31992. */
  31993. clearInternalTexturesCache(): void;
  31994. /**
  31995. * Force the entire cache to be cleared
  31996. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31997. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31998. */
  31999. wipeCaches(bruteForce?: boolean): void;
  32000. /**
  32001. * Set the compressed texture format to use, based on the formats you have, and the formats
  32002. * supported by the hardware / browser.
  32003. *
  32004. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32005. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32006. * to API arguments needed to compressed textures. This puts the burden on the container
  32007. * generator to house the arcane code for determining these for current & future formats.
  32008. *
  32009. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32010. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32011. *
  32012. * Note: The result of this call is not taken into account when a texture is base64.
  32013. *
  32014. * @param formatsAvailable defines the list of those format families you have created
  32015. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32016. *
  32017. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32018. * @returns The extension selected.
  32019. */
  32020. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32021. /** @hidden */
  32022. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32023. min: number;
  32024. mag: number;
  32025. };
  32026. /** @hidden */
  32027. _createTexture(): WebGLTexture;
  32028. /**
  32029. * Usually called from Texture.ts.
  32030. * Passed information to create a WebGLTexture
  32031. * @param urlArg defines a value which contains one of the following:
  32032. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32033. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32034. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32035. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32036. * @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)
  32037. * @param scene needed for loading to the correct scene
  32038. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32039. * @param onLoad optional callback to be called upon successful completion
  32040. * @param onError optional callback to be called upon failure
  32041. * @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
  32042. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32043. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32044. * @param forcedExtension defines the extension to use to pick the right loader
  32045. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32046. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32047. */
  32048. 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;
  32049. /**
  32050. * @hidden
  32051. * Rescales a texture
  32052. * @param source input texutre
  32053. * @param destination destination texture
  32054. * @param scene scene to use to render the resize
  32055. * @param internalFormat format to use when resizing
  32056. * @param onComplete callback to be called when resize has completed
  32057. */
  32058. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32059. private _unpackFlipYCached;
  32060. /**
  32061. * In case you are sharing the context with other applications, it might
  32062. * be interested to not cache the unpack flip y state to ensure a consistent
  32063. * value would be set.
  32064. */
  32065. enableUnpackFlipYCached: boolean;
  32066. /** @hidden */
  32067. _unpackFlipY(value: boolean): void;
  32068. /** @hidden */
  32069. _getUnpackAlignement(): number;
  32070. /**
  32071. * Creates a dynamic texture
  32072. * @param width defines the width of the texture
  32073. * @param height defines the height of the texture
  32074. * @param generateMipMaps defines if the engine should generate the mip levels
  32075. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32076. * @returns the dynamic texture inside an InternalTexture
  32077. */
  32078. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32079. /**
  32080. * Update the sampling mode of a given texture
  32081. * @param samplingMode defines the required sampling mode
  32082. * @param texture defines the texture to update
  32083. */
  32084. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32085. /**
  32086. * Update the content of a dynamic texture
  32087. * @param texture defines the texture to update
  32088. * @param canvas defines the canvas containing the source
  32089. * @param invertY defines if data must be stored with Y axis inverted
  32090. * @param premulAlpha defines if alpha is stored as premultiplied
  32091. * @param format defines the format of the data
  32092. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32093. */
  32094. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32095. /**
  32096. * Update a video texture
  32097. * @param texture defines the texture to update
  32098. * @param video defines the video element to use
  32099. * @param invertY defines if data must be stored with Y axis inverted
  32100. */
  32101. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32102. /**
  32103. * Updates a depth texture Comparison Mode and Function.
  32104. * If the comparison Function is equal to 0, the mode will be set to none.
  32105. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32106. * @param texture The texture to set the comparison function for
  32107. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32108. */
  32109. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32110. /** @hidden */
  32111. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32112. width: number;
  32113. height: number;
  32114. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32115. /**
  32116. * Creates a depth stencil texture.
  32117. * This is only available in WebGL 2 or with the depth texture extension available.
  32118. * @param size The size of face edge in the texture.
  32119. * @param options The options defining the texture.
  32120. * @returns The texture
  32121. */
  32122. createDepthStencilTexture(size: number | {
  32123. width: number;
  32124. height: number;
  32125. }, options: DepthTextureCreationOptions): InternalTexture;
  32126. /**
  32127. * Creates a depth stencil texture.
  32128. * This is only available in WebGL 2 or with the depth texture extension available.
  32129. * @param size The size of face edge in the texture.
  32130. * @param options The options defining the texture.
  32131. * @returns The texture
  32132. */
  32133. private _createDepthStencilTexture;
  32134. /**
  32135. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32136. * @param renderTarget The render target to set the frame buffer for
  32137. */
  32138. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32139. /**
  32140. * Creates a new render target texture
  32141. * @param size defines the size of the texture
  32142. * @param options defines the options used to create the texture
  32143. * @returns a new render target texture stored in an InternalTexture
  32144. */
  32145. createRenderTargetTexture(size: number | {
  32146. width: number;
  32147. height: number;
  32148. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32149. /** @hidden */
  32150. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32151. /**
  32152. * Updates the sample count of a render target texture
  32153. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32154. * @param texture defines the texture to update
  32155. * @param samples defines the sample count to set
  32156. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32157. */
  32158. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32159. /** @hidden */
  32160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32161. /** @hidden */
  32162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32163. /** @hidden */
  32164. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32165. /** @hidden */
  32166. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32167. /**
  32168. * @hidden
  32169. */
  32170. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32171. private _prepareWebGLTextureContinuation;
  32172. private _prepareWebGLTexture;
  32173. /** @hidden */
  32174. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32175. /** @hidden */
  32176. _releaseFramebufferObjects(texture: InternalTexture): void;
  32177. /** @hidden */
  32178. _releaseTexture(texture: InternalTexture): void;
  32179. private setProgram;
  32180. private _boundUniforms;
  32181. /**
  32182. * Binds an effect to the webGL context
  32183. * @param effect defines the effect to bind
  32184. */
  32185. bindSamplers(effect: Effect): void;
  32186. private _activateCurrentTexture;
  32187. /** @hidden */
  32188. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32189. /** @hidden */
  32190. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32191. /**
  32192. * Sets a texture to the webGL context from a postprocess
  32193. * @param channel defines the channel to use
  32194. * @param postProcess defines the source postprocess
  32195. */
  32196. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32197. /**
  32198. * Binds the output of the passed in post process to the texture channel specified
  32199. * @param channel The channel the texture should be bound to
  32200. * @param postProcess The post process which's output should be bound
  32201. */
  32202. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32203. /**
  32204. * Unbind all textures from the webGL context
  32205. */
  32206. unbindAllTextures(): void;
  32207. /**
  32208. * Sets a texture to the according uniform.
  32209. * @param channel The texture channel
  32210. * @param uniform The uniform to set
  32211. * @param texture The texture to apply
  32212. */
  32213. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32214. /**
  32215. * Sets a depth stencil texture from a render target to the according uniform.
  32216. * @param channel The texture channel
  32217. * @param uniform The uniform to set
  32218. * @param texture The render target texture containing the depth stencil texture to apply
  32219. */
  32220. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32221. private _bindSamplerUniformToChannel;
  32222. private _getTextureWrapMode;
  32223. private _setTexture;
  32224. /**
  32225. * Sets an array of texture to the webGL context
  32226. * @param channel defines the channel where the texture array must be set
  32227. * @param uniform defines the associated uniform location
  32228. * @param textures defines the array of textures to bind
  32229. */
  32230. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32231. /** @hidden */
  32232. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32233. private _setTextureParameterFloat;
  32234. private _setTextureParameterInteger;
  32235. /**
  32236. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32237. * @param x defines the x coordinate of the rectangle where pixels must be read
  32238. * @param y defines the y coordinate of the rectangle where pixels must be read
  32239. * @param width defines the width of the rectangle where pixels must be read
  32240. * @param height defines the height of the rectangle where pixels must be read
  32241. * @returns a Uint8Array containing RGBA colors
  32242. */
  32243. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32244. /**
  32245. * Add an externaly attached data from its key.
  32246. * This method call will fail and return false, if such key already exists.
  32247. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32248. * @param key the unique key that identifies the data
  32249. * @param data the data object to associate to the key for this Engine instance
  32250. * @return true if no such key were already present and the data was added successfully, false otherwise
  32251. */
  32252. addExternalData<T>(key: string, data: T): boolean;
  32253. /**
  32254. * Get an externaly attached data from its key
  32255. * @param key the unique key that identifies the data
  32256. * @return the associated data, if present (can be null), or undefined if not present
  32257. */
  32258. getExternalData<T>(key: string): T;
  32259. /**
  32260. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32261. * @param key the unique key that identifies the data
  32262. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32263. * @return the associated data, can be null if the factory returned null.
  32264. */
  32265. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32266. /**
  32267. * Remove an externaly attached data from the Engine instance
  32268. * @param key the unique key that identifies the data
  32269. * @return true if the data was successfully removed, false if it doesn't exist
  32270. */
  32271. removeExternalData(key: string): boolean;
  32272. /**
  32273. * Unbind all vertex attributes from the webGL context
  32274. */
  32275. unbindAllAttributes(): void;
  32276. /**
  32277. * 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
  32278. */
  32279. releaseEffects(): void;
  32280. /**
  32281. * Dispose and release all associated resources
  32282. */
  32283. dispose(): void;
  32284. /**
  32285. * Display the loading screen
  32286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32287. */
  32288. displayLoadingUI(): void;
  32289. /**
  32290. * Hide the loading screen
  32291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32292. */
  32293. hideLoadingUI(): void;
  32294. /**
  32295. * Gets the current loading screen object
  32296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32297. */
  32298. /**
  32299. * Sets the current loading screen object
  32300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32301. */
  32302. loadingScreen: ILoadingScreen;
  32303. /**
  32304. * Sets the current loading screen text
  32305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32306. */
  32307. loadingUIText: string;
  32308. /**
  32309. * Sets the current loading screen background color
  32310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32311. */
  32312. loadingUIBackgroundColor: string;
  32313. /**
  32314. * Attach a new callback raised when context lost event is fired
  32315. * @param callback defines the callback to call
  32316. */
  32317. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32318. /**
  32319. * Attach a new callback raised when context restored event is fired
  32320. * @param callback defines the callback to call
  32321. */
  32322. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32323. /**
  32324. * Gets the source code of the vertex shader associated with a specific webGL program
  32325. * @param program defines the program to use
  32326. * @returns a string containing the source code of the vertex shader associated with the program
  32327. */
  32328. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32329. /**
  32330. * Gets the source code of the fragment shader associated with a specific webGL program
  32331. * @param program defines the program to use
  32332. * @returns a string containing the source code of the fragment shader associated with the program
  32333. */
  32334. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32335. /**
  32336. * Get the current error code of the webGL context
  32337. * @returns the error code
  32338. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32339. */
  32340. getError(): number;
  32341. /**
  32342. * Gets the current framerate
  32343. * @returns a number representing the framerate
  32344. */
  32345. getFps(): number;
  32346. /**
  32347. * Gets the time spent between current and previous frame
  32348. * @returns a number representing the delta time in ms
  32349. */
  32350. getDeltaTime(): number;
  32351. private _measureFps;
  32352. /** @hidden */
  32353. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32354. private _canRenderToFloatFramebuffer;
  32355. private _canRenderToHalfFloatFramebuffer;
  32356. private _canRenderToFramebuffer;
  32357. /** @hidden */
  32358. _getWebGLTextureType(type: number): number;
  32359. /** @hidden */
  32360. _getInternalFormat(format: number): number;
  32361. /** @hidden */
  32362. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32363. /** @hidden */
  32364. _getRGBAMultiSampleBufferFormat(type: number): number;
  32365. /** @hidden */
  32366. _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;
  32367. /** @hidden */
  32368. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32369. /**
  32370. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32371. * @returns true if the engine can be created
  32372. * @ignorenaming
  32373. */
  32374. static isSupported(): boolean;
  32375. /**
  32376. * Find the next highest power of two.
  32377. * @param x Number to start search from.
  32378. * @return Next highest power of two.
  32379. */
  32380. static CeilingPOT(x: number): number;
  32381. /**
  32382. * Find the next lowest power of two.
  32383. * @param x Number to start search from.
  32384. * @return Next lowest power of two.
  32385. */
  32386. static FloorPOT(x: number): number;
  32387. /**
  32388. * Find the nearest power of two.
  32389. * @param x Number to start search from.
  32390. * @return Next nearest power of two.
  32391. */
  32392. static NearestPOT(x: number): number;
  32393. /**
  32394. * Get the closest exponent of two
  32395. * @param value defines the value to approximate
  32396. * @param max defines the maximum value to return
  32397. * @param mode defines how to define the closest value
  32398. * @returns closest exponent of two of the given value
  32399. */
  32400. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32401. /**
  32402. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32403. * @param func - the function to be called
  32404. * @param requester - the object that will request the next frame. Falls back to window.
  32405. * @returns frame number
  32406. */
  32407. static QueueNewFrame(func: () => void, requester?: any): number;
  32408. /**
  32409. * Ask the browser to promote the current element to pointerlock mode
  32410. * @param element defines the DOM element to promote
  32411. */
  32412. static _RequestPointerlock(element: HTMLElement): void;
  32413. /**
  32414. * Asks the browser to exit pointerlock mode
  32415. */
  32416. static _ExitPointerlock(): void;
  32417. /**
  32418. * Ask the browser to promote the current element to fullscreen rendering mode
  32419. * @param element defines the DOM element to promote
  32420. */
  32421. static _RequestFullscreen(element: HTMLElement): void;
  32422. /**
  32423. * Asks the browser to exit fullscreen mode
  32424. */
  32425. static _ExitFullscreen(): void;
  32426. }
  32427. }
  32428. declare module "babylonjs/Engines/engineStore" {
  32429. import { Nullable } from "babylonjs/types";
  32430. import { Engine } from "babylonjs/Engines/engine";
  32431. import { Scene } from "babylonjs/scene";
  32432. /**
  32433. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32434. * during the life time of the application.
  32435. */
  32436. export class EngineStore {
  32437. /** Gets the list of created engines */
  32438. static Instances: import("babylonjs/Engines/engine").Engine[];
  32439. /** @hidden */
  32440. static _LastCreatedScene: Nullable<Scene>;
  32441. /**
  32442. * Gets the latest created engine
  32443. */
  32444. static readonly LastCreatedEngine: Nullable<Engine>;
  32445. /**
  32446. * Gets the latest created scene
  32447. */
  32448. static readonly LastCreatedScene: Nullable<Scene>;
  32449. /**
  32450. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32451. * @ignorenaming
  32452. */
  32453. static UseFallbackTexture: boolean;
  32454. /**
  32455. * Texture content used if a texture cannot loaded
  32456. * @ignorenaming
  32457. */
  32458. static FallbackTexture: string;
  32459. }
  32460. }
  32461. declare module "babylonjs/Misc/promise" {
  32462. /**
  32463. * Helper class that provides a small promise polyfill
  32464. */
  32465. export class PromisePolyfill {
  32466. /**
  32467. * Static function used to check if the polyfill is required
  32468. * If this is the case then the function will inject the polyfill to window.Promise
  32469. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32470. */
  32471. static Apply(force?: boolean): void;
  32472. }
  32473. }
  32474. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32475. /**
  32476. * Interface for screenshot methods with describe argument called `size` as object with options
  32477. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32478. */
  32479. export interface IScreenshotSize {
  32480. /**
  32481. * number in pixels for canvas height
  32482. */
  32483. height?: number;
  32484. /**
  32485. * multiplier allowing render at a higher or lower resolution
  32486. * If value is defined then height and width will be ignored and taken from camera
  32487. */
  32488. precision?: number;
  32489. /**
  32490. * number in pixels for canvas width
  32491. */
  32492. width?: number;
  32493. }
  32494. }
  32495. declare module "babylonjs/Misc/tools" {
  32496. import { Nullable, float } from "babylonjs/types";
  32497. import { DomManagement } from "babylonjs/Misc/domManagement";
  32498. import { WebRequest } from "babylonjs/Misc/webRequest";
  32499. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32500. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32501. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32502. import { Camera } from "babylonjs/Cameras/camera";
  32503. import { Engine } from "babylonjs/Engines/engine";
  32504. interface IColor4Like {
  32505. r: float;
  32506. g: float;
  32507. b: float;
  32508. a: float;
  32509. }
  32510. /**
  32511. * Class containing a set of static utilities functions
  32512. */
  32513. export class Tools {
  32514. /**
  32515. * Gets or sets the base URL to use to load assets
  32516. */
  32517. static BaseUrl: string;
  32518. /**
  32519. * Enable/Disable Custom HTTP Request Headers globally.
  32520. * default = false
  32521. * @see CustomRequestHeaders
  32522. */
  32523. static UseCustomRequestHeaders: boolean;
  32524. /**
  32525. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32526. * i.e. when loading files, where the server/service expects an Authorization header
  32527. */
  32528. static CustomRequestHeaders: {
  32529. [key: string]: string;
  32530. };
  32531. /**
  32532. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32533. */
  32534. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32535. /**
  32536. * Default behaviour for cors in the application.
  32537. * It can be a string if the expected behavior is identical in the entire app.
  32538. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32539. */
  32540. static CorsBehavior: string | ((url: string | string[]) => string);
  32541. /**
  32542. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32543. * @ignorenaming
  32544. */
  32545. static UseFallbackTexture: boolean;
  32546. /**
  32547. * Use this object to register external classes like custom textures or material
  32548. * to allow the laoders to instantiate them
  32549. */
  32550. static RegisteredExternalClasses: {
  32551. [key: string]: Object;
  32552. };
  32553. /**
  32554. * Texture content used if a texture cannot loaded
  32555. * @ignorenaming
  32556. */
  32557. static fallbackTexture: string;
  32558. /**
  32559. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32560. * @param u defines the coordinate on X axis
  32561. * @param v defines the coordinate on Y axis
  32562. * @param width defines the width of the source data
  32563. * @param height defines the height of the source data
  32564. * @param pixels defines the source byte array
  32565. * @param color defines the output color
  32566. */
  32567. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32568. /**
  32569. * Interpolates between a and b via alpha
  32570. * @param a The lower value (returned when alpha = 0)
  32571. * @param b The upper value (returned when alpha = 1)
  32572. * @param alpha The interpolation-factor
  32573. * @return The mixed value
  32574. */
  32575. static Mix(a: number, b: number, alpha: number): number;
  32576. /**
  32577. * Tries to instantiate a new object from a given class name
  32578. * @param className defines the class name to instantiate
  32579. * @returns the new object or null if the system was not able to do the instantiation
  32580. */
  32581. static Instantiate(className: string): any;
  32582. /**
  32583. * Provides a slice function that will work even on IE
  32584. * @param data defines the array to slice
  32585. * @param start defines the start of the data (optional)
  32586. * @param end defines the end of the data (optional)
  32587. * @returns the new sliced array
  32588. */
  32589. static Slice<T>(data: T, start?: number, end?: number): T;
  32590. /**
  32591. * Polyfill for setImmediate
  32592. * @param action defines the action to execute after the current execution block
  32593. */
  32594. static SetImmediate(action: () => void): void;
  32595. /**
  32596. * Function indicating if a number is an exponent of 2
  32597. * @param value defines the value to test
  32598. * @returns true if the value is an exponent of 2
  32599. */
  32600. static IsExponentOfTwo(value: number): boolean;
  32601. private static _tmpFloatArray;
  32602. /**
  32603. * Returns the nearest 32-bit single precision float representation of a Number
  32604. * @param value A Number. If the parameter is of a different type, it will get converted
  32605. * to a number or to NaN if it cannot be converted
  32606. * @returns number
  32607. */
  32608. static FloatRound(value: number): number;
  32609. /**
  32610. * Extracts the filename from a path
  32611. * @param path defines the path to use
  32612. * @returns the filename
  32613. */
  32614. static GetFilename(path: string): string;
  32615. /**
  32616. * Extracts the "folder" part of a path (everything before the filename).
  32617. * @param uri The URI to extract the info from
  32618. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32619. * @returns The "folder" part of the path
  32620. */
  32621. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32622. /**
  32623. * Extracts text content from a DOM element hierarchy
  32624. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32625. */
  32626. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32627. /**
  32628. * Convert an angle in radians to degrees
  32629. * @param angle defines the angle to convert
  32630. * @returns the angle in degrees
  32631. */
  32632. static ToDegrees(angle: number): number;
  32633. /**
  32634. * Convert an angle in degrees to radians
  32635. * @param angle defines the angle to convert
  32636. * @returns the angle in radians
  32637. */
  32638. static ToRadians(angle: number): number;
  32639. /**
  32640. * Encode a buffer to a base64 string
  32641. * @param buffer defines the buffer to encode
  32642. * @returns the encoded string
  32643. */
  32644. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32645. /**
  32646. * Returns an array if obj is not an array
  32647. * @param obj defines the object to evaluate as an array
  32648. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32649. * @returns either obj directly if obj is an array or a new array containing obj
  32650. */
  32651. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32652. /**
  32653. * Gets the pointer prefix to use
  32654. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32655. */
  32656. static GetPointerPrefix(): string;
  32657. /**
  32658. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32659. * @param url define the url we are trying
  32660. * @param element define the dom element where to configure the cors policy
  32661. */
  32662. static SetCorsBehavior(url: string | string[], element: {
  32663. crossOrigin: string | null;
  32664. }): void;
  32665. /**
  32666. * Removes unwanted characters from an url
  32667. * @param url defines the url to clean
  32668. * @returns the cleaned url
  32669. */
  32670. static CleanUrl(url: string): string;
  32671. /**
  32672. * Gets or sets a function used to pre-process url before using them to load assets
  32673. */
  32674. static PreprocessUrl: (url: string) => string;
  32675. /**
  32676. * Loads an image as an HTMLImageElement.
  32677. * @param input url string, ArrayBuffer, or Blob to load
  32678. * @param onLoad callback called when the image successfully loads
  32679. * @param onError callback called when the image fails to load
  32680. * @param offlineProvider offline provider for caching
  32681. * @returns the HTMLImageElement of the loaded image
  32682. */
  32683. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32684. /**
  32685. * Loads a file
  32686. * @param url url string, ArrayBuffer, or Blob to load
  32687. * @param onSuccess callback called when the file successfully loads
  32688. * @param onProgress callback called while file is loading (if the server supports this mode)
  32689. * @param offlineProvider defines the offline provider for caching
  32690. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32691. * @param onError callback called when the file fails to load
  32692. * @returns a file request object
  32693. */
  32694. 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;
  32695. /**
  32696. * Loads a file from a url
  32697. * @param url the file url to load
  32698. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32699. */
  32700. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32701. /**
  32702. * Load a script (identified by an url). When the url returns, the
  32703. * content of this file is added into a new script element, attached to the DOM (body element)
  32704. * @param scriptUrl defines the url of the script to laod
  32705. * @param onSuccess defines the callback called when the script is loaded
  32706. * @param onError defines the callback to call if an error occurs
  32707. * @param scriptId defines the id of the script element
  32708. */
  32709. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32710. /**
  32711. * Load an asynchronous script (identified by an url). When the url returns, the
  32712. * content of this file is added into a new script element, attached to the DOM (body element)
  32713. * @param scriptUrl defines the url of the script to laod
  32714. * @param scriptId defines the id of the script element
  32715. * @returns a promise request object
  32716. */
  32717. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32718. /**
  32719. * Loads a file from a blob
  32720. * @param fileToLoad defines the blob to use
  32721. * @param callback defines the callback to call when data is loaded
  32722. * @param progressCallback defines the callback to call during loading process
  32723. * @returns a file request object
  32724. */
  32725. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32726. /**
  32727. * Loads a file
  32728. * @param fileToLoad defines the file to load
  32729. * @param callback defines the callback to call when data is loaded
  32730. * @param progressCallBack defines the callback to call during loading process
  32731. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32732. * @returns a file request object
  32733. */
  32734. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32735. /**
  32736. * Creates a data url from a given string content
  32737. * @param content defines the content to convert
  32738. * @returns the new data url link
  32739. */
  32740. static FileAsURL(content: string): string;
  32741. /**
  32742. * Format the given number to a specific decimal format
  32743. * @param value defines the number to format
  32744. * @param decimals defines the number of decimals to use
  32745. * @returns the formatted string
  32746. */
  32747. static Format(value: number, decimals?: number): string;
  32748. /**
  32749. * Tries to copy an object by duplicating every property
  32750. * @param source defines the source object
  32751. * @param destination defines the target object
  32752. * @param doNotCopyList defines a list of properties to avoid
  32753. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32754. */
  32755. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32756. /**
  32757. * Gets a boolean indicating if the given object has no own property
  32758. * @param obj defines the object to test
  32759. * @returns true if object has no own property
  32760. */
  32761. static IsEmpty(obj: any): boolean;
  32762. /**
  32763. * Function used to register events at window level
  32764. * @param windowElement defines the Window object to use
  32765. * @param events defines the events to register
  32766. */
  32767. static RegisterTopRootEvents(windowElement: Window, events: {
  32768. name: string;
  32769. handler: Nullable<(e: FocusEvent) => any>;
  32770. }[]): void;
  32771. /**
  32772. * Function used to unregister events from window level
  32773. * @param windowElement defines the Window object to use
  32774. * @param events defines the events to unregister
  32775. */
  32776. static UnregisterTopRootEvents(windowElement: Window, events: {
  32777. name: string;
  32778. handler: Nullable<(e: FocusEvent) => any>;
  32779. }[]): void;
  32780. /**
  32781. * @ignore
  32782. */
  32783. static _ScreenshotCanvas: HTMLCanvasElement;
  32784. /**
  32785. * Dumps the current bound framebuffer
  32786. * @param width defines the rendering width
  32787. * @param height defines the rendering height
  32788. * @param engine defines the hosting engine
  32789. * @param successCallback defines the callback triggered once the data are available
  32790. * @param mimeType defines the mime type of the result
  32791. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32792. */
  32793. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32794. /**
  32795. * Converts the canvas data to blob.
  32796. * This acts as a polyfill for browsers not supporting the to blob function.
  32797. * @param canvas Defines the canvas to extract the data from
  32798. * @param successCallback Defines the callback triggered once the data are available
  32799. * @param mimeType Defines the mime type of the result
  32800. */
  32801. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32802. /**
  32803. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32804. * @param successCallback defines the callback triggered once the data are available
  32805. * @param mimeType defines the mime type of the result
  32806. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32807. */
  32808. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32809. /**
  32810. * Downloads a blob in the browser
  32811. * @param blob defines the blob to download
  32812. * @param fileName defines the name of the downloaded file
  32813. */
  32814. static Download(blob: Blob, fileName: string): void;
  32815. /**
  32816. * Captures a screenshot of the current rendering
  32817. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32818. * @param engine defines the rendering engine
  32819. * @param camera defines the source camera
  32820. * @param size This parameter can be set to a single number or to an object with the
  32821. * following (optional) properties: precision, width, height. If a single number is passed,
  32822. * it will be used for both width and height. If an object is passed, the screenshot size
  32823. * will be derived from the parameters. The precision property is a multiplier allowing
  32824. * rendering at a higher or lower resolution
  32825. * @param successCallback defines the callback receives a single parameter which contains the
  32826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32827. * src parameter of an <img> to display it
  32828. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32829. * Check your browser for supported MIME types
  32830. */
  32831. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32832. /**
  32833. * Captures a screenshot of the current rendering
  32834. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32835. * @param engine defines the rendering engine
  32836. * @param camera defines the source camera
  32837. * @param size This parameter can be set to a single number or to an object with the
  32838. * following (optional) properties: precision, width, height. If a single number is passed,
  32839. * it will be used for both width and height. If an object is passed, the screenshot size
  32840. * will be derived from the parameters. The precision property is a multiplier allowing
  32841. * rendering at a higher or lower resolution
  32842. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32843. * Check your browser for supported MIME types
  32844. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32845. * to the src parameter of an <img> to display it
  32846. */
  32847. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32848. /**
  32849. * Generates an image screenshot from the specified camera.
  32850. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32851. * @param engine The engine to use for rendering
  32852. * @param camera The camera to use for rendering
  32853. * @param size This parameter can be set to a single number or to an object with the
  32854. * following (optional) properties: precision, width, height. If a single number is passed,
  32855. * it will be used for both width and height. If an object is passed, the screenshot size
  32856. * will be derived from the parameters. The precision property is a multiplier allowing
  32857. * rendering at a higher or lower resolution
  32858. * @param successCallback The callback receives a single parameter which contains the
  32859. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32860. * src parameter of an <img> to display it
  32861. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32862. * Check your browser for supported MIME types
  32863. * @param samples Texture samples (default: 1)
  32864. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32865. * @param fileName A name for for the downloaded file.
  32866. */
  32867. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32868. /**
  32869. * Generates an image screenshot from the specified camera.
  32870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32871. * @param engine The engine to use for rendering
  32872. * @param camera The camera to use for rendering
  32873. * @param size This parameter can be set to a single number or to an object with the
  32874. * following (optional) properties: precision, width, height. If a single number is passed,
  32875. * it will be used for both width and height. If an object is passed, the screenshot size
  32876. * will be derived from the parameters. The precision property is a multiplier allowing
  32877. * rendering at a higher or lower resolution
  32878. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32879. * Check your browser for supported MIME types
  32880. * @param samples Texture samples (default: 1)
  32881. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32882. * @param fileName A name for for the downloaded file.
  32883. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32884. * to the src parameter of an <img> to display it
  32885. */
  32886. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32887. /**
  32888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32889. * Be aware Math.random() could cause collisions, but:
  32890. * "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"
  32891. * @returns a pseudo random id
  32892. */
  32893. static RandomId(): string;
  32894. /**
  32895. * Test if the given uri is a base64 string
  32896. * @param uri The uri to test
  32897. * @return True if the uri is a base64 string or false otherwise
  32898. */
  32899. static IsBase64(uri: string): boolean;
  32900. /**
  32901. * Decode the given base64 uri.
  32902. * @param uri The uri to decode
  32903. * @return The decoded base64 data.
  32904. */
  32905. static DecodeBase64(uri: string): ArrayBuffer;
  32906. /**
  32907. * Gets the absolute url.
  32908. * @param url the input url
  32909. * @return the absolute url
  32910. */
  32911. static GetAbsoluteUrl(url: string): string;
  32912. /**
  32913. * No log
  32914. */
  32915. static readonly NoneLogLevel: number;
  32916. /**
  32917. * Only message logs
  32918. */
  32919. static readonly MessageLogLevel: number;
  32920. /**
  32921. * Only warning logs
  32922. */
  32923. static readonly WarningLogLevel: number;
  32924. /**
  32925. * Only error logs
  32926. */
  32927. static readonly ErrorLogLevel: number;
  32928. /**
  32929. * All logs
  32930. */
  32931. static readonly AllLogLevel: number;
  32932. /**
  32933. * Gets a value indicating the number of loading errors
  32934. * @ignorenaming
  32935. */
  32936. static readonly errorsCount: number;
  32937. /**
  32938. * Callback called when a new log is added
  32939. */
  32940. static OnNewCacheEntry: (entry: string) => void;
  32941. /**
  32942. * Log a message to the console
  32943. * @param message defines the message to log
  32944. */
  32945. static Log(message: string): void;
  32946. /**
  32947. * Write a warning message to the console
  32948. * @param message defines the message to log
  32949. */
  32950. static Warn(message: string): void;
  32951. /**
  32952. * Write an error message to the console
  32953. * @param message defines the message to log
  32954. */
  32955. static Error(message: string): void;
  32956. /**
  32957. * Gets current log cache (list of logs)
  32958. */
  32959. static readonly LogCache: string;
  32960. /**
  32961. * Clears the log cache
  32962. */
  32963. static ClearLogCache(): void;
  32964. /**
  32965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32966. */
  32967. static LogLevels: number;
  32968. /**
  32969. * Checks if the window object exists
  32970. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32971. */
  32972. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32973. /**
  32974. * No performance log
  32975. */
  32976. static readonly PerformanceNoneLogLevel: number;
  32977. /**
  32978. * Use user marks to log performance
  32979. */
  32980. static readonly PerformanceUserMarkLogLevel: number;
  32981. /**
  32982. * Log performance to the console
  32983. */
  32984. static readonly PerformanceConsoleLogLevel: number;
  32985. private static _performance;
  32986. /**
  32987. * Sets the current performance log level
  32988. */
  32989. static PerformanceLogLevel: number;
  32990. private static _StartPerformanceCounterDisabled;
  32991. private static _EndPerformanceCounterDisabled;
  32992. private static _StartUserMark;
  32993. private static _EndUserMark;
  32994. private static _StartPerformanceConsole;
  32995. private static _EndPerformanceConsole;
  32996. /**
  32997. * Starts a performance counter
  32998. */
  32999. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33000. /**
  33001. * Ends a specific performance coutner
  33002. */
  33003. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33004. /**
  33005. * Gets either window.performance.now() if supported or Date.now() else
  33006. */
  33007. static readonly Now: number;
  33008. /**
  33009. * This method will return the name of the class used to create the instance of the given object.
  33010. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33011. * @param object the object to get the class name from
  33012. * @param isType defines if the object is actually a type
  33013. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33014. */
  33015. static GetClassName(object: any, isType?: boolean): string;
  33016. /**
  33017. * Gets the first element of an array satisfying a given predicate
  33018. * @param array defines the array to browse
  33019. * @param predicate defines the predicate to use
  33020. * @returns null if not found or the element
  33021. */
  33022. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33023. /**
  33024. * This method will return the name of the full name of the class, including its owning module (if any).
  33025. * 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).
  33026. * @param object the object to get the class name from
  33027. * @param isType defines if the object is actually a type
  33028. * @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.
  33029. * @ignorenaming
  33030. */
  33031. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33032. /**
  33033. * Returns a promise that resolves after the given amount of time.
  33034. * @param delay Number of milliseconds to delay
  33035. * @returns Promise that resolves after the given amount of time
  33036. */
  33037. static DelayAsync(delay: number): Promise<void>;
  33038. }
  33039. /**
  33040. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33041. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33042. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33043. * @param name The name of the class, case should be preserved
  33044. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33045. */
  33046. export function className(name: string, module?: string): (target: Object) => void;
  33047. /**
  33048. * An implementation of a loop for asynchronous functions.
  33049. */
  33050. export class AsyncLoop {
  33051. /**
  33052. * Defines the number of iterations for the loop
  33053. */
  33054. iterations: number;
  33055. /**
  33056. * Defines the current index of the loop.
  33057. */
  33058. index: number;
  33059. private _done;
  33060. private _fn;
  33061. private _successCallback;
  33062. /**
  33063. * Constructor.
  33064. * @param iterations the number of iterations.
  33065. * @param func the function to run each iteration
  33066. * @param successCallback the callback that will be called upon succesful execution
  33067. * @param offset starting offset.
  33068. */
  33069. constructor(
  33070. /**
  33071. * Defines the number of iterations for the loop
  33072. */
  33073. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33074. /**
  33075. * Execute the next iteration. Must be called after the last iteration was finished.
  33076. */
  33077. executeNext(): void;
  33078. /**
  33079. * Break the loop and run the success callback.
  33080. */
  33081. breakLoop(): void;
  33082. /**
  33083. * Create and run an async loop.
  33084. * @param iterations the number of iterations.
  33085. * @param fn the function to run each iteration
  33086. * @param successCallback the callback that will be called upon succesful execution
  33087. * @param offset starting offset.
  33088. * @returns the created async loop object
  33089. */
  33090. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33091. /**
  33092. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33093. * @param iterations total number of iterations
  33094. * @param syncedIterations number of synchronous iterations in each async iteration.
  33095. * @param fn the function to call each iteration.
  33096. * @param callback a success call back that will be called when iterating stops.
  33097. * @param breakFunction a break condition (optional)
  33098. * @param timeout timeout settings for the setTimeout function. default - 0.
  33099. * @returns the created async loop object
  33100. */
  33101. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33102. }
  33103. }
  33104. declare module "babylonjs/Collisions/collisionCoordinator" {
  33105. import { Nullable } from "babylonjs/types";
  33106. import { Scene } from "babylonjs/scene";
  33107. import { Vector3 } from "babylonjs/Maths/math.vector";
  33108. import { Collider } from "babylonjs/Collisions/collider";
  33109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33110. /** @hidden */
  33111. export interface ICollisionCoordinator {
  33112. createCollider(): Collider;
  33113. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33114. init(scene: Scene): void;
  33115. }
  33116. /** @hidden */
  33117. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33118. private _scene;
  33119. private _scaledPosition;
  33120. private _scaledVelocity;
  33121. private _finalPosition;
  33122. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33123. createCollider(): Collider;
  33124. init(scene: Scene): void;
  33125. private _collideWithWorld;
  33126. }
  33127. }
  33128. declare module "babylonjs/Inputs/scene.inputManager" {
  33129. import { Nullable } from "babylonjs/types";
  33130. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33131. import { Vector2 } from "babylonjs/Maths/math.vector";
  33132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33133. import { Scene } from "babylonjs/scene";
  33134. /**
  33135. * Class used to manage all inputs for the scene.
  33136. */
  33137. export class InputManager {
  33138. /** The distance in pixel that you have to move to prevent some events */
  33139. static DragMovementThreshold: number;
  33140. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33141. static LongPressDelay: number;
  33142. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33143. static DoubleClickDelay: number;
  33144. /** If you need to check double click without raising a single click at first click, enable this flag */
  33145. static ExclusiveDoubleClickMode: boolean;
  33146. private _wheelEventName;
  33147. private _onPointerMove;
  33148. private _onPointerDown;
  33149. private _onPointerUp;
  33150. private _initClickEvent;
  33151. private _initActionManager;
  33152. private _delayedSimpleClick;
  33153. private _delayedSimpleClickTimeout;
  33154. private _previousDelayedSimpleClickTimeout;
  33155. private _meshPickProceed;
  33156. private _previousButtonPressed;
  33157. private _currentPickResult;
  33158. private _previousPickResult;
  33159. private _totalPointersPressed;
  33160. private _doubleClickOccured;
  33161. private _pointerOverMesh;
  33162. private _pickedDownMesh;
  33163. private _pickedUpMesh;
  33164. private _pointerX;
  33165. private _pointerY;
  33166. private _unTranslatedPointerX;
  33167. private _unTranslatedPointerY;
  33168. private _startingPointerPosition;
  33169. private _previousStartingPointerPosition;
  33170. private _startingPointerTime;
  33171. private _previousStartingPointerTime;
  33172. private _pointerCaptures;
  33173. private _onKeyDown;
  33174. private _onKeyUp;
  33175. private _onCanvasFocusObserver;
  33176. private _onCanvasBlurObserver;
  33177. private _scene;
  33178. /**
  33179. * Creates a new InputManager
  33180. * @param scene defines the hosting scene
  33181. */
  33182. constructor(scene: Scene);
  33183. /**
  33184. * Gets the mesh that is currently under the pointer
  33185. */
  33186. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33187. /**
  33188. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33189. */
  33190. readonly unTranslatedPointer: Vector2;
  33191. /**
  33192. * Gets or sets the current on-screen X position of the pointer
  33193. */
  33194. pointerX: number;
  33195. /**
  33196. * Gets or sets the current on-screen Y position of the pointer
  33197. */
  33198. pointerY: number;
  33199. private _updatePointerPosition;
  33200. private _processPointerMove;
  33201. private _setRayOnPointerInfo;
  33202. private _checkPrePointerObservable;
  33203. /**
  33204. * Use this method to simulate a pointer move on a mesh
  33205. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33206. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33207. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33208. */
  33209. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33210. /**
  33211. * Use this method to simulate a pointer down on a mesh
  33212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33215. */
  33216. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33217. private _processPointerDown;
  33218. /** @hidden */
  33219. _isPointerSwiping(): boolean;
  33220. /**
  33221. * Use this method to simulate a pointer up on a mesh
  33222. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33223. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33224. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33225. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33226. */
  33227. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33228. private _processPointerUp;
  33229. /**
  33230. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33231. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33232. * @returns true if the pointer was captured
  33233. */
  33234. isPointerCaptured(pointerId?: number): boolean;
  33235. /**
  33236. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33237. * @param attachUp defines if you want to attach events to pointerup
  33238. * @param attachDown defines if you want to attach events to pointerdown
  33239. * @param attachMove defines if you want to attach events to pointermove
  33240. */
  33241. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33242. /**
  33243. * Detaches all event handlers
  33244. */
  33245. detachControl(): void;
  33246. /**
  33247. * Force the value of meshUnderPointer
  33248. * @param mesh defines the mesh to use
  33249. */
  33250. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33251. /**
  33252. * Gets the mesh under the pointer
  33253. * @returns a Mesh or null if no mesh is under the pointer
  33254. */
  33255. getPointerOverMesh(): Nullable<AbstractMesh>;
  33256. }
  33257. }
  33258. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33259. /**
  33260. * Helper class used to generate session unique ID
  33261. */
  33262. export class UniqueIdGenerator {
  33263. private static _UniqueIdCounter;
  33264. /**
  33265. * Gets an unique (relatively to the current scene) Id
  33266. */
  33267. static readonly UniqueId: number;
  33268. }
  33269. }
  33270. declare module "babylonjs/Animations/animationGroup" {
  33271. import { Animatable } from "babylonjs/Animations/animatable";
  33272. import { Animation } from "babylonjs/Animations/animation";
  33273. import { Scene, IDisposable } from "babylonjs/scene";
  33274. import { Observable } from "babylonjs/Misc/observable";
  33275. import { Nullable } from "babylonjs/types";
  33276. import "babylonjs/Animations/animatable";
  33277. /**
  33278. * This class defines the direct association between an animation and a target
  33279. */
  33280. export class TargetedAnimation {
  33281. /**
  33282. * Animation to perform
  33283. */
  33284. animation: Animation;
  33285. /**
  33286. * Target to animate
  33287. */
  33288. target: any;
  33289. /**
  33290. * Serialize the object
  33291. * @returns the JSON object representing the current entity
  33292. */
  33293. serialize(): any;
  33294. }
  33295. /**
  33296. * Use this class to create coordinated animations on multiple targets
  33297. */
  33298. export class AnimationGroup implements IDisposable {
  33299. /** The name of the animation group */
  33300. name: string;
  33301. private _scene;
  33302. private _targetedAnimations;
  33303. private _animatables;
  33304. private _from;
  33305. private _to;
  33306. private _isStarted;
  33307. private _isPaused;
  33308. private _speedRatio;
  33309. private _loopAnimation;
  33310. /**
  33311. * Gets or sets the unique id of the node
  33312. */
  33313. uniqueId: number;
  33314. /**
  33315. * This observable will notify when one animation have ended
  33316. */
  33317. onAnimationEndObservable: Observable<TargetedAnimation>;
  33318. /**
  33319. * Observer raised when one animation loops
  33320. */
  33321. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33322. /**
  33323. * This observable will notify when all animations have ended.
  33324. */
  33325. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33326. /**
  33327. * This observable will notify when all animations have paused.
  33328. */
  33329. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33330. /**
  33331. * This observable will notify when all animations are playing.
  33332. */
  33333. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33334. /**
  33335. * Gets the first frame
  33336. */
  33337. readonly from: number;
  33338. /**
  33339. * Gets the last frame
  33340. */
  33341. readonly to: number;
  33342. /**
  33343. * Define if the animations are started
  33344. */
  33345. readonly isStarted: boolean;
  33346. /**
  33347. * Gets a value indicating that the current group is playing
  33348. */
  33349. readonly isPlaying: boolean;
  33350. /**
  33351. * Gets or sets the speed ratio to use for all animations
  33352. */
  33353. /**
  33354. * Gets or sets the speed ratio to use for all animations
  33355. */
  33356. speedRatio: number;
  33357. /**
  33358. * Gets or sets if all animations should loop or not
  33359. */
  33360. loopAnimation: boolean;
  33361. /**
  33362. * Gets the targeted animations for this animation group
  33363. */
  33364. readonly targetedAnimations: Array<TargetedAnimation>;
  33365. /**
  33366. * returning the list of animatables controlled by this animation group.
  33367. */
  33368. readonly animatables: Array<Animatable>;
  33369. /**
  33370. * Instantiates a new Animation Group.
  33371. * This helps managing several animations at once.
  33372. * @see http://doc.babylonjs.com/how_to/group
  33373. * @param name Defines the name of the group
  33374. * @param scene Defines the scene the group belongs to
  33375. */
  33376. constructor(
  33377. /** The name of the animation group */
  33378. name: string, scene?: Nullable<Scene>);
  33379. /**
  33380. * Add an animation (with its target) in the group
  33381. * @param animation defines the animation we want to add
  33382. * @param target defines the target of the animation
  33383. * @returns the TargetedAnimation object
  33384. */
  33385. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33386. /**
  33387. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33388. * It can add constant keys at begin or end
  33389. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33390. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33391. * @returns the animation group
  33392. */
  33393. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33394. /**
  33395. * Start all animations on given targets
  33396. * @param loop defines if animations must loop
  33397. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33398. * @param from defines the from key (optional)
  33399. * @param to defines the to key (optional)
  33400. * @returns the current animation group
  33401. */
  33402. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33403. /**
  33404. * Pause all animations
  33405. * @returns the animation group
  33406. */
  33407. pause(): AnimationGroup;
  33408. /**
  33409. * Play all animations to initial state
  33410. * This function will start() the animations if they were not started or will restart() them if they were paused
  33411. * @param loop defines if animations must loop
  33412. * @returns the animation group
  33413. */
  33414. play(loop?: boolean): AnimationGroup;
  33415. /**
  33416. * Reset all animations to initial state
  33417. * @returns the animation group
  33418. */
  33419. reset(): AnimationGroup;
  33420. /**
  33421. * Restart animations from key 0
  33422. * @returns the animation group
  33423. */
  33424. restart(): AnimationGroup;
  33425. /**
  33426. * Stop all animations
  33427. * @returns the animation group
  33428. */
  33429. stop(): AnimationGroup;
  33430. /**
  33431. * Set animation weight for all animatables
  33432. * @param weight defines the weight to use
  33433. * @return the animationGroup
  33434. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33435. */
  33436. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33437. /**
  33438. * Synchronize and normalize all animatables with a source animatable
  33439. * @param root defines the root animatable to synchronize with
  33440. * @return the animationGroup
  33441. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33442. */
  33443. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33444. /**
  33445. * Goes to a specific frame in this animation group
  33446. * @param frame the frame number to go to
  33447. * @return the animationGroup
  33448. */
  33449. goToFrame(frame: number): AnimationGroup;
  33450. /**
  33451. * Dispose all associated resources
  33452. */
  33453. dispose(): void;
  33454. private _checkAnimationGroupEnded;
  33455. /**
  33456. * Clone the current animation group and returns a copy
  33457. * @param newName defines the name of the new group
  33458. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33459. * @returns the new aniamtion group
  33460. */
  33461. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33462. /**
  33463. * Serializes the animationGroup to an object
  33464. * @returns Serialized object
  33465. */
  33466. serialize(): any;
  33467. /**
  33468. * Returns a new AnimationGroup object parsed from the source provided.
  33469. * @param parsedAnimationGroup defines the source
  33470. * @param scene defines the scene that will receive the animationGroup
  33471. * @returns a new AnimationGroup
  33472. */
  33473. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33474. /**
  33475. * Returns the string "AnimationGroup"
  33476. * @returns "AnimationGroup"
  33477. */
  33478. getClassName(): string;
  33479. /**
  33480. * Creates a detailled string about the object
  33481. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33482. * @returns a string representing the object
  33483. */
  33484. toString(fullDetails?: boolean): string;
  33485. }
  33486. }
  33487. declare module "babylonjs/scene" {
  33488. import { Nullable } from "babylonjs/types";
  33489. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33490. import { Observable } from "babylonjs/Misc/observable";
  33491. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33492. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33493. import { Geometry } from "babylonjs/Meshes/geometry";
  33494. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33497. import { Mesh } from "babylonjs/Meshes/mesh";
  33498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33499. import { Bone } from "babylonjs/Bones/bone";
  33500. import { Skeleton } from "babylonjs/Bones/skeleton";
  33501. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33502. import { Camera } from "babylonjs/Cameras/camera";
  33503. import { AbstractScene } from "babylonjs/abstractScene";
  33504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33506. import { Material } from "babylonjs/Materials/material";
  33507. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33508. import { Effect } from "babylonjs/Materials/effect";
  33509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33510. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33511. import { Light } from "babylonjs/Lights/light";
  33512. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33513. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33514. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33515. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33516. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33517. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33518. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33519. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33520. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33521. import { Engine } from "babylonjs/Engines/engine";
  33522. import { Node } from "babylonjs/node";
  33523. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33524. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33525. import { WebRequest } from "babylonjs/Misc/webRequest";
  33526. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33527. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33528. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33529. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33530. import { Plane } from "babylonjs/Maths/math.plane";
  33531. import { Ray } from "babylonjs/Culling/ray";
  33532. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33533. import { Animation } from "babylonjs/Animations/animation";
  33534. import { Animatable } from "babylonjs/Animations/animatable";
  33535. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33536. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33537. import { Collider } from "babylonjs/Collisions/collider";
  33538. /**
  33539. * Define an interface for all classes that will hold resources
  33540. */
  33541. export interface IDisposable {
  33542. /**
  33543. * Releases all held resources
  33544. */
  33545. dispose(): void;
  33546. }
  33547. /** Interface defining initialization parameters for Scene class */
  33548. export interface SceneOptions {
  33549. /**
  33550. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33551. * It will improve performance when the number of geometries becomes important.
  33552. */
  33553. useGeometryUniqueIdsMap?: boolean;
  33554. /**
  33555. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33556. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33557. */
  33558. useMaterialMeshMap?: boolean;
  33559. /**
  33560. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33561. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33562. */
  33563. useClonedMeshhMap?: boolean;
  33564. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33565. virtual?: boolean;
  33566. }
  33567. /**
  33568. * Represents a scene to be rendered by the engine.
  33569. * @see http://doc.babylonjs.com/features/scene
  33570. */
  33571. export class Scene extends AbstractScene implements IAnimatable {
  33572. /** The fog is deactivated */
  33573. static readonly FOGMODE_NONE: number;
  33574. /** The fog density is following an exponential function */
  33575. static readonly FOGMODE_EXP: number;
  33576. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33577. static readonly FOGMODE_EXP2: number;
  33578. /** The fog density is following a linear function. */
  33579. static readonly FOGMODE_LINEAR: number;
  33580. /**
  33581. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33583. */
  33584. static MinDeltaTime: number;
  33585. /**
  33586. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33588. */
  33589. static MaxDeltaTime: number;
  33590. /**
  33591. * Factory used to create the default material.
  33592. * @param name The name of the material to create
  33593. * @param scene The scene to create the material for
  33594. * @returns The default material
  33595. */
  33596. static DefaultMaterialFactory(scene: Scene): Material;
  33597. /**
  33598. * Factory used to create the a collision coordinator.
  33599. * @returns The collision coordinator
  33600. */
  33601. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33602. /** @hidden */
  33603. _inputManager: InputManager;
  33604. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33605. cameraToUseForPointers: Nullable<Camera>;
  33606. /** @hidden */
  33607. readonly _isScene: boolean;
  33608. /**
  33609. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33610. */
  33611. autoClear: boolean;
  33612. /**
  33613. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33614. */
  33615. autoClearDepthAndStencil: boolean;
  33616. /**
  33617. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33618. */
  33619. clearColor: Color4;
  33620. /**
  33621. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33622. */
  33623. ambientColor: Color3;
  33624. /**
  33625. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33626. * It should only be one of the following (if not the default embedded one):
  33627. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33628. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33629. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33630. * The material properties need to be setup according to the type of texture in use.
  33631. */
  33632. environmentBRDFTexture: BaseTexture;
  33633. /** @hidden */
  33634. protected _environmentTexture: Nullable<BaseTexture>;
  33635. /**
  33636. * Texture used in all pbr material as the reflection texture.
  33637. * As in the majority of the scene they are the same (exception for multi room and so on),
  33638. * this is easier to reference from here than from all the materials.
  33639. */
  33640. /**
  33641. * Texture used in all pbr material as the reflection texture.
  33642. * As in the majority of the scene they are the same (exception for multi room and so on),
  33643. * this is easier to set here than in all the materials.
  33644. */
  33645. environmentTexture: Nullable<BaseTexture>;
  33646. /** @hidden */
  33647. protected _environmentIntensity: number;
  33648. /**
  33649. * Intensity of the environment in all pbr material.
  33650. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33651. * As in the majority of the scene they are the same (exception for multi room and so on),
  33652. * this is easier to reference from here than from all the materials.
  33653. */
  33654. /**
  33655. * Intensity of the environment in all pbr material.
  33656. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33657. * As in the majority of the scene they are the same (exception for multi room and so on),
  33658. * this is easier to set here than in all the materials.
  33659. */
  33660. environmentIntensity: number;
  33661. /** @hidden */
  33662. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33663. /**
  33664. * Default image processing configuration used either in the rendering
  33665. * Forward main pass or through the imageProcessingPostProcess if present.
  33666. * As in the majority of the scene they are the same (exception for multi camera),
  33667. * this is easier to reference from here than from all the materials and post process.
  33668. *
  33669. * No setter as we it is a shared configuration, you can set the values instead.
  33670. */
  33671. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33672. private _forceWireframe;
  33673. /**
  33674. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33675. */
  33676. forceWireframe: boolean;
  33677. private _forcePointsCloud;
  33678. /**
  33679. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33680. */
  33681. forcePointsCloud: boolean;
  33682. /**
  33683. * Gets or sets the active clipplane 1
  33684. */
  33685. clipPlane: Nullable<Plane>;
  33686. /**
  33687. * Gets or sets the active clipplane 2
  33688. */
  33689. clipPlane2: Nullable<Plane>;
  33690. /**
  33691. * Gets or sets the active clipplane 3
  33692. */
  33693. clipPlane3: Nullable<Plane>;
  33694. /**
  33695. * Gets or sets the active clipplane 4
  33696. */
  33697. clipPlane4: Nullable<Plane>;
  33698. /**
  33699. * Gets or sets a boolean indicating if animations are enabled
  33700. */
  33701. animationsEnabled: boolean;
  33702. private _animationPropertiesOverride;
  33703. /**
  33704. * Gets or sets the animation properties override
  33705. */
  33706. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33707. /**
  33708. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33709. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33710. */
  33711. useConstantAnimationDeltaTime: boolean;
  33712. /**
  33713. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33714. * Please note that it requires to run a ray cast through the scene on every frame
  33715. */
  33716. constantlyUpdateMeshUnderPointer: boolean;
  33717. /**
  33718. * Defines the HTML cursor to use when hovering over interactive elements
  33719. */
  33720. hoverCursor: string;
  33721. /**
  33722. * Defines the HTML default cursor to use (empty by default)
  33723. */
  33724. defaultCursor: string;
  33725. /**
  33726. * This is used to call preventDefault() on pointer down
  33727. * in order to block unwanted artifacts like system double clicks
  33728. */
  33729. preventDefaultOnPointerDown: boolean;
  33730. /**
  33731. * This is used to call preventDefault() on pointer up
  33732. * in order to block unwanted artifacts like system double clicks
  33733. */
  33734. preventDefaultOnPointerUp: boolean;
  33735. /**
  33736. * Gets or sets user defined metadata
  33737. */
  33738. metadata: any;
  33739. /**
  33740. * For internal use only. Please do not use.
  33741. */
  33742. reservedDataStore: any;
  33743. /**
  33744. * Gets the name of the plugin used to load this scene (null by default)
  33745. */
  33746. loadingPluginName: string;
  33747. /**
  33748. * Use this array to add regular expressions used to disable offline support for specific urls
  33749. */
  33750. disableOfflineSupportExceptionRules: RegExp[];
  33751. /**
  33752. * An event triggered when the scene is disposed.
  33753. */
  33754. onDisposeObservable: Observable<Scene>;
  33755. private _onDisposeObserver;
  33756. /** Sets a function to be executed when this scene is disposed. */
  33757. onDispose: () => void;
  33758. /**
  33759. * An event triggered before rendering the scene (right after animations and physics)
  33760. */
  33761. onBeforeRenderObservable: Observable<Scene>;
  33762. private _onBeforeRenderObserver;
  33763. /** Sets a function to be executed before rendering this scene */
  33764. beforeRender: Nullable<() => void>;
  33765. /**
  33766. * An event triggered after rendering the scene
  33767. */
  33768. onAfterRenderObservable: Observable<Scene>;
  33769. /**
  33770. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33771. */
  33772. onAfterRenderCameraObservable: Observable<Camera>;
  33773. private _onAfterRenderObserver;
  33774. /** Sets a function to be executed after rendering this scene */
  33775. afterRender: Nullable<() => void>;
  33776. /**
  33777. * An event triggered before animating the scene
  33778. */
  33779. onBeforeAnimationsObservable: Observable<Scene>;
  33780. /**
  33781. * An event triggered after animations processing
  33782. */
  33783. onAfterAnimationsObservable: Observable<Scene>;
  33784. /**
  33785. * An event triggered before draw calls are ready to be sent
  33786. */
  33787. onBeforeDrawPhaseObservable: Observable<Scene>;
  33788. /**
  33789. * An event triggered after draw calls have been sent
  33790. */
  33791. onAfterDrawPhaseObservable: Observable<Scene>;
  33792. /**
  33793. * An event triggered when the scene is ready
  33794. */
  33795. onReadyObservable: Observable<Scene>;
  33796. /**
  33797. * An event triggered before rendering a camera
  33798. */
  33799. onBeforeCameraRenderObservable: Observable<Camera>;
  33800. private _onBeforeCameraRenderObserver;
  33801. /** Sets a function to be executed before rendering a camera*/
  33802. beforeCameraRender: () => void;
  33803. /**
  33804. * An event triggered after rendering a camera
  33805. */
  33806. onAfterCameraRenderObservable: Observable<Camera>;
  33807. private _onAfterCameraRenderObserver;
  33808. /** Sets a function to be executed after rendering a camera*/
  33809. afterCameraRender: () => void;
  33810. /**
  33811. * An event triggered when active meshes evaluation is about to start
  33812. */
  33813. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33814. /**
  33815. * An event triggered when active meshes evaluation is done
  33816. */
  33817. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33818. /**
  33819. * An event triggered when particles rendering is about to start
  33820. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33821. */
  33822. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33823. /**
  33824. * An event triggered when particles rendering is done
  33825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33826. */
  33827. onAfterParticlesRenderingObservable: Observable<Scene>;
  33828. /**
  33829. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33830. */
  33831. onDataLoadedObservable: Observable<Scene>;
  33832. /**
  33833. * An event triggered when a camera is created
  33834. */
  33835. onNewCameraAddedObservable: Observable<Camera>;
  33836. /**
  33837. * An event triggered when a camera is removed
  33838. */
  33839. onCameraRemovedObservable: Observable<Camera>;
  33840. /**
  33841. * An event triggered when a light is created
  33842. */
  33843. onNewLightAddedObservable: Observable<Light>;
  33844. /**
  33845. * An event triggered when a light is removed
  33846. */
  33847. onLightRemovedObservable: Observable<Light>;
  33848. /**
  33849. * An event triggered when a geometry is created
  33850. */
  33851. onNewGeometryAddedObservable: Observable<Geometry>;
  33852. /**
  33853. * An event triggered when a geometry is removed
  33854. */
  33855. onGeometryRemovedObservable: Observable<Geometry>;
  33856. /**
  33857. * An event triggered when a transform node is created
  33858. */
  33859. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33860. /**
  33861. * An event triggered when a transform node is removed
  33862. */
  33863. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33864. /**
  33865. * An event triggered when a mesh is created
  33866. */
  33867. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33868. /**
  33869. * An event triggered when a mesh is removed
  33870. */
  33871. onMeshRemovedObservable: Observable<AbstractMesh>;
  33872. /**
  33873. * An event triggered when a skeleton is created
  33874. */
  33875. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33876. /**
  33877. * An event triggered when a skeleton is removed
  33878. */
  33879. onSkeletonRemovedObservable: Observable<Skeleton>;
  33880. /**
  33881. * An event triggered when a material is created
  33882. */
  33883. onNewMaterialAddedObservable: Observable<Material>;
  33884. /**
  33885. * An event triggered when a material is removed
  33886. */
  33887. onMaterialRemovedObservable: Observable<Material>;
  33888. /**
  33889. * An event triggered when a texture is created
  33890. */
  33891. onNewTextureAddedObservable: Observable<BaseTexture>;
  33892. /**
  33893. * An event triggered when a texture is removed
  33894. */
  33895. onTextureRemovedObservable: Observable<BaseTexture>;
  33896. /**
  33897. * An event triggered when render targets are about to be rendered
  33898. * Can happen multiple times per frame.
  33899. */
  33900. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33901. /**
  33902. * An event triggered when render targets were rendered.
  33903. * Can happen multiple times per frame.
  33904. */
  33905. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33906. /**
  33907. * An event triggered before calculating deterministic simulation step
  33908. */
  33909. onBeforeStepObservable: Observable<Scene>;
  33910. /**
  33911. * An event triggered after calculating deterministic simulation step
  33912. */
  33913. onAfterStepObservable: Observable<Scene>;
  33914. /**
  33915. * An event triggered when the activeCamera property is updated
  33916. */
  33917. onActiveCameraChanged: Observable<Scene>;
  33918. /**
  33919. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33920. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33921. * 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)
  33922. */
  33923. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33924. /**
  33925. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33926. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33927. * 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)
  33928. */
  33929. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33930. /**
  33931. * This Observable will when a mesh has been imported into the scene.
  33932. */
  33933. onMeshImportedObservable: Observable<AbstractMesh>;
  33934. /**
  33935. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33936. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33937. */
  33938. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33939. /** @hidden */
  33940. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33941. /**
  33942. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33943. */
  33944. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33945. /**
  33946. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33947. */
  33948. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33949. /**
  33950. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33951. */
  33952. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33953. /** Callback called when a pointer move is detected */
  33954. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33955. /** Callback called when a pointer down is detected */
  33956. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33957. /** Callback called when a pointer up is detected */
  33958. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33959. /** Callback called when a pointer pick is detected */
  33960. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33961. /**
  33962. * 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).
  33963. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33964. */
  33965. onPrePointerObservable: Observable<PointerInfoPre>;
  33966. /**
  33967. * Observable event triggered each time an input event is received from the rendering canvas
  33968. */
  33969. onPointerObservable: Observable<PointerInfo>;
  33970. /**
  33971. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33972. */
  33973. readonly unTranslatedPointer: Vector2;
  33974. /**
  33975. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33976. */
  33977. static DragMovementThreshold: number;
  33978. /**
  33979. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33980. */
  33981. static LongPressDelay: number;
  33982. /**
  33983. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33984. */
  33985. static DoubleClickDelay: number;
  33986. /** If you need to check double click without raising a single click at first click, enable this flag */
  33987. static ExclusiveDoubleClickMode: boolean;
  33988. /** @hidden */
  33989. _mirroredCameraPosition: Nullable<Vector3>;
  33990. /**
  33991. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33992. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33993. */
  33994. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33995. /**
  33996. * Observable event triggered each time an keyboard event is received from the hosting window
  33997. */
  33998. onKeyboardObservable: Observable<KeyboardInfo>;
  33999. private _useRightHandedSystem;
  34000. /**
  34001. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34002. */
  34003. useRightHandedSystem: boolean;
  34004. private _timeAccumulator;
  34005. private _currentStepId;
  34006. private _currentInternalStep;
  34007. /**
  34008. * Sets the step Id used by deterministic lock step
  34009. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34010. * @param newStepId defines the step Id
  34011. */
  34012. setStepId(newStepId: number): void;
  34013. /**
  34014. * Gets the step Id used by deterministic lock step
  34015. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34016. * @returns the step Id
  34017. */
  34018. getStepId(): number;
  34019. /**
  34020. * Gets the internal step used by deterministic lock step
  34021. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34022. * @returns the internal step
  34023. */
  34024. getInternalStep(): number;
  34025. private _fogEnabled;
  34026. /**
  34027. * Gets or sets a boolean indicating if fog is enabled on this scene
  34028. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34029. * (Default is true)
  34030. */
  34031. fogEnabled: boolean;
  34032. private _fogMode;
  34033. /**
  34034. * Gets or sets the fog mode to use
  34035. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34036. * | mode | value |
  34037. * | --- | --- |
  34038. * | FOGMODE_NONE | 0 |
  34039. * | FOGMODE_EXP | 1 |
  34040. * | FOGMODE_EXP2 | 2 |
  34041. * | FOGMODE_LINEAR | 3 |
  34042. */
  34043. fogMode: number;
  34044. /**
  34045. * Gets or sets the fog color to use
  34046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34047. * (Default is Color3(0.2, 0.2, 0.3))
  34048. */
  34049. fogColor: Color3;
  34050. /**
  34051. * Gets or sets the fog density to use
  34052. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34053. * (Default is 0.1)
  34054. */
  34055. fogDensity: number;
  34056. /**
  34057. * Gets or sets the fog start distance to use
  34058. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34059. * (Default is 0)
  34060. */
  34061. fogStart: number;
  34062. /**
  34063. * Gets or sets the fog end distance to use
  34064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34065. * (Default is 1000)
  34066. */
  34067. fogEnd: number;
  34068. private _shadowsEnabled;
  34069. /**
  34070. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34071. */
  34072. shadowsEnabled: boolean;
  34073. private _lightsEnabled;
  34074. /**
  34075. * Gets or sets a boolean indicating if lights are enabled on this scene
  34076. */
  34077. lightsEnabled: boolean;
  34078. /** All of the active cameras added to this scene. */
  34079. activeCameras: Camera[];
  34080. /** @hidden */
  34081. _activeCamera: Nullable<Camera>;
  34082. /** Gets or sets the current active camera */
  34083. activeCamera: Nullable<Camera>;
  34084. private _defaultMaterial;
  34085. /** The default material used on meshes when no material is affected */
  34086. /** The default material used on meshes when no material is affected */
  34087. defaultMaterial: Material;
  34088. private _texturesEnabled;
  34089. /**
  34090. * Gets or sets a boolean indicating if textures are enabled on this scene
  34091. */
  34092. texturesEnabled: boolean;
  34093. /**
  34094. * Gets or sets a boolean indicating if particles are enabled on this scene
  34095. */
  34096. particlesEnabled: boolean;
  34097. /**
  34098. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34099. */
  34100. spritesEnabled: boolean;
  34101. private _skeletonsEnabled;
  34102. /**
  34103. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34104. */
  34105. skeletonsEnabled: boolean;
  34106. /**
  34107. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34108. */
  34109. lensFlaresEnabled: boolean;
  34110. /**
  34111. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34113. */
  34114. collisionsEnabled: boolean;
  34115. private _collisionCoordinator;
  34116. /** @hidden */
  34117. readonly collisionCoordinator: ICollisionCoordinator;
  34118. /**
  34119. * Defines the gravity applied to this scene (used only for collisions)
  34120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34121. */
  34122. gravity: Vector3;
  34123. /**
  34124. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34125. */
  34126. postProcessesEnabled: boolean;
  34127. /**
  34128. * The list of postprocesses added to the scene
  34129. */
  34130. postProcesses: PostProcess[];
  34131. /**
  34132. * Gets the current postprocess manager
  34133. */
  34134. postProcessManager: PostProcessManager;
  34135. /**
  34136. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34137. */
  34138. renderTargetsEnabled: boolean;
  34139. /**
  34140. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34141. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34142. */
  34143. dumpNextRenderTargets: boolean;
  34144. /**
  34145. * The list of user defined render targets added to the scene
  34146. */
  34147. customRenderTargets: RenderTargetTexture[];
  34148. /**
  34149. * Defines if texture loading must be delayed
  34150. * If true, textures will only be loaded when they need to be rendered
  34151. */
  34152. useDelayedTextureLoading: boolean;
  34153. /**
  34154. * Gets the list of meshes imported to the scene through SceneLoader
  34155. */
  34156. importedMeshesFiles: String[];
  34157. /**
  34158. * Gets or sets a boolean indicating if probes are enabled on this scene
  34159. */
  34160. probesEnabled: boolean;
  34161. /**
  34162. * Gets or sets the current offline provider to use to store scene data
  34163. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34164. */
  34165. offlineProvider: IOfflineProvider;
  34166. /**
  34167. * Gets or sets the action manager associated with the scene
  34168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34169. */
  34170. actionManager: AbstractActionManager;
  34171. private _meshesForIntersections;
  34172. /**
  34173. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34174. */
  34175. proceduralTexturesEnabled: boolean;
  34176. private _engine;
  34177. private _totalVertices;
  34178. /** @hidden */
  34179. _activeIndices: PerfCounter;
  34180. /** @hidden */
  34181. _activeParticles: PerfCounter;
  34182. /** @hidden */
  34183. _activeBones: PerfCounter;
  34184. private _animationRatio;
  34185. /** @hidden */
  34186. _animationTimeLast: number;
  34187. /** @hidden */
  34188. _animationTime: number;
  34189. /**
  34190. * Gets or sets a general scale for animation speed
  34191. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34192. */
  34193. animationTimeScale: number;
  34194. /** @hidden */
  34195. _cachedMaterial: Nullable<Material>;
  34196. /** @hidden */
  34197. _cachedEffect: Nullable<Effect>;
  34198. /** @hidden */
  34199. _cachedVisibility: Nullable<number>;
  34200. private _renderId;
  34201. private _frameId;
  34202. private _executeWhenReadyTimeoutId;
  34203. private _intermediateRendering;
  34204. private _viewUpdateFlag;
  34205. private _projectionUpdateFlag;
  34206. /** @hidden */
  34207. _toBeDisposed: Nullable<IDisposable>[];
  34208. private _activeRequests;
  34209. /** @hidden */
  34210. _pendingData: any[];
  34211. private _isDisposed;
  34212. /**
  34213. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34214. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34215. */
  34216. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34217. private _activeMeshes;
  34218. private _processedMaterials;
  34219. private _renderTargets;
  34220. /** @hidden */
  34221. _activeParticleSystems: SmartArray<IParticleSystem>;
  34222. private _activeSkeletons;
  34223. private _softwareSkinnedMeshes;
  34224. private _renderingManager;
  34225. /** @hidden */
  34226. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34227. private _transformMatrix;
  34228. private _sceneUbo;
  34229. /** @hidden */
  34230. _viewMatrix: Matrix;
  34231. private _projectionMatrix;
  34232. /** @hidden */
  34233. _forcedViewPosition: Nullable<Vector3>;
  34234. /** @hidden */
  34235. _frustumPlanes: Plane[];
  34236. /**
  34237. * Gets the list of frustum planes (built from the active camera)
  34238. */
  34239. readonly frustumPlanes: Plane[];
  34240. /**
  34241. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34242. * This is useful if there are more lights that the maximum simulteanous authorized
  34243. */
  34244. requireLightSorting: boolean;
  34245. /** @hidden */
  34246. readonly useMaterialMeshMap: boolean;
  34247. /** @hidden */
  34248. readonly useClonedMeshhMap: boolean;
  34249. private _externalData;
  34250. private _uid;
  34251. /**
  34252. * @hidden
  34253. * Backing store of defined scene components.
  34254. */
  34255. _components: ISceneComponent[];
  34256. /**
  34257. * @hidden
  34258. * Backing store of defined scene components.
  34259. */
  34260. _serializableComponents: ISceneSerializableComponent[];
  34261. /**
  34262. * List of components to register on the next registration step.
  34263. */
  34264. private _transientComponents;
  34265. /**
  34266. * Registers the transient components if needed.
  34267. */
  34268. private _registerTransientComponents;
  34269. /**
  34270. * @hidden
  34271. * Add a component to the scene.
  34272. * Note that the ccomponent could be registered on th next frame if this is called after
  34273. * the register component stage.
  34274. * @param component Defines the component to add to the scene
  34275. */
  34276. _addComponent(component: ISceneComponent): void;
  34277. /**
  34278. * @hidden
  34279. * Gets a component from the scene.
  34280. * @param name defines the name of the component to retrieve
  34281. * @returns the component or null if not present
  34282. */
  34283. _getComponent(name: string): Nullable<ISceneComponent>;
  34284. /**
  34285. * @hidden
  34286. * Defines the actions happening before camera updates.
  34287. */
  34288. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34289. /**
  34290. * @hidden
  34291. * Defines the actions happening before clear the canvas.
  34292. */
  34293. _beforeClearStage: Stage<SimpleStageAction>;
  34294. /**
  34295. * @hidden
  34296. * Defines the actions when collecting render targets for the frame.
  34297. */
  34298. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34299. /**
  34300. * @hidden
  34301. * Defines the actions happening for one camera in the frame.
  34302. */
  34303. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34304. /**
  34305. * @hidden
  34306. * Defines the actions happening during the per mesh ready checks.
  34307. */
  34308. _isReadyForMeshStage: Stage<MeshStageAction>;
  34309. /**
  34310. * @hidden
  34311. * Defines the actions happening before evaluate active mesh checks.
  34312. */
  34313. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34314. /**
  34315. * @hidden
  34316. * Defines the actions happening during the evaluate sub mesh checks.
  34317. */
  34318. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34319. /**
  34320. * @hidden
  34321. * Defines the actions happening during the active mesh stage.
  34322. */
  34323. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34324. /**
  34325. * @hidden
  34326. * Defines the actions happening during the per camera render target step.
  34327. */
  34328. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34329. /**
  34330. * @hidden
  34331. * Defines the actions happening just before the active camera is drawing.
  34332. */
  34333. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34334. /**
  34335. * @hidden
  34336. * Defines the actions happening just before a render target is drawing.
  34337. */
  34338. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34339. /**
  34340. * @hidden
  34341. * Defines the actions happening just before a rendering group is drawing.
  34342. */
  34343. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34344. /**
  34345. * @hidden
  34346. * Defines the actions happening just before a mesh is drawing.
  34347. */
  34348. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34349. /**
  34350. * @hidden
  34351. * Defines the actions happening just after a mesh has been drawn.
  34352. */
  34353. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34354. /**
  34355. * @hidden
  34356. * Defines the actions happening just after a rendering group has been drawn.
  34357. */
  34358. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34359. /**
  34360. * @hidden
  34361. * Defines the actions happening just after the active camera has been drawn.
  34362. */
  34363. _afterCameraDrawStage: Stage<CameraStageAction>;
  34364. /**
  34365. * @hidden
  34366. * Defines the actions happening just after a render target has been drawn.
  34367. */
  34368. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34369. /**
  34370. * @hidden
  34371. * Defines the actions happening just after rendering all cameras and computing intersections.
  34372. */
  34373. _afterRenderStage: Stage<SimpleStageAction>;
  34374. /**
  34375. * @hidden
  34376. * Defines the actions happening when a pointer move event happens.
  34377. */
  34378. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34379. /**
  34380. * @hidden
  34381. * Defines the actions happening when a pointer down event happens.
  34382. */
  34383. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34384. /**
  34385. * @hidden
  34386. * Defines the actions happening when a pointer up event happens.
  34387. */
  34388. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34389. /**
  34390. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34391. */
  34392. private geometriesByUniqueId;
  34393. /**
  34394. * Creates a new Scene
  34395. * @param engine defines the engine to use to render this scene
  34396. * @param options defines the scene options
  34397. */
  34398. constructor(engine: Engine, options?: SceneOptions);
  34399. /**
  34400. * Gets a string idenfifying the name of the class
  34401. * @returns "Scene" string
  34402. */
  34403. getClassName(): string;
  34404. private _defaultMeshCandidates;
  34405. /**
  34406. * @hidden
  34407. */
  34408. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34409. private _defaultSubMeshCandidates;
  34410. /**
  34411. * @hidden
  34412. */
  34413. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34414. /**
  34415. * Sets the default candidate providers for the scene.
  34416. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34417. * and getCollidingSubMeshCandidates to their default function
  34418. */
  34419. setDefaultCandidateProviders(): void;
  34420. /**
  34421. * Gets the mesh that is currently under the pointer
  34422. */
  34423. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34424. /**
  34425. * Gets or sets the current on-screen X position of the pointer
  34426. */
  34427. pointerX: number;
  34428. /**
  34429. * Gets or sets the current on-screen Y position of the pointer
  34430. */
  34431. pointerY: number;
  34432. /**
  34433. * Gets the cached material (ie. the latest rendered one)
  34434. * @returns the cached material
  34435. */
  34436. getCachedMaterial(): Nullable<Material>;
  34437. /**
  34438. * Gets the cached effect (ie. the latest rendered one)
  34439. * @returns the cached effect
  34440. */
  34441. getCachedEffect(): Nullable<Effect>;
  34442. /**
  34443. * Gets the cached visibility state (ie. the latest rendered one)
  34444. * @returns the cached visibility state
  34445. */
  34446. getCachedVisibility(): Nullable<number>;
  34447. /**
  34448. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34449. * @param material defines the current material
  34450. * @param effect defines the current effect
  34451. * @param visibility defines the current visibility state
  34452. * @returns true if one parameter is not cached
  34453. */
  34454. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34455. /**
  34456. * Gets the engine associated with the scene
  34457. * @returns an Engine
  34458. */
  34459. getEngine(): Engine;
  34460. /**
  34461. * Gets the total number of vertices rendered per frame
  34462. * @returns the total number of vertices rendered per frame
  34463. */
  34464. getTotalVertices(): number;
  34465. /**
  34466. * Gets the performance counter for total vertices
  34467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34468. */
  34469. readonly totalVerticesPerfCounter: PerfCounter;
  34470. /**
  34471. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34472. * @returns the total number of active indices rendered per frame
  34473. */
  34474. getActiveIndices(): number;
  34475. /**
  34476. * Gets the performance counter for active indices
  34477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34478. */
  34479. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34480. /**
  34481. * Gets the total number of active particles rendered per frame
  34482. * @returns the total number of active particles rendered per frame
  34483. */
  34484. getActiveParticles(): number;
  34485. /**
  34486. * Gets the performance counter for active particles
  34487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34488. */
  34489. readonly activeParticlesPerfCounter: PerfCounter;
  34490. /**
  34491. * Gets the total number of active bones rendered per frame
  34492. * @returns the total number of active bones rendered per frame
  34493. */
  34494. getActiveBones(): number;
  34495. /**
  34496. * Gets the performance counter for active bones
  34497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34498. */
  34499. readonly activeBonesPerfCounter: PerfCounter;
  34500. /**
  34501. * Gets the array of active meshes
  34502. * @returns an array of AbstractMesh
  34503. */
  34504. getActiveMeshes(): SmartArray<AbstractMesh>;
  34505. /**
  34506. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34507. * @returns a number
  34508. */
  34509. getAnimationRatio(): number;
  34510. /**
  34511. * Gets an unique Id for the current render phase
  34512. * @returns a number
  34513. */
  34514. getRenderId(): number;
  34515. /**
  34516. * Gets an unique Id for the current frame
  34517. * @returns a number
  34518. */
  34519. getFrameId(): number;
  34520. /** Call this function if you want to manually increment the render Id*/
  34521. incrementRenderId(): void;
  34522. private _createUbo;
  34523. /**
  34524. * Use this method to simulate a pointer move on a mesh
  34525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34528. * @returns the current scene
  34529. */
  34530. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34531. /**
  34532. * Use this method to simulate a pointer down on a mesh
  34533. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34534. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34535. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34536. * @returns the current scene
  34537. */
  34538. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34539. /**
  34540. * Use this method to simulate a pointer up on a mesh
  34541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34544. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34545. * @returns the current scene
  34546. */
  34547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34548. /**
  34549. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34550. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34551. * @returns true if the pointer was captured
  34552. */
  34553. isPointerCaptured(pointerId?: number): boolean;
  34554. /**
  34555. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34556. * @param attachUp defines if you want to attach events to pointerup
  34557. * @param attachDown defines if you want to attach events to pointerdown
  34558. * @param attachMove defines if you want to attach events to pointermove
  34559. */
  34560. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34561. /** Detaches all event handlers*/
  34562. detachControl(): void;
  34563. /**
  34564. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34565. * Delay loaded resources are not taking in account
  34566. * @return true if all required resources are ready
  34567. */
  34568. isReady(): boolean;
  34569. /** Resets all cached information relative to material (including effect and visibility) */
  34570. resetCachedMaterial(): void;
  34571. /**
  34572. * Registers a function to be called before every frame render
  34573. * @param func defines the function to register
  34574. */
  34575. registerBeforeRender(func: () => void): void;
  34576. /**
  34577. * Unregisters a function called before every frame render
  34578. * @param func defines the function to unregister
  34579. */
  34580. unregisterBeforeRender(func: () => void): void;
  34581. /**
  34582. * Registers a function to be called after every frame render
  34583. * @param func defines the function to register
  34584. */
  34585. registerAfterRender(func: () => void): void;
  34586. /**
  34587. * Unregisters a function called after every frame render
  34588. * @param func defines the function to unregister
  34589. */
  34590. unregisterAfterRender(func: () => void): void;
  34591. private _executeOnceBeforeRender;
  34592. /**
  34593. * The provided function will run before render once and will be disposed afterwards.
  34594. * A timeout delay can be provided so that the function will be executed in N ms.
  34595. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34596. * @param func The function to be executed.
  34597. * @param timeout optional delay in ms
  34598. */
  34599. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34600. /** @hidden */
  34601. _addPendingData(data: any): void;
  34602. /** @hidden */
  34603. _removePendingData(data: any): void;
  34604. /**
  34605. * Returns the number of items waiting to be loaded
  34606. * @returns the number of items waiting to be loaded
  34607. */
  34608. getWaitingItemsCount(): number;
  34609. /**
  34610. * Returns a boolean indicating if the scene is still loading data
  34611. */
  34612. readonly isLoading: boolean;
  34613. /**
  34614. * Registers a function to be executed when the scene is ready
  34615. * @param {Function} func - the function to be executed
  34616. */
  34617. executeWhenReady(func: () => void): void;
  34618. /**
  34619. * Returns a promise that resolves when the scene is ready
  34620. * @returns A promise that resolves when the scene is ready
  34621. */
  34622. whenReadyAsync(): Promise<void>;
  34623. /** @hidden */
  34624. _checkIsReady(): void;
  34625. /**
  34626. * Gets all animatable attached to the scene
  34627. */
  34628. readonly animatables: Animatable[];
  34629. /**
  34630. * Resets the last animation time frame.
  34631. * Useful to override when animations start running when loading a scene for the first time.
  34632. */
  34633. resetLastAnimationTimeFrame(): void;
  34634. /**
  34635. * Gets the current view matrix
  34636. * @returns a Matrix
  34637. */
  34638. getViewMatrix(): Matrix;
  34639. /**
  34640. * Gets the current projection matrix
  34641. * @returns a Matrix
  34642. */
  34643. getProjectionMatrix(): Matrix;
  34644. /**
  34645. * Gets the current transform matrix
  34646. * @returns a Matrix made of View * Projection
  34647. */
  34648. getTransformMatrix(): Matrix;
  34649. /**
  34650. * Sets the current transform matrix
  34651. * @param viewL defines the View matrix to use
  34652. * @param projectionL defines the Projection matrix to use
  34653. * @param viewR defines the right View matrix to use (if provided)
  34654. * @param projectionR defines the right Projection matrix to use (if provided)
  34655. */
  34656. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34657. /**
  34658. * Gets the uniform buffer used to store scene data
  34659. * @returns a UniformBuffer
  34660. */
  34661. getSceneUniformBuffer(): UniformBuffer;
  34662. /**
  34663. * Gets an unique (relatively to the current scene) Id
  34664. * @returns an unique number for the scene
  34665. */
  34666. getUniqueId(): number;
  34667. /**
  34668. * Add a mesh to the list of scene's meshes
  34669. * @param newMesh defines the mesh to add
  34670. * @param recursive if all child meshes should also be added to the scene
  34671. */
  34672. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34673. /**
  34674. * Remove a mesh for the list of scene's meshes
  34675. * @param toRemove defines the mesh to remove
  34676. * @param recursive if all child meshes should also be removed from the scene
  34677. * @returns the index where the mesh was in the mesh list
  34678. */
  34679. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34680. /**
  34681. * Add a transform node to the list of scene's transform nodes
  34682. * @param newTransformNode defines the transform node to add
  34683. */
  34684. addTransformNode(newTransformNode: TransformNode): void;
  34685. /**
  34686. * Remove a transform node for the list of scene's transform nodes
  34687. * @param toRemove defines the transform node to remove
  34688. * @returns the index where the transform node was in the transform node list
  34689. */
  34690. removeTransformNode(toRemove: TransformNode): number;
  34691. /**
  34692. * Remove a skeleton for the list of scene's skeletons
  34693. * @param toRemove defines the skeleton to remove
  34694. * @returns the index where the skeleton was in the skeleton list
  34695. */
  34696. removeSkeleton(toRemove: Skeleton): number;
  34697. /**
  34698. * Remove a morph target for the list of scene's morph targets
  34699. * @param toRemove defines the morph target to remove
  34700. * @returns the index where the morph target was in the morph target list
  34701. */
  34702. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34703. /**
  34704. * Remove a light for the list of scene's lights
  34705. * @param toRemove defines the light to remove
  34706. * @returns the index where the light was in the light list
  34707. */
  34708. removeLight(toRemove: Light): number;
  34709. /**
  34710. * Remove a camera for the list of scene's cameras
  34711. * @param toRemove defines the camera to remove
  34712. * @returns the index where the camera was in the camera list
  34713. */
  34714. removeCamera(toRemove: Camera): number;
  34715. /**
  34716. * Remove a particle system for the list of scene's particle systems
  34717. * @param toRemove defines the particle system to remove
  34718. * @returns the index where the particle system was in the particle system list
  34719. */
  34720. removeParticleSystem(toRemove: IParticleSystem): number;
  34721. /**
  34722. * Remove a animation for the list of scene's animations
  34723. * @param toRemove defines the animation to remove
  34724. * @returns the index where the animation was in the animation list
  34725. */
  34726. removeAnimation(toRemove: Animation): number;
  34727. /**
  34728. * Will stop the animation of the given target
  34729. * @param target - the target
  34730. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34731. * @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)
  34732. */
  34733. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34734. /**
  34735. * Removes the given animation group from this scene.
  34736. * @param toRemove The animation group to remove
  34737. * @returns The index of the removed animation group
  34738. */
  34739. removeAnimationGroup(toRemove: AnimationGroup): number;
  34740. /**
  34741. * Removes the given multi-material from this scene.
  34742. * @param toRemove The multi-material to remove
  34743. * @returns The index of the removed multi-material
  34744. */
  34745. removeMultiMaterial(toRemove: MultiMaterial): number;
  34746. /**
  34747. * Removes the given material from this scene.
  34748. * @param toRemove The material to remove
  34749. * @returns The index of the removed material
  34750. */
  34751. removeMaterial(toRemove: Material): number;
  34752. /**
  34753. * Removes the given action manager from this scene.
  34754. * @param toRemove The action manager to remove
  34755. * @returns The index of the removed action manager
  34756. */
  34757. removeActionManager(toRemove: AbstractActionManager): number;
  34758. /**
  34759. * Removes the given texture from this scene.
  34760. * @param toRemove The texture to remove
  34761. * @returns The index of the removed texture
  34762. */
  34763. removeTexture(toRemove: BaseTexture): number;
  34764. /**
  34765. * Adds the given light to this scene
  34766. * @param newLight The light to add
  34767. */
  34768. addLight(newLight: Light): void;
  34769. /**
  34770. * Sorts the list list based on light priorities
  34771. */
  34772. sortLightsByPriority(): void;
  34773. /**
  34774. * Adds the given camera to this scene
  34775. * @param newCamera The camera to add
  34776. */
  34777. addCamera(newCamera: Camera): void;
  34778. /**
  34779. * Adds the given skeleton to this scene
  34780. * @param newSkeleton The skeleton to add
  34781. */
  34782. addSkeleton(newSkeleton: Skeleton): void;
  34783. /**
  34784. * Adds the given particle system to this scene
  34785. * @param newParticleSystem The particle system to add
  34786. */
  34787. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34788. /**
  34789. * Adds the given animation to this scene
  34790. * @param newAnimation The animation to add
  34791. */
  34792. addAnimation(newAnimation: Animation): void;
  34793. /**
  34794. * Adds the given animation group to this scene.
  34795. * @param newAnimationGroup The animation group to add
  34796. */
  34797. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34798. /**
  34799. * Adds the given multi-material to this scene
  34800. * @param newMultiMaterial The multi-material to add
  34801. */
  34802. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34803. /**
  34804. * Adds the given material to this scene
  34805. * @param newMaterial The material to add
  34806. */
  34807. addMaterial(newMaterial: Material): void;
  34808. /**
  34809. * Adds the given morph target to this scene
  34810. * @param newMorphTargetManager The morph target to add
  34811. */
  34812. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34813. /**
  34814. * Adds the given geometry to this scene
  34815. * @param newGeometry The geometry to add
  34816. */
  34817. addGeometry(newGeometry: Geometry): void;
  34818. /**
  34819. * Adds the given action manager to this scene
  34820. * @param newActionManager The action manager to add
  34821. */
  34822. addActionManager(newActionManager: AbstractActionManager): void;
  34823. /**
  34824. * Adds the given texture to this scene.
  34825. * @param newTexture The texture to add
  34826. */
  34827. addTexture(newTexture: BaseTexture): void;
  34828. /**
  34829. * Switch active camera
  34830. * @param newCamera defines the new active camera
  34831. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34832. */
  34833. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34834. /**
  34835. * sets the active camera of the scene using its ID
  34836. * @param id defines the camera's ID
  34837. * @return the new active camera or null if none found.
  34838. */
  34839. setActiveCameraByID(id: string): Nullable<Camera>;
  34840. /**
  34841. * sets the active camera of the scene using its name
  34842. * @param name defines the camera's name
  34843. * @returns the new active camera or null if none found.
  34844. */
  34845. setActiveCameraByName(name: string): Nullable<Camera>;
  34846. /**
  34847. * get an animation group using its name
  34848. * @param name defines the material's name
  34849. * @return the animation group or null if none found.
  34850. */
  34851. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34852. /**
  34853. * Get a material using its unique id
  34854. * @param uniqueId defines the material's unique id
  34855. * @return the material or null if none found.
  34856. */
  34857. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34858. /**
  34859. * get a material using its id
  34860. * @param id defines the material's ID
  34861. * @return the material or null if none found.
  34862. */
  34863. getMaterialByID(id: string): Nullable<Material>;
  34864. /**
  34865. * Gets a the last added material using a given id
  34866. * @param id defines the material's ID
  34867. * @return the last material with the given id or null if none found.
  34868. */
  34869. getLastMaterialByID(id: string): Nullable<Material>;
  34870. /**
  34871. * Gets a material using its name
  34872. * @param name defines the material's name
  34873. * @return the material or null if none found.
  34874. */
  34875. getMaterialByName(name: string): Nullable<Material>;
  34876. /**
  34877. * Get a texture using its unique id
  34878. * @param uniqueId defines the texture's unique id
  34879. * @return the texture or null if none found.
  34880. */
  34881. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34882. /**
  34883. * Gets a camera using its id
  34884. * @param id defines the id to look for
  34885. * @returns the camera or null if not found
  34886. */
  34887. getCameraByID(id: string): Nullable<Camera>;
  34888. /**
  34889. * Gets a camera using its unique id
  34890. * @param uniqueId defines the unique id to look for
  34891. * @returns the camera or null if not found
  34892. */
  34893. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34894. /**
  34895. * Gets a camera using its name
  34896. * @param name defines the camera's name
  34897. * @return the camera or null if none found.
  34898. */
  34899. getCameraByName(name: string): Nullable<Camera>;
  34900. /**
  34901. * Gets a bone using its id
  34902. * @param id defines the bone's id
  34903. * @return the bone or null if not found
  34904. */
  34905. getBoneByID(id: string): Nullable<Bone>;
  34906. /**
  34907. * Gets a bone using its id
  34908. * @param name defines the bone's name
  34909. * @return the bone or null if not found
  34910. */
  34911. getBoneByName(name: string): Nullable<Bone>;
  34912. /**
  34913. * Gets a light node using its name
  34914. * @param name defines the the light's name
  34915. * @return the light or null if none found.
  34916. */
  34917. getLightByName(name: string): Nullable<Light>;
  34918. /**
  34919. * Gets a light node using its id
  34920. * @param id defines the light's id
  34921. * @return the light or null if none found.
  34922. */
  34923. getLightByID(id: string): Nullable<Light>;
  34924. /**
  34925. * Gets a light node using its scene-generated unique ID
  34926. * @param uniqueId defines the light's unique id
  34927. * @return the light or null if none found.
  34928. */
  34929. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34930. /**
  34931. * Gets a particle system by id
  34932. * @param id defines the particle system id
  34933. * @return the corresponding system or null if none found
  34934. */
  34935. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34936. /**
  34937. * Gets a geometry using its ID
  34938. * @param id defines the geometry's id
  34939. * @return the geometry or null if none found.
  34940. */
  34941. getGeometryByID(id: string): Nullable<Geometry>;
  34942. private _getGeometryByUniqueID;
  34943. /**
  34944. * Add a new geometry to this scene
  34945. * @param geometry defines the geometry to be added to the scene.
  34946. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34947. * @return a boolean defining if the geometry was added or not
  34948. */
  34949. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34950. /**
  34951. * Removes an existing geometry
  34952. * @param geometry defines the geometry to be removed from the scene
  34953. * @return a boolean defining if the geometry was removed or not
  34954. */
  34955. removeGeometry(geometry: Geometry): boolean;
  34956. /**
  34957. * Gets the list of geometries attached to the scene
  34958. * @returns an array of Geometry
  34959. */
  34960. getGeometries(): Geometry[];
  34961. /**
  34962. * Gets the first added mesh found of a given ID
  34963. * @param id defines the id to search for
  34964. * @return the mesh found or null if not found at all
  34965. */
  34966. getMeshByID(id: string): Nullable<AbstractMesh>;
  34967. /**
  34968. * Gets a list of meshes using their id
  34969. * @param id defines the id to search for
  34970. * @returns a list of meshes
  34971. */
  34972. getMeshesByID(id: string): Array<AbstractMesh>;
  34973. /**
  34974. * Gets the first added transform node found of a given ID
  34975. * @param id defines the id to search for
  34976. * @return the found transform node or null if not found at all.
  34977. */
  34978. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34979. /**
  34980. * Gets a transform node with its auto-generated unique id
  34981. * @param uniqueId efines the unique id to search for
  34982. * @return the found transform node or null if not found at all.
  34983. */
  34984. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34985. /**
  34986. * Gets a list of transform nodes using their id
  34987. * @param id defines the id to search for
  34988. * @returns a list of transform nodes
  34989. */
  34990. getTransformNodesByID(id: string): Array<TransformNode>;
  34991. /**
  34992. * Gets a mesh with its auto-generated unique id
  34993. * @param uniqueId defines the unique id to search for
  34994. * @return the found mesh or null if not found at all.
  34995. */
  34996. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34997. /**
  34998. * Gets a the last added mesh using a given id
  34999. * @param id defines the id to search for
  35000. * @return the found mesh or null if not found at all.
  35001. */
  35002. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35003. /**
  35004. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35005. * @param id defines the id to search for
  35006. * @return the found node or null if not found at all
  35007. */
  35008. getLastEntryByID(id: string): Nullable<Node>;
  35009. /**
  35010. * Gets a node (Mesh, Camera, Light) using a given id
  35011. * @param id defines the id to search for
  35012. * @return the found node or null if not found at all
  35013. */
  35014. getNodeByID(id: string): Nullable<Node>;
  35015. /**
  35016. * Gets a node (Mesh, Camera, Light) using a given name
  35017. * @param name defines the name to search for
  35018. * @return the found node or null if not found at all.
  35019. */
  35020. getNodeByName(name: string): Nullable<Node>;
  35021. /**
  35022. * Gets a mesh using a given name
  35023. * @param name defines the name to search for
  35024. * @return the found mesh or null if not found at all.
  35025. */
  35026. getMeshByName(name: string): Nullable<AbstractMesh>;
  35027. /**
  35028. * Gets a transform node using a given name
  35029. * @param name defines the name to search for
  35030. * @return the found transform node or null if not found at all.
  35031. */
  35032. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35033. /**
  35034. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35035. * @param id defines the id to search for
  35036. * @return the found skeleton or null if not found at all.
  35037. */
  35038. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35039. /**
  35040. * Gets a skeleton using a given auto generated unique id
  35041. * @param uniqueId defines the unique id to search for
  35042. * @return the found skeleton or null if not found at all.
  35043. */
  35044. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35045. /**
  35046. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35047. * @param id defines the id to search for
  35048. * @return the found skeleton or null if not found at all.
  35049. */
  35050. getSkeletonById(id: string): Nullable<Skeleton>;
  35051. /**
  35052. * Gets a skeleton using a given name
  35053. * @param name defines the name to search for
  35054. * @return the found skeleton or null if not found at all.
  35055. */
  35056. getSkeletonByName(name: string): Nullable<Skeleton>;
  35057. /**
  35058. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35059. * @param id defines the id to search for
  35060. * @return the found morph target manager or null if not found at all.
  35061. */
  35062. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35063. /**
  35064. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35065. * @param id defines the id to search for
  35066. * @return the found morph target or null if not found at all.
  35067. */
  35068. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35069. /**
  35070. * Gets a boolean indicating if the given mesh is active
  35071. * @param mesh defines the mesh to look for
  35072. * @returns true if the mesh is in the active list
  35073. */
  35074. isActiveMesh(mesh: AbstractMesh): boolean;
  35075. /**
  35076. * Return a unique id as a string which can serve as an identifier for the scene
  35077. */
  35078. readonly uid: string;
  35079. /**
  35080. * Add an externaly attached data from its key.
  35081. * This method call will fail and return false, if such key already exists.
  35082. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35083. * @param key the unique key that identifies the data
  35084. * @param data the data object to associate to the key for this Engine instance
  35085. * @return true if no such key were already present and the data was added successfully, false otherwise
  35086. */
  35087. addExternalData<T>(key: string, data: T): boolean;
  35088. /**
  35089. * Get an externaly attached data from its key
  35090. * @param key the unique key that identifies the data
  35091. * @return the associated data, if present (can be null), or undefined if not present
  35092. */
  35093. getExternalData<T>(key: string): Nullable<T>;
  35094. /**
  35095. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35096. * @param key the unique key that identifies the data
  35097. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35098. * @return the associated data, can be null if the factory returned null.
  35099. */
  35100. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35101. /**
  35102. * Remove an externaly attached data from the Engine instance
  35103. * @param key the unique key that identifies the data
  35104. * @return true if the data was successfully removed, false if it doesn't exist
  35105. */
  35106. removeExternalData(key: string): boolean;
  35107. private _evaluateSubMesh;
  35108. /**
  35109. * Clear the processed materials smart array preventing retention point in material dispose.
  35110. */
  35111. freeProcessedMaterials(): void;
  35112. private _preventFreeActiveMeshesAndRenderingGroups;
  35113. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35114. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35115. * when disposing several meshes in a row or a hierarchy of meshes.
  35116. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35117. */
  35118. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35119. /**
  35120. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35121. */
  35122. freeActiveMeshes(): void;
  35123. /**
  35124. * Clear the info related to rendering groups preventing retention points during dispose.
  35125. */
  35126. freeRenderingGroups(): void;
  35127. /** @hidden */
  35128. _isInIntermediateRendering(): boolean;
  35129. /**
  35130. * Lambda returning the list of potentially active meshes.
  35131. */
  35132. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35133. /**
  35134. * Lambda returning the list of potentially active sub meshes.
  35135. */
  35136. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35137. /**
  35138. * Lambda returning the list of potentially intersecting sub meshes.
  35139. */
  35140. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35141. /**
  35142. * Lambda returning the list of potentially colliding sub meshes.
  35143. */
  35144. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35145. private _activeMeshesFrozen;
  35146. /**
  35147. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35148. * @returns the current scene
  35149. */
  35150. freezeActiveMeshes(): Scene;
  35151. /**
  35152. * Use this function to restart evaluating active meshes on every frame
  35153. * @returns the current scene
  35154. */
  35155. unfreezeActiveMeshes(): Scene;
  35156. private _evaluateActiveMeshes;
  35157. private _activeMesh;
  35158. /**
  35159. * Update the transform matrix to update from the current active camera
  35160. * @param force defines a boolean used to force the update even if cache is up to date
  35161. */
  35162. updateTransformMatrix(force?: boolean): void;
  35163. private _bindFrameBuffer;
  35164. /** @hidden */
  35165. _allowPostProcessClearColor: boolean;
  35166. /** @hidden */
  35167. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35168. private _processSubCameras;
  35169. private _checkIntersections;
  35170. /** @hidden */
  35171. _advancePhysicsEngineStep(step: number): void;
  35172. /**
  35173. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35174. */
  35175. getDeterministicFrameTime: () => number;
  35176. /** @hidden */
  35177. _animate(): void;
  35178. /** Execute all animations (for a frame) */
  35179. animate(): void;
  35180. /**
  35181. * Render the scene
  35182. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35183. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35184. */
  35185. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35186. /**
  35187. * Freeze all materials
  35188. * A frozen material will not be updatable but should be faster to render
  35189. */
  35190. freezeMaterials(): void;
  35191. /**
  35192. * Unfreeze all materials
  35193. * A frozen material will not be updatable but should be faster to render
  35194. */
  35195. unfreezeMaterials(): void;
  35196. /**
  35197. * Releases all held ressources
  35198. */
  35199. dispose(): void;
  35200. /**
  35201. * Gets if the scene is already disposed
  35202. */
  35203. readonly isDisposed: boolean;
  35204. /**
  35205. * Call this function to reduce memory footprint of the scene.
  35206. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35207. */
  35208. clearCachedVertexData(): void;
  35209. /**
  35210. * This function will remove the local cached buffer data from texture.
  35211. * It will save memory but will prevent the texture from being rebuilt
  35212. */
  35213. cleanCachedTextureBuffer(): void;
  35214. /**
  35215. * Get the world extend vectors with an optional filter
  35216. *
  35217. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35218. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35219. */
  35220. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35221. min: Vector3;
  35222. max: Vector3;
  35223. };
  35224. /**
  35225. * Creates a ray that can be used to pick in the scene
  35226. * @param x defines the x coordinate of the origin (on-screen)
  35227. * @param y defines the y coordinate of the origin (on-screen)
  35228. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35229. * @param camera defines the camera to use for the picking
  35230. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35231. * @returns a Ray
  35232. */
  35233. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35234. /**
  35235. * Creates a ray that can be used to pick in the scene
  35236. * @param x defines the x coordinate of the origin (on-screen)
  35237. * @param y defines the y coordinate of the origin (on-screen)
  35238. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35239. * @param result defines the ray where to store the picking ray
  35240. * @param camera defines the camera to use for the picking
  35241. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35242. * @returns the current scene
  35243. */
  35244. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35245. /**
  35246. * Creates a ray that can be used to pick in the scene
  35247. * @param x defines the x coordinate of the origin (on-screen)
  35248. * @param y defines the y coordinate of the origin (on-screen)
  35249. * @param camera defines the camera to use for the picking
  35250. * @returns a Ray
  35251. */
  35252. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35253. /**
  35254. * Creates a ray that can be used to pick in the scene
  35255. * @param x defines the x coordinate of the origin (on-screen)
  35256. * @param y defines the y coordinate of the origin (on-screen)
  35257. * @param result defines the ray where to store the picking ray
  35258. * @param camera defines the camera to use for the picking
  35259. * @returns the current scene
  35260. */
  35261. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35262. /** Launch a ray to try to pick a mesh in the scene
  35263. * @param x position on screen
  35264. * @param y position on screen
  35265. * @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
  35266. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35267. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35268. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35269. * @returns a PickingInfo
  35270. */
  35271. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35272. /** Use the given ray to pick a mesh in the scene
  35273. * @param ray The ray to use to pick meshes
  35274. * @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
  35275. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35276. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35277. * @returns a PickingInfo
  35278. */
  35279. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35280. /**
  35281. * Launch a ray to try to pick a mesh in the scene
  35282. * @param x X position on screen
  35283. * @param y Y position on screen
  35284. * @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
  35285. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35287. * @returns an array of PickingInfo
  35288. */
  35289. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35290. /**
  35291. * Launch a ray to try to pick a mesh in the scene
  35292. * @param ray Ray to use
  35293. * @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
  35294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35295. * @returns an array of PickingInfo
  35296. */
  35297. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35298. /**
  35299. * Force the value of meshUnderPointer
  35300. * @param mesh defines the mesh to use
  35301. */
  35302. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35303. /**
  35304. * Gets the mesh under the pointer
  35305. * @returns a Mesh or null if no mesh is under the pointer
  35306. */
  35307. getPointerOverMesh(): Nullable<AbstractMesh>;
  35308. /** @hidden */
  35309. _rebuildGeometries(): void;
  35310. /** @hidden */
  35311. _rebuildTextures(): void;
  35312. private _getByTags;
  35313. /**
  35314. * Get a list of meshes by tags
  35315. * @param tagsQuery defines the tags query to use
  35316. * @param forEach defines a predicate used to filter results
  35317. * @returns an array of Mesh
  35318. */
  35319. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35320. /**
  35321. * Get a list of cameras by tags
  35322. * @param tagsQuery defines the tags query to use
  35323. * @param forEach defines a predicate used to filter results
  35324. * @returns an array of Camera
  35325. */
  35326. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35327. /**
  35328. * Get a list of lights by tags
  35329. * @param tagsQuery defines the tags query to use
  35330. * @param forEach defines a predicate used to filter results
  35331. * @returns an array of Light
  35332. */
  35333. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35334. /**
  35335. * Get a list of materials by tags
  35336. * @param tagsQuery defines the tags query to use
  35337. * @param forEach defines a predicate used to filter results
  35338. * @returns an array of Material
  35339. */
  35340. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35341. /**
  35342. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35343. * This allowed control for front to back rendering or reversly depending of the special needs.
  35344. *
  35345. * @param renderingGroupId The rendering group id corresponding to its index
  35346. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35347. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35348. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35349. */
  35350. 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;
  35351. /**
  35352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35353. *
  35354. * @param renderingGroupId The rendering group id corresponding to its index
  35355. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35356. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35357. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35358. */
  35359. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35360. /**
  35361. * Gets the current auto clear configuration for one rendering group of the rendering
  35362. * manager.
  35363. * @param index the rendering group index to get the information for
  35364. * @returns The auto clear setup for the requested rendering group
  35365. */
  35366. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35367. private _blockMaterialDirtyMechanism;
  35368. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35369. blockMaterialDirtyMechanism: boolean;
  35370. /**
  35371. * Will flag all materials as dirty to trigger new shader compilation
  35372. * @param flag defines the flag used to specify which material part must be marked as dirty
  35373. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35374. */
  35375. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35376. /** @hidden */
  35377. _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;
  35378. /** @hidden */
  35379. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35380. }
  35381. }
  35382. declare module "babylonjs/assetContainer" {
  35383. import { AbstractScene } from "babylonjs/abstractScene";
  35384. import { Scene } from "babylonjs/scene";
  35385. import { Mesh } from "babylonjs/Meshes/mesh";
  35386. /**
  35387. * Set of assets to keep when moving a scene into an asset container.
  35388. */
  35389. export class KeepAssets extends AbstractScene {
  35390. }
  35391. /**
  35392. * Container with a set of assets that can be added or removed from a scene.
  35393. */
  35394. export class AssetContainer extends AbstractScene {
  35395. /**
  35396. * The scene the AssetContainer belongs to.
  35397. */
  35398. scene: Scene;
  35399. /**
  35400. * Instantiates an AssetContainer.
  35401. * @param scene The scene the AssetContainer belongs to.
  35402. */
  35403. constructor(scene: Scene);
  35404. /**
  35405. * Adds all the assets from the container to the scene.
  35406. */
  35407. addAllToScene(): void;
  35408. /**
  35409. * Removes all the assets in the container from the scene
  35410. */
  35411. removeAllFromScene(): void;
  35412. /**
  35413. * Disposes all the assets in the container
  35414. */
  35415. dispose(): void;
  35416. private _moveAssets;
  35417. /**
  35418. * Removes all the assets contained in the scene and adds them to the container.
  35419. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35420. */
  35421. moveAllFromScene(keepAssets?: KeepAssets): void;
  35422. /**
  35423. * 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.
  35424. * @returns the root mesh
  35425. */
  35426. createRootMesh(): Mesh;
  35427. }
  35428. }
  35429. declare module "babylonjs/abstractScene" {
  35430. import { Scene } from "babylonjs/scene";
  35431. import { Nullable } from "babylonjs/types";
  35432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35434. import { Geometry } from "babylonjs/Meshes/geometry";
  35435. import { Skeleton } from "babylonjs/Bones/skeleton";
  35436. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35437. import { AssetContainer } from "babylonjs/assetContainer";
  35438. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35439. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35441. import { Material } from "babylonjs/Materials/material";
  35442. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35443. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35444. import { Camera } from "babylonjs/Cameras/camera";
  35445. import { Light } from "babylonjs/Lights/light";
  35446. import { Node } from "babylonjs/node";
  35447. import { Animation } from "babylonjs/Animations/animation";
  35448. /**
  35449. * Defines how the parser contract is defined.
  35450. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35451. */
  35452. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35453. /**
  35454. * Defines how the individual parser contract is defined.
  35455. * These parser can parse an individual asset
  35456. */
  35457. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35458. /**
  35459. * Base class of the scene acting as a container for the different elements composing a scene.
  35460. * This class is dynamically extended by the different components of the scene increasing
  35461. * flexibility and reducing coupling
  35462. */
  35463. export abstract class AbstractScene {
  35464. /**
  35465. * Stores the list of available parsers in the application.
  35466. */
  35467. private static _BabylonFileParsers;
  35468. /**
  35469. * Stores the list of available individual parsers in the application.
  35470. */
  35471. private static _IndividualBabylonFileParsers;
  35472. /**
  35473. * Adds a parser in the list of available ones
  35474. * @param name Defines the name of the parser
  35475. * @param parser Defines the parser to add
  35476. */
  35477. static AddParser(name: string, parser: BabylonFileParser): void;
  35478. /**
  35479. * Gets a general parser from the list of avaialble ones
  35480. * @param name Defines the name of the parser
  35481. * @returns the requested parser or null
  35482. */
  35483. static GetParser(name: string): Nullable<BabylonFileParser>;
  35484. /**
  35485. * Adds n individual parser in the list of available ones
  35486. * @param name Defines the name of the parser
  35487. * @param parser Defines the parser to add
  35488. */
  35489. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35490. /**
  35491. * Gets an individual parser from the list of avaialble ones
  35492. * @param name Defines the name of the parser
  35493. * @returns the requested parser or null
  35494. */
  35495. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35496. /**
  35497. * Parser json data and populate both a scene and its associated container object
  35498. * @param jsonData Defines the data to parse
  35499. * @param scene Defines the scene to parse the data for
  35500. * @param container Defines the container attached to the parsing sequence
  35501. * @param rootUrl Defines the root url of the data
  35502. */
  35503. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35504. /**
  35505. * Gets the list of root nodes (ie. nodes with no parent)
  35506. */
  35507. rootNodes: Node[];
  35508. /** All of the cameras added to this scene
  35509. * @see http://doc.babylonjs.com/babylon101/cameras
  35510. */
  35511. cameras: Camera[];
  35512. /**
  35513. * All of the lights added to this scene
  35514. * @see http://doc.babylonjs.com/babylon101/lights
  35515. */
  35516. lights: Light[];
  35517. /**
  35518. * All of the (abstract) meshes added to this scene
  35519. */
  35520. meshes: AbstractMesh[];
  35521. /**
  35522. * The list of skeletons added to the scene
  35523. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35524. */
  35525. skeletons: Skeleton[];
  35526. /**
  35527. * All of the particle systems added to this scene
  35528. * @see http://doc.babylonjs.com/babylon101/particles
  35529. */
  35530. particleSystems: IParticleSystem[];
  35531. /**
  35532. * Gets a list of Animations associated with the scene
  35533. */
  35534. animations: Animation[];
  35535. /**
  35536. * All of the animation groups added to this scene
  35537. * @see http://doc.babylonjs.com/how_to/group
  35538. */
  35539. animationGroups: AnimationGroup[];
  35540. /**
  35541. * All of the multi-materials added to this scene
  35542. * @see http://doc.babylonjs.com/how_to/multi_materials
  35543. */
  35544. multiMaterials: MultiMaterial[];
  35545. /**
  35546. * All of the materials added to this scene
  35547. * In the context of a Scene, it is not supposed to be modified manually.
  35548. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35549. * Note also that the order of the Material wihin the array is not significant and might change.
  35550. * @see http://doc.babylonjs.com/babylon101/materials
  35551. */
  35552. materials: Material[];
  35553. /**
  35554. * The list of morph target managers added to the scene
  35555. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35556. */
  35557. morphTargetManagers: MorphTargetManager[];
  35558. /**
  35559. * The list of geometries used in the scene.
  35560. */
  35561. geometries: Geometry[];
  35562. /**
  35563. * All of the tranform nodes added to this scene
  35564. * In the context of a Scene, it is not supposed to be modified manually.
  35565. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35566. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35567. * @see http://doc.babylonjs.com/how_to/transformnode
  35568. */
  35569. transformNodes: TransformNode[];
  35570. /**
  35571. * ActionManagers available on the scene.
  35572. */
  35573. actionManagers: AbstractActionManager[];
  35574. /**
  35575. * Textures to keep.
  35576. */
  35577. textures: BaseTexture[];
  35578. /**
  35579. * Environment texture for the scene
  35580. */
  35581. environmentTexture: Nullable<BaseTexture>;
  35582. }
  35583. }
  35584. declare module "babylonjs/Audio/sound" {
  35585. import { Observable } from "babylonjs/Misc/observable";
  35586. import { Vector3 } from "babylonjs/Maths/math.vector";
  35587. import { Nullable } from "babylonjs/types";
  35588. import { Scene } from "babylonjs/scene";
  35589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35590. /**
  35591. * Interface used to define options for Sound class
  35592. */
  35593. export interface ISoundOptions {
  35594. /**
  35595. * Does the sound autoplay once loaded.
  35596. */
  35597. autoplay?: boolean;
  35598. /**
  35599. * Does the sound loop after it finishes playing once.
  35600. */
  35601. loop?: boolean;
  35602. /**
  35603. * Sound's volume
  35604. */
  35605. volume?: number;
  35606. /**
  35607. * Is it a spatial sound?
  35608. */
  35609. spatialSound?: boolean;
  35610. /**
  35611. * Maximum distance to hear that sound
  35612. */
  35613. maxDistance?: number;
  35614. /**
  35615. * Uses user defined attenuation function
  35616. */
  35617. useCustomAttenuation?: boolean;
  35618. /**
  35619. * Define the roll off factor of spatial sounds.
  35620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35621. */
  35622. rolloffFactor?: number;
  35623. /**
  35624. * Define the reference distance the sound should be heard perfectly.
  35625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35626. */
  35627. refDistance?: number;
  35628. /**
  35629. * Define the distance attenuation model the sound will follow.
  35630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35631. */
  35632. distanceModel?: string;
  35633. /**
  35634. * Defines the playback speed (1 by default)
  35635. */
  35636. playbackRate?: number;
  35637. /**
  35638. * Defines if the sound is from a streaming source
  35639. */
  35640. streaming?: boolean;
  35641. /**
  35642. * Defines an optional length (in seconds) inside the sound file
  35643. */
  35644. length?: number;
  35645. /**
  35646. * Defines an optional offset (in seconds) inside the sound file
  35647. */
  35648. offset?: number;
  35649. /**
  35650. * If true, URLs will not be required to state the audio file codec to use.
  35651. */
  35652. skipCodecCheck?: boolean;
  35653. }
  35654. /**
  35655. * Defines a sound that can be played in the application.
  35656. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35658. */
  35659. export class Sound {
  35660. /**
  35661. * The name of the sound in the scene.
  35662. */
  35663. name: string;
  35664. /**
  35665. * Does the sound autoplay once loaded.
  35666. */
  35667. autoplay: boolean;
  35668. /**
  35669. * Does the sound loop after it finishes playing once.
  35670. */
  35671. loop: boolean;
  35672. /**
  35673. * Does the sound use a custom attenuation curve to simulate the falloff
  35674. * happening when the source gets further away from the camera.
  35675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35676. */
  35677. useCustomAttenuation: boolean;
  35678. /**
  35679. * The sound track id this sound belongs to.
  35680. */
  35681. soundTrackId: number;
  35682. /**
  35683. * Is this sound currently played.
  35684. */
  35685. isPlaying: boolean;
  35686. /**
  35687. * Is this sound currently paused.
  35688. */
  35689. isPaused: boolean;
  35690. /**
  35691. * Does this sound enables spatial sound.
  35692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35693. */
  35694. spatialSound: boolean;
  35695. /**
  35696. * Define the reference distance the sound should be heard perfectly.
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35698. */
  35699. refDistance: number;
  35700. /**
  35701. * Define the roll off factor of spatial sounds.
  35702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35703. */
  35704. rolloffFactor: number;
  35705. /**
  35706. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35708. */
  35709. maxDistance: number;
  35710. /**
  35711. * Define the distance attenuation model the sound will follow.
  35712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35713. */
  35714. distanceModel: string;
  35715. /**
  35716. * @hidden
  35717. * Back Compat
  35718. **/
  35719. onended: () => any;
  35720. /**
  35721. * Observable event when the current playing sound finishes.
  35722. */
  35723. onEndedObservable: Observable<Sound>;
  35724. private _panningModel;
  35725. private _playbackRate;
  35726. private _streaming;
  35727. private _startTime;
  35728. private _startOffset;
  35729. private _position;
  35730. /** @hidden */
  35731. _positionInEmitterSpace: boolean;
  35732. private _localDirection;
  35733. private _volume;
  35734. private _isReadyToPlay;
  35735. private _isDirectional;
  35736. private _readyToPlayCallback;
  35737. private _audioBuffer;
  35738. private _soundSource;
  35739. private _streamingSource;
  35740. private _soundPanner;
  35741. private _soundGain;
  35742. private _inputAudioNode;
  35743. private _outputAudioNode;
  35744. private _coneInnerAngle;
  35745. private _coneOuterAngle;
  35746. private _coneOuterGain;
  35747. private _scene;
  35748. private _connectedTransformNode;
  35749. private _customAttenuationFunction;
  35750. private _registerFunc;
  35751. private _isOutputConnected;
  35752. private _htmlAudioElement;
  35753. private _urlType;
  35754. private _length?;
  35755. private _offset?;
  35756. /** @hidden */
  35757. static _SceneComponentInitialization: (scene: Scene) => void;
  35758. /**
  35759. * Create a sound and attach it to a scene
  35760. * @param name Name of your sound
  35761. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35762. * @param scene defines the scene the sound belongs to
  35763. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35764. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35765. */
  35766. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35767. /**
  35768. * Release the sound and its associated resources
  35769. */
  35770. dispose(): void;
  35771. /**
  35772. * Gets if the sounds is ready to be played or not.
  35773. * @returns true if ready, otherwise false
  35774. */
  35775. isReady(): boolean;
  35776. private _soundLoaded;
  35777. /**
  35778. * Sets the data of the sound from an audiobuffer
  35779. * @param audioBuffer The audioBuffer containing the data
  35780. */
  35781. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35782. /**
  35783. * Updates the current sounds options such as maxdistance, loop...
  35784. * @param options A JSON object containing values named as the object properties
  35785. */
  35786. updateOptions(options: ISoundOptions): void;
  35787. private _createSpatialParameters;
  35788. private _updateSpatialParameters;
  35789. /**
  35790. * Switch the panning model to HRTF:
  35791. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35793. */
  35794. switchPanningModelToHRTF(): void;
  35795. /**
  35796. * Switch the panning model to Equal Power:
  35797. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35799. */
  35800. switchPanningModelToEqualPower(): void;
  35801. private _switchPanningModel;
  35802. /**
  35803. * Connect this sound to a sound track audio node like gain...
  35804. * @param soundTrackAudioNode the sound track audio node to connect to
  35805. */
  35806. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35807. /**
  35808. * Transform this sound into a directional source
  35809. * @param coneInnerAngle Size of the inner cone in degree
  35810. * @param coneOuterAngle Size of the outer cone in degree
  35811. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35812. */
  35813. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35814. /**
  35815. * Gets or sets the inner angle for the directional cone.
  35816. */
  35817. /**
  35818. * Gets or sets the inner angle for the directional cone.
  35819. */
  35820. directionalConeInnerAngle: number;
  35821. /**
  35822. * Gets or sets the outer angle for the directional cone.
  35823. */
  35824. /**
  35825. * Gets or sets the outer angle for the directional cone.
  35826. */
  35827. directionalConeOuterAngle: number;
  35828. /**
  35829. * Sets the position of the emitter if spatial sound is enabled
  35830. * @param newPosition Defines the new posisiton
  35831. */
  35832. setPosition(newPosition: Vector3): void;
  35833. /**
  35834. * Sets the local direction of the emitter if spatial sound is enabled
  35835. * @param newLocalDirection Defines the new local direction
  35836. */
  35837. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35838. private _updateDirection;
  35839. /** @hidden */
  35840. updateDistanceFromListener(): void;
  35841. /**
  35842. * Sets a new custom attenuation function for the sound.
  35843. * @param callback Defines the function used for the attenuation
  35844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35845. */
  35846. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35847. /**
  35848. * Play the sound
  35849. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35850. * @param offset (optional) Start the sound at a specific time in seconds
  35851. * @param length (optional) Sound duration (in seconds)
  35852. */
  35853. play(time?: number, offset?: number, length?: number): void;
  35854. private _onended;
  35855. /**
  35856. * Stop the sound
  35857. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35858. */
  35859. stop(time?: number): void;
  35860. /**
  35861. * Put the sound in pause
  35862. */
  35863. pause(): void;
  35864. /**
  35865. * Sets a dedicated volume for this sounds
  35866. * @param newVolume Define the new volume of the sound
  35867. * @param time Define time for gradual change to new volume
  35868. */
  35869. setVolume(newVolume: number, time?: number): void;
  35870. /**
  35871. * Set the sound play back rate
  35872. * @param newPlaybackRate Define the playback rate the sound should be played at
  35873. */
  35874. setPlaybackRate(newPlaybackRate: number): void;
  35875. /**
  35876. * Gets the volume of the sound.
  35877. * @returns the volume of the sound
  35878. */
  35879. getVolume(): number;
  35880. /**
  35881. * Attach the sound to a dedicated mesh
  35882. * @param transformNode The transform node to connect the sound with
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35884. */
  35885. attachToMesh(transformNode: TransformNode): void;
  35886. /**
  35887. * Detach the sound from the previously attached mesh
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35889. */
  35890. detachFromMesh(): void;
  35891. private _onRegisterAfterWorldMatrixUpdate;
  35892. /**
  35893. * Clone the current sound in the scene.
  35894. * @returns the new sound clone
  35895. */
  35896. clone(): Nullable<Sound>;
  35897. /**
  35898. * Gets the current underlying audio buffer containing the data
  35899. * @returns the audio buffer
  35900. */
  35901. getAudioBuffer(): Nullable<AudioBuffer>;
  35902. /**
  35903. * Serializes the Sound in a JSON representation
  35904. * @returns the JSON representation of the sound
  35905. */
  35906. serialize(): any;
  35907. /**
  35908. * Parse a JSON representation of a sound to innstantiate in a given scene
  35909. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35910. * @param scene Define the scene the new parsed sound should be created in
  35911. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35912. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35913. * @returns the newly parsed sound
  35914. */
  35915. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35916. }
  35917. }
  35918. declare module "babylonjs/Actions/directAudioActions" {
  35919. import { Action } from "babylonjs/Actions/action";
  35920. import { Condition } from "babylonjs/Actions/condition";
  35921. import { Sound } from "babylonjs/Audio/sound";
  35922. /**
  35923. * This defines an action helpful to play a defined sound on a triggered action.
  35924. */
  35925. export class PlaySoundAction extends Action {
  35926. private _sound;
  35927. /**
  35928. * Instantiate the action
  35929. * @param triggerOptions defines the trigger options
  35930. * @param sound defines the sound to play
  35931. * @param condition defines the trigger related conditions
  35932. */
  35933. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35934. /** @hidden */
  35935. _prepare(): void;
  35936. /**
  35937. * Execute the action and play the sound.
  35938. */
  35939. execute(): void;
  35940. /**
  35941. * Serializes the actions and its related information.
  35942. * @param parent defines the object to serialize in
  35943. * @returns the serialized object
  35944. */
  35945. serialize(parent: any): any;
  35946. }
  35947. /**
  35948. * This defines an action helpful to stop a defined sound on a triggered action.
  35949. */
  35950. export class StopSoundAction extends Action {
  35951. private _sound;
  35952. /**
  35953. * Instantiate the action
  35954. * @param triggerOptions defines the trigger options
  35955. * @param sound defines the sound to stop
  35956. * @param condition defines the trigger related conditions
  35957. */
  35958. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35959. /** @hidden */
  35960. _prepare(): void;
  35961. /**
  35962. * Execute the action and stop the sound.
  35963. */
  35964. execute(): void;
  35965. /**
  35966. * Serializes the actions and its related information.
  35967. * @param parent defines the object to serialize in
  35968. * @returns the serialized object
  35969. */
  35970. serialize(parent: any): any;
  35971. }
  35972. }
  35973. declare module "babylonjs/Actions/interpolateValueAction" {
  35974. import { Action } from "babylonjs/Actions/action";
  35975. import { Condition } from "babylonjs/Actions/condition";
  35976. import { Observable } from "babylonjs/Misc/observable";
  35977. /**
  35978. * This defines an action responsible to change the value of a property
  35979. * by interpolating between its current value and the newly set one once triggered.
  35980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35981. */
  35982. export class InterpolateValueAction extends Action {
  35983. /**
  35984. * Defines the path of the property where the value should be interpolated
  35985. */
  35986. propertyPath: string;
  35987. /**
  35988. * Defines the target value at the end of the interpolation.
  35989. */
  35990. value: any;
  35991. /**
  35992. * Defines the time it will take for the property to interpolate to the value.
  35993. */
  35994. duration: number;
  35995. /**
  35996. * Defines if the other scene animations should be stopped when the action has been triggered
  35997. */
  35998. stopOtherAnimations?: boolean;
  35999. /**
  36000. * Defines a callback raised once the interpolation animation has been done.
  36001. */
  36002. onInterpolationDone?: () => void;
  36003. /**
  36004. * Observable triggered once the interpolation animation has been done.
  36005. */
  36006. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36007. private _target;
  36008. private _effectiveTarget;
  36009. private _property;
  36010. /**
  36011. * Instantiate the action
  36012. * @param triggerOptions defines the trigger options
  36013. * @param target defines the object containing the value to interpolate
  36014. * @param propertyPath defines the path to the property in the target object
  36015. * @param value defines the target value at the end of the interpolation
  36016. * @param duration deines the time it will take for the property to interpolate to the value.
  36017. * @param condition defines the trigger related conditions
  36018. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36019. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36020. */
  36021. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36022. /** @hidden */
  36023. _prepare(): void;
  36024. /**
  36025. * Execute the action starts the value interpolation.
  36026. */
  36027. execute(): void;
  36028. /**
  36029. * Serializes the actions and its related information.
  36030. * @param parent defines the object to serialize in
  36031. * @returns the serialized object
  36032. */
  36033. serialize(parent: any): any;
  36034. }
  36035. }
  36036. declare module "babylonjs/Actions/index" {
  36037. export * from "babylonjs/Actions/action";
  36038. export * from "babylonjs/Actions/actionEvent";
  36039. export * from "babylonjs/Actions/actionManager";
  36040. export * from "babylonjs/Actions/condition";
  36041. export * from "babylonjs/Actions/directActions";
  36042. export * from "babylonjs/Actions/directAudioActions";
  36043. export * from "babylonjs/Actions/interpolateValueAction";
  36044. }
  36045. declare module "babylonjs/Animations/index" {
  36046. export * from "babylonjs/Animations/animatable";
  36047. export * from "babylonjs/Animations/animation";
  36048. export * from "babylonjs/Animations/animationGroup";
  36049. export * from "babylonjs/Animations/animationPropertiesOverride";
  36050. export * from "babylonjs/Animations/easing";
  36051. export * from "babylonjs/Animations/runtimeAnimation";
  36052. export * from "babylonjs/Animations/animationEvent";
  36053. export * from "babylonjs/Animations/animationGroup";
  36054. export * from "babylonjs/Animations/animationKey";
  36055. export * from "babylonjs/Animations/animationRange";
  36056. export * from "babylonjs/Animations/animatable.interface";
  36057. }
  36058. declare module "babylonjs/Audio/soundTrack" {
  36059. import { Sound } from "babylonjs/Audio/sound";
  36060. import { Analyser } from "babylonjs/Audio/analyser";
  36061. import { Scene } from "babylonjs/scene";
  36062. /**
  36063. * Options allowed during the creation of a sound track.
  36064. */
  36065. export interface ISoundTrackOptions {
  36066. /**
  36067. * The volume the sound track should take during creation
  36068. */
  36069. volume?: number;
  36070. /**
  36071. * Define if the sound track is the main sound track of the scene
  36072. */
  36073. mainTrack?: boolean;
  36074. }
  36075. /**
  36076. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36077. * It will be also used in a future release to apply effects on a specific track.
  36078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36079. */
  36080. export class SoundTrack {
  36081. /**
  36082. * The unique identifier of the sound track in the scene.
  36083. */
  36084. id: number;
  36085. /**
  36086. * The list of sounds included in the sound track.
  36087. */
  36088. soundCollection: Array<Sound>;
  36089. private _outputAudioNode;
  36090. private _scene;
  36091. private _isMainTrack;
  36092. private _connectedAnalyser;
  36093. private _options;
  36094. private _isInitialized;
  36095. /**
  36096. * Creates a new sound track.
  36097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36098. * @param scene Define the scene the sound track belongs to
  36099. * @param options
  36100. */
  36101. constructor(scene: Scene, options?: ISoundTrackOptions);
  36102. private _initializeSoundTrackAudioGraph;
  36103. /**
  36104. * Release the sound track and its associated resources
  36105. */
  36106. dispose(): void;
  36107. /**
  36108. * Adds a sound to this sound track
  36109. * @param sound define the cound to add
  36110. * @ignoreNaming
  36111. */
  36112. AddSound(sound: Sound): void;
  36113. /**
  36114. * Removes a sound to this sound track
  36115. * @param sound define the cound to remove
  36116. * @ignoreNaming
  36117. */
  36118. RemoveSound(sound: Sound): void;
  36119. /**
  36120. * Set a global volume for the full sound track.
  36121. * @param newVolume Define the new volume of the sound track
  36122. */
  36123. setVolume(newVolume: number): void;
  36124. /**
  36125. * Switch the panning model to HRTF:
  36126. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36128. */
  36129. switchPanningModelToHRTF(): void;
  36130. /**
  36131. * Switch the panning model to Equal Power:
  36132. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36134. */
  36135. switchPanningModelToEqualPower(): void;
  36136. /**
  36137. * Connect the sound track to an audio analyser allowing some amazing
  36138. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36140. * @param analyser The analyser to connect to the engine
  36141. */
  36142. connectToAnalyser(analyser: Analyser): void;
  36143. }
  36144. }
  36145. declare module "babylonjs/Audio/audioSceneComponent" {
  36146. import { Sound } from "babylonjs/Audio/sound";
  36147. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36148. import { Nullable } from "babylonjs/types";
  36149. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36150. import { Scene } from "babylonjs/scene";
  36151. import { AbstractScene } from "babylonjs/abstractScene";
  36152. import "babylonjs/Audio/audioEngine";
  36153. module "babylonjs/abstractScene" {
  36154. interface AbstractScene {
  36155. /**
  36156. * The list of sounds used in the scene.
  36157. */
  36158. sounds: Nullable<Array<Sound>>;
  36159. }
  36160. }
  36161. module "babylonjs/scene" {
  36162. interface Scene {
  36163. /**
  36164. * @hidden
  36165. * Backing field
  36166. */
  36167. _mainSoundTrack: SoundTrack;
  36168. /**
  36169. * The main sound track played by the scene.
  36170. * It cotains your primary collection of sounds.
  36171. */
  36172. mainSoundTrack: SoundTrack;
  36173. /**
  36174. * The list of sound tracks added to the scene
  36175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36176. */
  36177. soundTracks: Nullable<Array<SoundTrack>>;
  36178. /**
  36179. * Gets a sound using a given name
  36180. * @param name defines the name to search for
  36181. * @return the found sound or null if not found at all.
  36182. */
  36183. getSoundByName(name: string): Nullable<Sound>;
  36184. /**
  36185. * Gets or sets if audio support is enabled
  36186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36187. */
  36188. audioEnabled: boolean;
  36189. /**
  36190. * Gets or sets if audio will be output to headphones
  36191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36192. */
  36193. headphone: boolean;
  36194. }
  36195. }
  36196. /**
  36197. * Defines the sound scene component responsible to manage any sounds
  36198. * in a given scene.
  36199. */
  36200. export class AudioSceneComponent implements ISceneSerializableComponent {
  36201. /**
  36202. * The component name helpfull to identify the component in the list of scene components.
  36203. */
  36204. readonly name: string;
  36205. /**
  36206. * The scene the component belongs to.
  36207. */
  36208. scene: Scene;
  36209. private _audioEnabled;
  36210. /**
  36211. * Gets whether audio is enabled or not.
  36212. * Please use related enable/disable method to switch state.
  36213. */
  36214. readonly audioEnabled: boolean;
  36215. private _headphone;
  36216. /**
  36217. * Gets whether audio is outputing to headphone or not.
  36218. * Please use the according Switch methods to change output.
  36219. */
  36220. readonly headphone: boolean;
  36221. /**
  36222. * Creates a new instance of the component for the given scene
  36223. * @param scene Defines the scene to register the component in
  36224. */
  36225. constructor(scene: Scene);
  36226. /**
  36227. * Registers the component in a given scene
  36228. */
  36229. register(): void;
  36230. /**
  36231. * Rebuilds the elements related to this component in case of
  36232. * context lost for instance.
  36233. */
  36234. rebuild(): void;
  36235. /**
  36236. * Serializes the component data to the specified json object
  36237. * @param serializationObject The object to serialize to
  36238. */
  36239. serialize(serializationObject: any): void;
  36240. /**
  36241. * Adds all the elements from the container to the scene
  36242. * @param container the container holding the elements
  36243. */
  36244. addFromContainer(container: AbstractScene): void;
  36245. /**
  36246. * Removes all the elements in the container from the scene
  36247. * @param container contains the elements to remove
  36248. * @param dispose if the removed element should be disposed (default: false)
  36249. */
  36250. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36251. /**
  36252. * Disposes the component and the associated ressources.
  36253. */
  36254. dispose(): void;
  36255. /**
  36256. * Disables audio in the associated scene.
  36257. */
  36258. disableAudio(): void;
  36259. /**
  36260. * Enables audio in the associated scene.
  36261. */
  36262. enableAudio(): void;
  36263. /**
  36264. * Switch audio to headphone output.
  36265. */
  36266. switchAudioModeForHeadphones(): void;
  36267. /**
  36268. * Switch audio to normal speakers.
  36269. */
  36270. switchAudioModeForNormalSpeakers(): void;
  36271. private _afterRender;
  36272. }
  36273. }
  36274. declare module "babylonjs/Audio/weightedsound" {
  36275. import { Sound } from "babylonjs/Audio/sound";
  36276. /**
  36277. * Wraps one or more Sound objects and selects one with random weight for playback.
  36278. */
  36279. export class WeightedSound {
  36280. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36281. loop: boolean;
  36282. private _coneInnerAngle;
  36283. private _coneOuterAngle;
  36284. private _volume;
  36285. /** A Sound is currently playing. */
  36286. isPlaying: boolean;
  36287. /** A Sound is currently paused. */
  36288. isPaused: boolean;
  36289. private _sounds;
  36290. private _weights;
  36291. private _currentIndex?;
  36292. /**
  36293. * Creates a new WeightedSound from the list of sounds given.
  36294. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36295. * @param sounds Array of Sounds that will be selected from.
  36296. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36297. */
  36298. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36299. /**
  36300. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36301. */
  36302. /**
  36303. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36304. */
  36305. directionalConeInnerAngle: number;
  36306. /**
  36307. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36308. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36309. */
  36310. /**
  36311. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36312. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36313. */
  36314. directionalConeOuterAngle: number;
  36315. /**
  36316. * Playback volume.
  36317. */
  36318. /**
  36319. * Playback volume.
  36320. */
  36321. volume: number;
  36322. private _onended;
  36323. /**
  36324. * Suspend playback
  36325. */
  36326. pause(): void;
  36327. /**
  36328. * Stop playback
  36329. */
  36330. stop(): void;
  36331. /**
  36332. * Start playback.
  36333. * @param startOffset Position the clip head at a specific time in seconds.
  36334. */
  36335. play(startOffset?: number): void;
  36336. }
  36337. }
  36338. declare module "babylonjs/Audio/index" {
  36339. export * from "babylonjs/Audio/analyser";
  36340. export * from "babylonjs/Audio/audioEngine";
  36341. export * from "babylonjs/Audio/audioSceneComponent";
  36342. export * from "babylonjs/Audio/sound";
  36343. export * from "babylonjs/Audio/soundTrack";
  36344. export * from "babylonjs/Audio/weightedsound";
  36345. }
  36346. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36347. import { Behavior } from "babylonjs/Behaviors/behavior";
  36348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36349. import { BackEase } from "babylonjs/Animations/easing";
  36350. /**
  36351. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36353. */
  36354. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36355. /**
  36356. * Gets the name of the behavior.
  36357. */
  36358. readonly name: string;
  36359. /**
  36360. * The easing function used by animations
  36361. */
  36362. static EasingFunction: BackEase;
  36363. /**
  36364. * The easing mode used by animations
  36365. */
  36366. static EasingMode: number;
  36367. /**
  36368. * The duration of the animation, in milliseconds
  36369. */
  36370. transitionDuration: number;
  36371. /**
  36372. * Length of the distance animated by the transition when lower radius is reached
  36373. */
  36374. lowerRadiusTransitionRange: number;
  36375. /**
  36376. * Length of the distance animated by the transition when upper radius is reached
  36377. */
  36378. upperRadiusTransitionRange: number;
  36379. private _autoTransitionRange;
  36380. /**
  36381. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36382. */
  36383. /**
  36384. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36385. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36386. */
  36387. autoTransitionRange: boolean;
  36388. private _attachedCamera;
  36389. private _onAfterCheckInputsObserver;
  36390. private _onMeshTargetChangedObserver;
  36391. /**
  36392. * Initializes the behavior.
  36393. */
  36394. init(): void;
  36395. /**
  36396. * Attaches the behavior to its arc rotate camera.
  36397. * @param camera Defines the camera to attach the behavior to
  36398. */
  36399. attach(camera: ArcRotateCamera): void;
  36400. /**
  36401. * Detaches the behavior from its current arc rotate camera.
  36402. */
  36403. detach(): void;
  36404. private _radiusIsAnimating;
  36405. private _radiusBounceTransition;
  36406. private _animatables;
  36407. private _cachedWheelPrecision;
  36408. /**
  36409. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36410. * @param radiusLimit The limit to check against.
  36411. * @return Bool to indicate if at limit.
  36412. */
  36413. private _isRadiusAtLimit;
  36414. /**
  36415. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36416. * @param radiusDelta The delta by which to animate to. Can be negative.
  36417. */
  36418. private _applyBoundRadiusAnimation;
  36419. /**
  36420. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36421. */
  36422. protected _clearAnimationLocks(): void;
  36423. /**
  36424. * Stops and removes all animations that have been applied to the camera
  36425. */
  36426. stopAllAnimations(): void;
  36427. }
  36428. }
  36429. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36430. import { Behavior } from "babylonjs/Behaviors/behavior";
  36431. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36432. import { ExponentialEase } from "babylonjs/Animations/easing";
  36433. import { Nullable } from "babylonjs/types";
  36434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36435. import { Vector3 } from "babylonjs/Maths/math.vector";
  36436. /**
  36437. * 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.
  36438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36439. */
  36440. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36441. /**
  36442. * Gets the name of the behavior.
  36443. */
  36444. readonly name: string;
  36445. private _mode;
  36446. private _radiusScale;
  36447. private _positionScale;
  36448. private _defaultElevation;
  36449. private _elevationReturnTime;
  36450. private _elevationReturnWaitTime;
  36451. private _zoomStopsAnimation;
  36452. private _framingTime;
  36453. /**
  36454. * The easing function used by animations
  36455. */
  36456. static EasingFunction: ExponentialEase;
  36457. /**
  36458. * The easing mode used by animations
  36459. */
  36460. static EasingMode: number;
  36461. /**
  36462. * Sets the current mode used by the behavior
  36463. */
  36464. /**
  36465. * Gets current mode used by the behavior.
  36466. */
  36467. mode: number;
  36468. /**
  36469. * Sets the scale applied to the radius (1 by default)
  36470. */
  36471. /**
  36472. * Gets the scale applied to the radius
  36473. */
  36474. radiusScale: number;
  36475. /**
  36476. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36477. */
  36478. /**
  36479. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36480. */
  36481. positionScale: number;
  36482. /**
  36483. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36484. * behaviour is triggered, in radians.
  36485. */
  36486. /**
  36487. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36488. * behaviour is triggered, in radians.
  36489. */
  36490. defaultElevation: number;
  36491. /**
  36492. * Sets the time (in milliseconds) taken to return to the default beta position.
  36493. * Negative value indicates camera should not return to default.
  36494. */
  36495. /**
  36496. * Gets the time (in milliseconds) taken to return to the default beta position.
  36497. * Negative value indicates camera should not return to default.
  36498. */
  36499. elevationReturnTime: number;
  36500. /**
  36501. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36502. */
  36503. /**
  36504. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36505. */
  36506. elevationReturnWaitTime: number;
  36507. /**
  36508. * Sets the flag that indicates if user zooming should stop animation.
  36509. */
  36510. /**
  36511. * Gets the flag that indicates if user zooming should stop animation.
  36512. */
  36513. zoomStopsAnimation: boolean;
  36514. /**
  36515. * Sets the transition time when framing the mesh, in milliseconds
  36516. */
  36517. /**
  36518. * Gets the transition time when framing the mesh, in milliseconds
  36519. */
  36520. framingTime: number;
  36521. /**
  36522. * Define if the behavior should automatically change the configured
  36523. * camera limits and sensibilities.
  36524. */
  36525. autoCorrectCameraLimitsAndSensibility: boolean;
  36526. private _onPrePointerObservableObserver;
  36527. private _onAfterCheckInputsObserver;
  36528. private _onMeshTargetChangedObserver;
  36529. private _attachedCamera;
  36530. private _isPointerDown;
  36531. private _lastInteractionTime;
  36532. /**
  36533. * Initializes the behavior.
  36534. */
  36535. init(): void;
  36536. /**
  36537. * Attaches the behavior to its arc rotate camera.
  36538. * @param camera Defines the camera to attach the behavior to
  36539. */
  36540. attach(camera: ArcRotateCamera): void;
  36541. /**
  36542. * Detaches the behavior from its current arc rotate camera.
  36543. */
  36544. detach(): void;
  36545. private _animatables;
  36546. private _betaIsAnimating;
  36547. private _betaTransition;
  36548. private _radiusTransition;
  36549. private _vectorTransition;
  36550. /**
  36551. * Targets the given mesh and updates zoom level accordingly.
  36552. * @param mesh The mesh to target.
  36553. * @param radius Optional. If a cached radius position already exists, overrides default.
  36554. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36555. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36556. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36557. */
  36558. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36559. /**
  36560. * Targets the given mesh with its children and updates zoom level accordingly.
  36561. * @param mesh The mesh to target.
  36562. * @param radius Optional. If a cached radius position already exists, overrides default.
  36563. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36564. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36565. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36566. */
  36567. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36568. /**
  36569. * Targets the given meshes with their children and updates zoom level accordingly.
  36570. * @param meshes The mesh to target.
  36571. * @param radius Optional. If a cached radius position already exists, overrides default.
  36572. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36575. */
  36576. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36577. /**
  36578. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36579. * @param minimumWorld Determines the smaller position of the bounding box extend
  36580. * @param maximumWorld Determines the bigger position of the bounding box extend
  36581. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36582. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36583. */
  36584. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36585. /**
  36586. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36587. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36588. * frustum width.
  36589. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36590. * to fully enclose the mesh in the viewing frustum.
  36591. */
  36592. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36593. /**
  36594. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36595. * is automatically returned to its default position (expected to be above ground plane).
  36596. */
  36597. private _maintainCameraAboveGround;
  36598. /**
  36599. * Returns the frustum slope based on the canvas ratio and camera FOV
  36600. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36601. */
  36602. private _getFrustumSlope;
  36603. /**
  36604. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36605. */
  36606. private _clearAnimationLocks;
  36607. /**
  36608. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36609. */
  36610. private _applyUserInteraction;
  36611. /**
  36612. * Stops and removes all animations that have been applied to the camera
  36613. */
  36614. stopAllAnimations(): void;
  36615. /**
  36616. * Gets a value indicating if the user is moving the camera
  36617. */
  36618. readonly isUserIsMoving: boolean;
  36619. /**
  36620. * The camera can move all the way towards the mesh.
  36621. */
  36622. static IgnoreBoundsSizeMode: number;
  36623. /**
  36624. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36625. */
  36626. static FitFrustumSidesMode: number;
  36627. }
  36628. }
  36629. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36630. import { Nullable } from "babylonjs/types";
  36631. import { Camera } from "babylonjs/Cameras/camera";
  36632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36633. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36634. /**
  36635. * Base class for Camera Pointer Inputs.
  36636. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36637. * for example usage.
  36638. */
  36639. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36640. /**
  36641. * Defines the camera the input is attached to.
  36642. */
  36643. abstract camera: Camera;
  36644. /**
  36645. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36646. */
  36647. protected _altKey: boolean;
  36648. protected _ctrlKey: boolean;
  36649. protected _metaKey: boolean;
  36650. protected _shiftKey: boolean;
  36651. /**
  36652. * Which mouse buttons were pressed at time of last mouse event.
  36653. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36654. */
  36655. protected _buttonsPressed: number;
  36656. /**
  36657. * Defines the buttons associated with the input to handle camera move.
  36658. */
  36659. buttons: number[];
  36660. /**
  36661. * Attach the input controls to a specific dom element to get the input from.
  36662. * @param element Defines the element the controls should be listened from
  36663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36664. */
  36665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36666. /**
  36667. * Detach the current controls from the specified dom element.
  36668. * @param element Defines the element to stop listening the inputs from
  36669. */
  36670. detachControl(element: Nullable<HTMLElement>): void;
  36671. /**
  36672. * Gets the class name of the current input.
  36673. * @returns the class name
  36674. */
  36675. getClassName(): string;
  36676. /**
  36677. * Get the friendly name associated with the input class.
  36678. * @returns the input friendly name
  36679. */
  36680. getSimpleName(): string;
  36681. /**
  36682. * Called on pointer POINTERDOUBLETAP event.
  36683. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36684. */
  36685. protected onDoubleTap(type: string): void;
  36686. /**
  36687. * Called on pointer POINTERMOVE event if only a single touch is active.
  36688. * Override this method to provide functionality.
  36689. */
  36690. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36691. /**
  36692. * Called on pointer POINTERMOVE event if multiple touches are active.
  36693. * Override this method to provide functionality.
  36694. */
  36695. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36696. /**
  36697. * Called on JS contextmenu event.
  36698. * Override this method to provide functionality.
  36699. */
  36700. protected onContextMenu(evt: PointerEvent): void;
  36701. /**
  36702. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36703. * press.
  36704. * Override this method to provide functionality.
  36705. */
  36706. protected onButtonDown(evt: PointerEvent): void;
  36707. /**
  36708. * Called each time a new POINTERUP event occurs. Ie, for each button
  36709. * release.
  36710. * Override this method to provide functionality.
  36711. */
  36712. protected onButtonUp(evt: PointerEvent): void;
  36713. /**
  36714. * Called when window becomes inactive.
  36715. * Override this method to provide functionality.
  36716. */
  36717. protected onLostFocus(): void;
  36718. private _pointerInput;
  36719. private _observer;
  36720. private _onLostFocus;
  36721. private pointA;
  36722. private pointB;
  36723. }
  36724. }
  36725. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36726. import { Nullable } from "babylonjs/types";
  36727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36728. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36729. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36730. /**
  36731. * Manage the pointers inputs to control an arc rotate camera.
  36732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36733. */
  36734. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36735. /**
  36736. * Defines the camera the input is attached to.
  36737. */
  36738. camera: ArcRotateCamera;
  36739. /**
  36740. * Gets the class name of the current input.
  36741. * @returns the class name
  36742. */
  36743. getClassName(): string;
  36744. /**
  36745. * Defines the buttons associated with the input to handle camera move.
  36746. */
  36747. buttons: number[];
  36748. /**
  36749. * Defines the pointer angular sensibility along the X axis or how fast is
  36750. * the camera rotating.
  36751. */
  36752. angularSensibilityX: number;
  36753. /**
  36754. * Defines the pointer angular sensibility along the Y axis or how fast is
  36755. * the camera rotating.
  36756. */
  36757. angularSensibilityY: number;
  36758. /**
  36759. * Defines the pointer pinch precision or how fast is the camera zooming.
  36760. */
  36761. pinchPrecision: number;
  36762. /**
  36763. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36764. * from 0.
  36765. * It defines the percentage of current camera.radius to use as delta when
  36766. * pinch zoom is used.
  36767. */
  36768. pinchDeltaPercentage: number;
  36769. /**
  36770. * Defines the pointer panning sensibility or how fast is the camera moving.
  36771. */
  36772. panningSensibility: number;
  36773. /**
  36774. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36775. */
  36776. multiTouchPanning: boolean;
  36777. /**
  36778. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36779. * zoom (pinch) through multitouch.
  36780. */
  36781. multiTouchPanAndZoom: boolean;
  36782. /**
  36783. * Revers pinch action direction.
  36784. */
  36785. pinchInwards: boolean;
  36786. private _isPanClick;
  36787. private _twoFingerActivityCount;
  36788. private _isPinching;
  36789. /**
  36790. * Called on pointer POINTERMOVE event if only a single touch is active.
  36791. */
  36792. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36793. /**
  36794. * Called on pointer POINTERDOUBLETAP event.
  36795. */
  36796. protected onDoubleTap(type: string): void;
  36797. /**
  36798. * Called on pointer POINTERMOVE event if multiple touches are active.
  36799. */
  36800. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36801. /**
  36802. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36803. * press.
  36804. */
  36805. protected onButtonDown(evt: PointerEvent): void;
  36806. /**
  36807. * Called each time a new POINTERUP event occurs. Ie, for each button
  36808. * release.
  36809. */
  36810. protected onButtonUp(evt: PointerEvent): void;
  36811. /**
  36812. * Called when window becomes inactive.
  36813. */
  36814. protected onLostFocus(): void;
  36815. }
  36816. }
  36817. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36818. import { Nullable } from "babylonjs/types";
  36819. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36820. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36821. /**
  36822. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36824. */
  36825. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36826. /**
  36827. * Defines the camera the input is attached to.
  36828. */
  36829. camera: ArcRotateCamera;
  36830. /**
  36831. * Defines the list of key codes associated with the up action (increase alpha)
  36832. */
  36833. keysUp: number[];
  36834. /**
  36835. * Defines the list of key codes associated with the down action (decrease alpha)
  36836. */
  36837. keysDown: number[];
  36838. /**
  36839. * Defines the list of key codes associated with the left action (increase beta)
  36840. */
  36841. keysLeft: number[];
  36842. /**
  36843. * Defines the list of key codes associated with the right action (decrease beta)
  36844. */
  36845. keysRight: number[];
  36846. /**
  36847. * Defines the list of key codes associated with the reset action.
  36848. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36849. */
  36850. keysReset: number[];
  36851. /**
  36852. * Defines the panning sensibility of the inputs.
  36853. * (How fast is the camera paning)
  36854. */
  36855. panningSensibility: number;
  36856. /**
  36857. * Defines the zooming sensibility of the inputs.
  36858. * (How fast is the camera zooming)
  36859. */
  36860. zoomingSensibility: number;
  36861. /**
  36862. * Defines wether maintaining the alt key down switch the movement mode from
  36863. * orientation to zoom.
  36864. */
  36865. useAltToZoom: boolean;
  36866. /**
  36867. * Rotation speed of the camera
  36868. */
  36869. angularSpeed: number;
  36870. private _keys;
  36871. private _ctrlPressed;
  36872. private _altPressed;
  36873. private _onCanvasBlurObserver;
  36874. private _onKeyboardObserver;
  36875. private _engine;
  36876. private _scene;
  36877. /**
  36878. * Attach the input controls to a specific dom element to get the input from.
  36879. * @param element Defines the element the controls should be listened from
  36880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36881. */
  36882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36883. /**
  36884. * Detach the current controls from the specified dom element.
  36885. * @param element Defines the element to stop listening the inputs from
  36886. */
  36887. detachControl(element: Nullable<HTMLElement>): void;
  36888. /**
  36889. * Update the current camera state depending on the inputs that have been used this frame.
  36890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36891. */
  36892. checkInputs(): void;
  36893. /**
  36894. * Gets the class name of the current intput.
  36895. * @returns the class name
  36896. */
  36897. getClassName(): string;
  36898. /**
  36899. * Get the friendly name associated with the input class.
  36900. * @returns the input friendly name
  36901. */
  36902. getSimpleName(): string;
  36903. }
  36904. }
  36905. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36906. import { Nullable } from "babylonjs/types";
  36907. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36909. /**
  36910. * Manage the mouse wheel inputs to control an arc rotate camera.
  36911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36912. */
  36913. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36914. /**
  36915. * Defines the camera the input is attached to.
  36916. */
  36917. camera: ArcRotateCamera;
  36918. /**
  36919. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36920. */
  36921. wheelPrecision: number;
  36922. /**
  36923. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36924. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36925. */
  36926. wheelDeltaPercentage: number;
  36927. private _wheel;
  36928. private _observer;
  36929. private computeDeltaFromMouseWheelLegacyEvent;
  36930. /**
  36931. * Attach the input controls to a specific dom element to get the input from.
  36932. * @param element Defines the element the controls should be listened from
  36933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36934. */
  36935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36936. /**
  36937. * Detach the current controls from the specified dom element.
  36938. * @param element Defines the element to stop listening the inputs from
  36939. */
  36940. detachControl(element: Nullable<HTMLElement>): void;
  36941. /**
  36942. * Gets the class name of the current intput.
  36943. * @returns the class name
  36944. */
  36945. getClassName(): string;
  36946. /**
  36947. * Get the friendly name associated with the input class.
  36948. * @returns the input friendly name
  36949. */
  36950. getSimpleName(): string;
  36951. }
  36952. }
  36953. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36954. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36955. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36956. /**
  36957. * Default Inputs manager for the ArcRotateCamera.
  36958. * It groups all the default supported inputs for ease of use.
  36959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36960. */
  36961. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36962. /**
  36963. * Instantiates a new ArcRotateCameraInputsManager.
  36964. * @param camera Defines the camera the inputs belong to
  36965. */
  36966. constructor(camera: ArcRotateCamera);
  36967. /**
  36968. * Add mouse wheel input support to the input manager.
  36969. * @returns the current input manager
  36970. */
  36971. addMouseWheel(): ArcRotateCameraInputsManager;
  36972. /**
  36973. * Add pointers input support to the input manager.
  36974. * @returns the current input manager
  36975. */
  36976. addPointers(): ArcRotateCameraInputsManager;
  36977. /**
  36978. * Add keyboard input support to the input manager.
  36979. * @returns the current input manager
  36980. */
  36981. addKeyboard(): ArcRotateCameraInputsManager;
  36982. }
  36983. }
  36984. declare module "babylonjs/Cameras/arcRotateCamera" {
  36985. import { Observable } from "babylonjs/Misc/observable";
  36986. import { Nullable } from "babylonjs/types";
  36987. import { Scene } from "babylonjs/scene";
  36988. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36990. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36991. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36992. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36993. import { Camera } from "babylonjs/Cameras/camera";
  36994. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36995. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36996. import { Collider } from "babylonjs/Collisions/collider";
  36997. /**
  36998. * This represents an orbital type of camera.
  36999. *
  37000. * 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.
  37001. * 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.
  37002. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37003. */
  37004. export class ArcRotateCamera extends TargetCamera {
  37005. /**
  37006. * Defines the rotation angle of the camera along the longitudinal axis.
  37007. */
  37008. alpha: number;
  37009. /**
  37010. * Defines the rotation angle of the camera along the latitudinal axis.
  37011. */
  37012. beta: number;
  37013. /**
  37014. * Defines the radius of the camera from it s target point.
  37015. */
  37016. radius: number;
  37017. protected _target: Vector3;
  37018. protected _targetHost: Nullable<AbstractMesh>;
  37019. /**
  37020. * Defines the target point of the camera.
  37021. * The camera looks towards it form the radius distance.
  37022. */
  37023. target: Vector3;
  37024. /**
  37025. * Define the current local position of the camera in the scene
  37026. */
  37027. position: Vector3;
  37028. protected _upVector: Vector3;
  37029. protected _upToYMatrix: Matrix;
  37030. protected _YToUpMatrix: Matrix;
  37031. /**
  37032. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37033. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37034. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37035. */
  37036. upVector: Vector3;
  37037. /**
  37038. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37039. */
  37040. setMatUp(): void;
  37041. /**
  37042. * Current inertia value on the longitudinal axis.
  37043. * The bigger this number the longer it will take for the camera to stop.
  37044. */
  37045. inertialAlphaOffset: number;
  37046. /**
  37047. * Current inertia value on the latitudinal axis.
  37048. * The bigger this number the longer it will take for the camera to stop.
  37049. */
  37050. inertialBetaOffset: number;
  37051. /**
  37052. * Current inertia value on the radius axis.
  37053. * The bigger this number the longer it will take for the camera to stop.
  37054. */
  37055. inertialRadiusOffset: number;
  37056. /**
  37057. * Minimum allowed angle on the longitudinal axis.
  37058. * This can help limiting how the Camera is able to move in the scene.
  37059. */
  37060. lowerAlphaLimit: Nullable<number>;
  37061. /**
  37062. * Maximum allowed angle on the longitudinal axis.
  37063. * This can help limiting how the Camera is able to move in the scene.
  37064. */
  37065. upperAlphaLimit: Nullable<number>;
  37066. /**
  37067. * Minimum allowed angle on the latitudinal axis.
  37068. * This can help limiting how the Camera is able to move in the scene.
  37069. */
  37070. lowerBetaLimit: number;
  37071. /**
  37072. * Maximum allowed angle on the latitudinal axis.
  37073. * This can help limiting how the Camera is able to move in the scene.
  37074. */
  37075. upperBetaLimit: number;
  37076. /**
  37077. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37078. * This can help limiting how the Camera is able to move in the scene.
  37079. */
  37080. lowerRadiusLimit: Nullable<number>;
  37081. /**
  37082. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37083. * This can help limiting how the Camera is able to move in the scene.
  37084. */
  37085. upperRadiusLimit: Nullable<number>;
  37086. /**
  37087. * Defines the current inertia value used during panning of the camera along the X axis.
  37088. */
  37089. inertialPanningX: number;
  37090. /**
  37091. * Defines the current inertia value used during panning of the camera along the Y axis.
  37092. */
  37093. inertialPanningY: number;
  37094. /**
  37095. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37096. * Basically if your fingers moves away from more than this distance you will be considered
  37097. * in pinch mode.
  37098. */
  37099. pinchToPanMaxDistance: number;
  37100. /**
  37101. * Defines the maximum distance the camera can pan.
  37102. * This could help keeping the cammera always in your scene.
  37103. */
  37104. panningDistanceLimit: Nullable<number>;
  37105. /**
  37106. * Defines the target of the camera before paning.
  37107. */
  37108. panningOriginTarget: Vector3;
  37109. /**
  37110. * Defines the value of the inertia used during panning.
  37111. * 0 would mean stop inertia and one would mean no decelleration at all.
  37112. */
  37113. panningInertia: number;
  37114. /**
  37115. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37116. */
  37117. angularSensibilityX: number;
  37118. /**
  37119. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37120. */
  37121. angularSensibilityY: number;
  37122. /**
  37123. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37124. */
  37125. pinchPrecision: number;
  37126. /**
  37127. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37128. * It will be used instead of pinchDeltaPrecision if different from 0.
  37129. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37130. */
  37131. pinchDeltaPercentage: number;
  37132. /**
  37133. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37134. */
  37135. panningSensibility: number;
  37136. /**
  37137. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37138. */
  37139. keysUp: number[];
  37140. /**
  37141. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37142. */
  37143. keysDown: number[];
  37144. /**
  37145. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37146. */
  37147. keysLeft: number[];
  37148. /**
  37149. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37150. */
  37151. keysRight: number[];
  37152. /**
  37153. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37154. */
  37155. wheelPrecision: number;
  37156. /**
  37157. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37158. * It will be used instead of pinchDeltaPrecision if different from 0.
  37159. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37160. */
  37161. wheelDeltaPercentage: number;
  37162. /**
  37163. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37164. */
  37165. zoomOnFactor: number;
  37166. /**
  37167. * Defines a screen offset for the camera position.
  37168. */
  37169. targetScreenOffset: Vector2;
  37170. /**
  37171. * Allows the camera to be completely reversed.
  37172. * If false the camera can not arrive upside down.
  37173. */
  37174. allowUpsideDown: boolean;
  37175. /**
  37176. * Define if double tap/click is used to restore the previously saved state of the camera.
  37177. */
  37178. useInputToRestoreState: boolean;
  37179. /** @hidden */
  37180. _viewMatrix: Matrix;
  37181. /** @hidden */
  37182. _useCtrlForPanning: boolean;
  37183. /** @hidden */
  37184. _panningMouseButton: number;
  37185. /**
  37186. * Defines the input associated to the camera.
  37187. */
  37188. inputs: ArcRotateCameraInputsManager;
  37189. /** @hidden */
  37190. _reset: () => void;
  37191. /**
  37192. * Defines the allowed panning axis.
  37193. */
  37194. panningAxis: Vector3;
  37195. protected _localDirection: Vector3;
  37196. protected _transformedDirection: Vector3;
  37197. private _bouncingBehavior;
  37198. /**
  37199. * Gets the bouncing behavior of the camera if it has been enabled.
  37200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37201. */
  37202. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37203. /**
  37204. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37206. */
  37207. useBouncingBehavior: boolean;
  37208. private _framingBehavior;
  37209. /**
  37210. * Gets the framing behavior of the camera if it has been enabled.
  37211. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37212. */
  37213. readonly framingBehavior: Nullable<FramingBehavior>;
  37214. /**
  37215. * Defines if the framing behavior of the camera is enabled on the camera.
  37216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37217. */
  37218. useFramingBehavior: boolean;
  37219. private _autoRotationBehavior;
  37220. /**
  37221. * Gets the auto rotation behavior of the camera if it has been enabled.
  37222. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37223. */
  37224. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37225. /**
  37226. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37228. */
  37229. useAutoRotationBehavior: boolean;
  37230. /**
  37231. * Observable triggered when the mesh target has been changed on the camera.
  37232. */
  37233. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37234. /**
  37235. * Event raised when the camera is colliding with a mesh.
  37236. */
  37237. onCollide: (collidedMesh: AbstractMesh) => void;
  37238. /**
  37239. * Defines whether the camera should check collision with the objects oh the scene.
  37240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37241. */
  37242. checkCollisions: boolean;
  37243. /**
  37244. * Defines the collision radius of the camera.
  37245. * This simulates a sphere around the camera.
  37246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37247. */
  37248. collisionRadius: Vector3;
  37249. protected _collider: Collider;
  37250. protected _previousPosition: Vector3;
  37251. protected _collisionVelocity: Vector3;
  37252. protected _newPosition: Vector3;
  37253. protected _previousAlpha: number;
  37254. protected _previousBeta: number;
  37255. protected _previousRadius: number;
  37256. protected _collisionTriggered: boolean;
  37257. protected _targetBoundingCenter: Nullable<Vector3>;
  37258. private _computationVector;
  37259. /**
  37260. * Instantiates a new ArcRotateCamera in a given scene
  37261. * @param name Defines the name of the camera
  37262. * @param alpha Defines the camera rotation along the logitudinal axis
  37263. * @param beta Defines the camera rotation along the latitudinal axis
  37264. * @param radius Defines the camera distance from its target
  37265. * @param target Defines the camera target
  37266. * @param scene Defines the scene the camera belongs to
  37267. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37268. */
  37269. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37270. /** @hidden */
  37271. _initCache(): void;
  37272. /** @hidden */
  37273. _updateCache(ignoreParentClass?: boolean): void;
  37274. protected _getTargetPosition(): Vector3;
  37275. private _storedAlpha;
  37276. private _storedBeta;
  37277. private _storedRadius;
  37278. private _storedTarget;
  37279. /**
  37280. * Stores the current state of the camera (alpha, beta, radius and target)
  37281. * @returns the camera itself
  37282. */
  37283. storeState(): Camera;
  37284. /**
  37285. * @hidden
  37286. * Restored camera state. You must call storeState() first
  37287. */
  37288. _restoreStateValues(): boolean;
  37289. /** @hidden */
  37290. _isSynchronizedViewMatrix(): boolean;
  37291. /**
  37292. * Attached controls to the current camera.
  37293. * @param element Defines the element the controls should be listened from
  37294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37295. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37296. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37297. */
  37298. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37299. /**
  37300. * Detach the current controls from the camera.
  37301. * The camera will stop reacting to inputs.
  37302. * @param element Defines the element to stop listening the inputs from
  37303. */
  37304. detachControl(element: HTMLElement): void;
  37305. /** @hidden */
  37306. _checkInputs(): void;
  37307. protected _checkLimits(): void;
  37308. /**
  37309. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37310. */
  37311. rebuildAnglesAndRadius(): void;
  37312. /**
  37313. * Use a position to define the current camera related information like aplha, beta and radius
  37314. * @param position Defines the position to set the camera at
  37315. */
  37316. setPosition(position: Vector3): void;
  37317. /**
  37318. * Defines the target the camera should look at.
  37319. * This will automatically adapt alpha beta and radius to fit within the new target.
  37320. * @param target Defines the new target as a Vector or a mesh
  37321. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37322. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37323. */
  37324. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37325. /** @hidden */
  37326. _getViewMatrix(): Matrix;
  37327. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37328. /**
  37329. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37330. * @param meshes Defines the mesh to zoom on
  37331. * @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)
  37332. */
  37333. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37334. /**
  37335. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37336. * The target will be changed but the radius
  37337. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37338. * @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)
  37339. */
  37340. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37341. min: Vector3;
  37342. max: Vector3;
  37343. distance: number;
  37344. }, doNotUpdateMaxZ?: boolean): void;
  37345. /**
  37346. * @override
  37347. * Override Camera.createRigCamera
  37348. */
  37349. createRigCamera(name: string, cameraIndex: number): Camera;
  37350. /**
  37351. * @hidden
  37352. * @override
  37353. * Override Camera._updateRigCameras
  37354. */
  37355. _updateRigCameras(): void;
  37356. /**
  37357. * Destroy the camera and release the current resources hold by it.
  37358. */
  37359. dispose(): void;
  37360. /**
  37361. * Gets the current object class name.
  37362. * @return the class name
  37363. */
  37364. getClassName(): string;
  37365. }
  37366. }
  37367. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37368. import { Behavior } from "babylonjs/Behaviors/behavior";
  37369. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37370. /**
  37371. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37373. */
  37374. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37375. /**
  37376. * Gets the name of the behavior.
  37377. */
  37378. readonly name: string;
  37379. private _zoomStopsAnimation;
  37380. private _idleRotationSpeed;
  37381. private _idleRotationWaitTime;
  37382. private _idleRotationSpinupTime;
  37383. /**
  37384. * Sets the flag that indicates if user zooming should stop animation.
  37385. */
  37386. /**
  37387. * Gets the flag that indicates if user zooming should stop animation.
  37388. */
  37389. zoomStopsAnimation: boolean;
  37390. /**
  37391. * Sets the default speed at which the camera rotates around the model.
  37392. */
  37393. /**
  37394. * Gets the default speed at which the camera rotates around the model.
  37395. */
  37396. idleRotationSpeed: number;
  37397. /**
  37398. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37399. */
  37400. /**
  37401. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37402. */
  37403. idleRotationWaitTime: number;
  37404. /**
  37405. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37406. */
  37407. /**
  37408. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37409. */
  37410. idleRotationSpinupTime: number;
  37411. /**
  37412. * Gets a value indicating if the camera is currently rotating because of this behavior
  37413. */
  37414. readonly rotationInProgress: boolean;
  37415. private _onPrePointerObservableObserver;
  37416. private _onAfterCheckInputsObserver;
  37417. private _attachedCamera;
  37418. private _isPointerDown;
  37419. private _lastFrameTime;
  37420. private _lastInteractionTime;
  37421. private _cameraRotationSpeed;
  37422. /**
  37423. * Initializes the behavior.
  37424. */
  37425. init(): void;
  37426. /**
  37427. * Attaches the behavior to its arc rotate camera.
  37428. * @param camera Defines the camera to attach the behavior to
  37429. */
  37430. attach(camera: ArcRotateCamera): void;
  37431. /**
  37432. * Detaches the behavior from its current arc rotate camera.
  37433. */
  37434. detach(): void;
  37435. /**
  37436. * Returns true if user is scrolling.
  37437. * @return true if user is scrolling.
  37438. */
  37439. private _userIsZooming;
  37440. private _lastFrameRadius;
  37441. private _shouldAnimationStopForInteraction;
  37442. /**
  37443. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37444. */
  37445. private _applyUserInteraction;
  37446. private _userIsMoving;
  37447. }
  37448. }
  37449. declare module "babylonjs/Behaviors/Cameras/index" {
  37450. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37451. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37452. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37453. }
  37454. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37455. import { Mesh } from "babylonjs/Meshes/mesh";
  37456. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37457. import { Behavior } from "babylonjs/Behaviors/behavior";
  37458. /**
  37459. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37460. */
  37461. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37462. private ui;
  37463. /**
  37464. * The name of the behavior
  37465. */
  37466. name: string;
  37467. /**
  37468. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37469. */
  37470. distanceAwayFromFace: number;
  37471. /**
  37472. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37473. */
  37474. distanceAwayFromBottomOfFace: number;
  37475. private _faceVectors;
  37476. private _target;
  37477. private _scene;
  37478. private _onRenderObserver;
  37479. private _tmpMatrix;
  37480. private _tmpVector;
  37481. /**
  37482. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37483. * @param ui The transform node that should be attched to the mesh
  37484. */
  37485. constructor(ui: TransformNode);
  37486. /**
  37487. * Initializes the behavior
  37488. */
  37489. init(): void;
  37490. private _closestFace;
  37491. private _zeroVector;
  37492. private _lookAtTmpMatrix;
  37493. private _lookAtToRef;
  37494. /**
  37495. * Attaches the AttachToBoxBehavior to the passed in mesh
  37496. * @param target The mesh that the specified node will be attached to
  37497. */
  37498. attach(target: Mesh): void;
  37499. /**
  37500. * Detaches the behavior from the mesh
  37501. */
  37502. detach(): void;
  37503. }
  37504. }
  37505. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37506. import { Behavior } from "babylonjs/Behaviors/behavior";
  37507. import { Mesh } from "babylonjs/Meshes/mesh";
  37508. /**
  37509. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37510. */
  37511. export class FadeInOutBehavior implements Behavior<Mesh> {
  37512. /**
  37513. * Time in milliseconds to delay before fading in (Default: 0)
  37514. */
  37515. delay: number;
  37516. /**
  37517. * Time in milliseconds for the mesh to fade in (Default: 300)
  37518. */
  37519. fadeInTime: number;
  37520. private _millisecondsPerFrame;
  37521. private _hovered;
  37522. private _hoverValue;
  37523. private _ownerNode;
  37524. /**
  37525. * Instatiates the FadeInOutBehavior
  37526. */
  37527. constructor();
  37528. /**
  37529. * The name of the behavior
  37530. */
  37531. readonly name: string;
  37532. /**
  37533. * Initializes the behavior
  37534. */
  37535. init(): void;
  37536. /**
  37537. * Attaches the fade behavior on the passed in mesh
  37538. * @param ownerNode The mesh that will be faded in/out once attached
  37539. */
  37540. attach(ownerNode: Mesh): void;
  37541. /**
  37542. * Detaches the behavior from the mesh
  37543. */
  37544. detach(): void;
  37545. /**
  37546. * Triggers the mesh to begin fading in or out
  37547. * @param value if the object should fade in or out (true to fade in)
  37548. */
  37549. fadeIn(value: boolean): void;
  37550. private _update;
  37551. private _setAllVisibility;
  37552. }
  37553. }
  37554. declare module "babylonjs/Misc/pivotTools" {
  37555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37556. /**
  37557. * Class containing a set of static utilities functions for managing Pivots
  37558. * @hidden
  37559. */
  37560. export class PivotTools {
  37561. private static _PivotCached;
  37562. private static _OldPivotPoint;
  37563. private static _PivotTranslation;
  37564. private static _PivotTmpVector;
  37565. /** @hidden */
  37566. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37567. /** @hidden */
  37568. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37569. }
  37570. }
  37571. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37572. import { Scene } from "babylonjs/scene";
  37573. import { Vector4 } from "babylonjs/Maths/math.vector";
  37574. import { Mesh } from "babylonjs/Meshes/mesh";
  37575. import { Nullable } from "babylonjs/types";
  37576. import { Plane } from "babylonjs/Maths/math.plane";
  37577. /**
  37578. * Class containing static functions to help procedurally build meshes
  37579. */
  37580. export class PlaneBuilder {
  37581. /**
  37582. * Creates a plane mesh
  37583. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37584. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37585. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37589. * @param name defines the name of the mesh
  37590. * @param options defines the options used to create the mesh
  37591. * @param scene defines the hosting scene
  37592. * @returns the plane mesh
  37593. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37594. */
  37595. static CreatePlane(name: string, options: {
  37596. size?: number;
  37597. width?: number;
  37598. height?: number;
  37599. sideOrientation?: number;
  37600. frontUVs?: Vector4;
  37601. backUVs?: Vector4;
  37602. updatable?: boolean;
  37603. sourcePlane?: Plane;
  37604. }, scene?: Nullable<Scene>): Mesh;
  37605. }
  37606. }
  37607. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37608. import { Behavior } from "babylonjs/Behaviors/behavior";
  37609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37610. import { Observable } from "babylonjs/Misc/observable";
  37611. import { Vector3 } from "babylonjs/Maths/math.vector";
  37612. import { Ray } from "babylonjs/Culling/ray";
  37613. import "babylonjs/Meshes/Builders/planeBuilder";
  37614. /**
  37615. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37616. */
  37617. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37618. private static _AnyMouseID;
  37619. /**
  37620. * Abstract mesh the behavior is set on
  37621. */
  37622. attachedNode: AbstractMesh;
  37623. private _dragPlane;
  37624. private _scene;
  37625. private _pointerObserver;
  37626. private _beforeRenderObserver;
  37627. private static _planeScene;
  37628. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37629. /**
  37630. * 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)
  37631. */
  37632. maxDragAngle: number;
  37633. /**
  37634. * @hidden
  37635. */
  37636. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37637. /**
  37638. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37639. */
  37640. currentDraggingPointerID: number;
  37641. /**
  37642. * The last position where the pointer hit the drag plane in world space
  37643. */
  37644. lastDragPosition: Vector3;
  37645. /**
  37646. * If the behavior is currently in a dragging state
  37647. */
  37648. dragging: boolean;
  37649. /**
  37650. * 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)
  37651. */
  37652. dragDeltaRatio: number;
  37653. /**
  37654. * If the drag plane orientation should be updated during the dragging (Default: true)
  37655. */
  37656. updateDragPlane: boolean;
  37657. private _debugMode;
  37658. private _moving;
  37659. /**
  37660. * Fires each time the attached mesh is dragged with the pointer
  37661. * * delta between last drag position and current drag position in world space
  37662. * * dragDistance along the drag axis
  37663. * * dragPlaneNormal normal of the current drag plane used during the drag
  37664. * * dragPlanePoint in world space where the drag intersects the drag plane
  37665. */
  37666. onDragObservable: Observable<{
  37667. delta: Vector3;
  37668. dragPlanePoint: Vector3;
  37669. dragPlaneNormal: Vector3;
  37670. dragDistance: number;
  37671. pointerId: number;
  37672. }>;
  37673. /**
  37674. * Fires each time a drag begins (eg. mouse down on mesh)
  37675. */
  37676. onDragStartObservable: Observable<{
  37677. dragPlanePoint: Vector3;
  37678. pointerId: number;
  37679. }>;
  37680. /**
  37681. * Fires each time a drag ends (eg. mouse release after drag)
  37682. */
  37683. onDragEndObservable: Observable<{
  37684. dragPlanePoint: Vector3;
  37685. pointerId: number;
  37686. }>;
  37687. /**
  37688. * If the attached mesh should be moved when dragged
  37689. */
  37690. moveAttached: boolean;
  37691. /**
  37692. * If the drag behavior will react to drag events (Default: true)
  37693. */
  37694. enabled: boolean;
  37695. /**
  37696. * If pointer events should start and release the drag (Default: true)
  37697. */
  37698. startAndReleaseDragOnPointerEvents: boolean;
  37699. /**
  37700. * If camera controls should be detached during the drag
  37701. */
  37702. detachCameraControls: boolean;
  37703. /**
  37704. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37705. */
  37706. useObjectOrienationForDragging: boolean;
  37707. private _options;
  37708. /**
  37709. * Creates a pointer drag behavior that can be attached to a mesh
  37710. * @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)
  37711. */
  37712. constructor(options?: {
  37713. dragAxis?: Vector3;
  37714. dragPlaneNormal?: Vector3;
  37715. });
  37716. /**
  37717. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37718. */
  37719. validateDrag: (targetPosition: Vector3) => boolean;
  37720. /**
  37721. * The name of the behavior
  37722. */
  37723. readonly name: string;
  37724. /**
  37725. * Initializes the behavior
  37726. */
  37727. init(): void;
  37728. private _tmpVector;
  37729. private _alternatePickedPoint;
  37730. private _worldDragAxis;
  37731. private _targetPosition;
  37732. private _attachedElement;
  37733. /**
  37734. * Attaches the drag behavior the passed in mesh
  37735. * @param ownerNode The mesh that will be dragged around once attached
  37736. */
  37737. attach(ownerNode: AbstractMesh): void;
  37738. /**
  37739. * Force relase the drag action by code.
  37740. */
  37741. releaseDrag(): void;
  37742. private _startDragRay;
  37743. private _lastPointerRay;
  37744. /**
  37745. * Simulates the start of a pointer drag event on the behavior
  37746. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37747. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37748. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37749. */
  37750. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37751. private _startDrag;
  37752. private _dragDelta;
  37753. private _moveDrag;
  37754. private _pickWithRayOnDragPlane;
  37755. private _pointA;
  37756. private _pointB;
  37757. private _pointC;
  37758. private _lineA;
  37759. private _lineB;
  37760. private _localAxis;
  37761. private _lookAt;
  37762. private _updateDragPlanePosition;
  37763. /**
  37764. * Detaches the behavior from the mesh
  37765. */
  37766. detach(): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37770. import { Mesh } from "babylonjs/Meshes/mesh";
  37771. import { Behavior } from "babylonjs/Behaviors/behavior";
  37772. /**
  37773. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37774. */
  37775. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37776. private _dragBehaviorA;
  37777. private _dragBehaviorB;
  37778. private _startDistance;
  37779. private _initialScale;
  37780. private _targetScale;
  37781. private _ownerNode;
  37782. private _sceneRenderObserver;
  37783. /**
  37784. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37785. */
  37786. constructor();
  37787. /**
  37788. * The name of the behavior
  37789. */
  37790. readonly name: string;
  37791. /**
  37792. * Initializes the behavior
  37793. */
  37794. init(): void;
  37795. private _getCurrentDistance;
  37796. /**
  37797. * Attaches the scale behavior the passed in mesh
  37798. * @param ownerNode The mesh that will be scaled around once attached
  37799. */
  37800. attach(ownerNode: Mesh): void;
  37801. /**
  37802. * Detaches the behavior from the mesh
  37803. */
  37804. detach(): void;
  37805. }
  37806. }
  37807. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37808. import { Behavior } from "babylonjs/Behaviors/behavior";
  37809. import { Mesh } from "babylonjs/Meshes/mesh";
  37810. import { Observable } from "babylonjs/Misc/observable";
  37811. /**
  37812. * 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
  37813. */
  37814. export class SixDofDragBehavior implements Behavior<Mesh> {
  37815. private static _virtualScene;
  37816. private _ownerNode;
  37817. private _sceneRenderObserver;
  37818. private _scene;
  37819. private _targetPosition;
  37820. private _virtualOriginMesh;
  37821. private _virtualDragMesh;
  37822. private _pointerObserver;
  37823. private _moving;
  37824. private _startingOrientation;
  37825. /**
  37826. * 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)
  37827. */
  37828. private zDragFactor;
  37829. /**
  37830. * If the object should rotate to face the drag origin
  37831. */
  37832. rotateDraggedObject: boolean;
  37833. /**
  37834. * If the behavior is currently in a dragging state
  37835. */
  37836. dragging: boolean;
  37837. /**
  37838. * 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)
  37839. */
  37840. dragDeltaRatio: number;
  37841. /**
  37842. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37843. */
  37844. currentDraggingPointerID: number;
  37845. /**
  37846. * If camera controls should be detached during the drag
  37847. */
  37848. detachCameraControls: boolean;
  37849. /**
  37850. * Fires each time a drag starts
  37851. */
  37852. onDragStartObservable: Observable<{}>;
  37853. /**
  37854. * Fires each time a drag ends (eg. mouse release after drag)
  37855. */
  37856. onDragEndObservable: Observable<{}>;
  37857. /**
  37858. * 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
  37859. */
  37860. constructor();
  37861. /**
  37862. * The name of the behavior
  37863. */
  37864. readonly name: string;
  37865. /**
  37866. * Initializes the behavior
  37867. */
  37868. init(): void;
  37869. /**
  37870. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37871. */
  37872. private readonly _pointerCamera;
  37873. /**
  37874. * Attaches the scale behavior the passed in mesh
  37875. * @param ownerNode The mesh that will be scaled around once attached
  37876. */
  37877. attach(ownerNode: Mesh): void;
  37878. /**
  37879. * Detaches the behavior from the mesh
  37880. */
  37881. detach(): void;
  37882. }
  37883. }
  37884. declare module "babylonjs/Behaviors/Meshes/index" {
  37885. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37886. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37887. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37888. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37889. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37890. }
  37891. declare module "babylonjs/Behaviors/index" {
  37892. export * from "babylonjs/Behaviors/behavior";
  37893. export * from "babylonjs/Behaviors/Cameras/index";
  37894. export * from "babylonjs/Behaviors/Meshes/index";
  37895. }
  37896. declare module "babylonjs/Bones/boneIKController" {
  37897. import { Bone } from "babylonjs/Bones/bone";
  37898. import { Vector3 } from "babylonjs/Maths/math.vector";
  37899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37900. import { Nullable } from "babylonjs/types";
  37901. /**
  37902. * Class used to apply inverse kinematics to bones
  37903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37904. */
  37905. export class BoneIKController {
  37906. private static _tmpVecs;
  37907. private static _tmpQuat;
  37908. private static _tmpMats;
  37909. /**
  37910. * Gets or sets the target mesh
  37911. */
  37912. targetMesh: AbstractMesh;
  37913. /** Gets or sets the mesh used as pole */
  37914. poleTargetMesh: AbstractMesh;
  37915. /**
  37916. * Gets or sets the bone used as pole
  37917. */
  37918. poleTargetBone: Nullable<Bone>;
  37919. /**
  37920. * Gets or sets the target position
  37921. */
  37922. targetPosition: Vector3;
  37923. /**
  37924. * Gets or sets the pole target position
  37925. */
  37926. poleTargetPosition: Vector3;
  37927. /**
  37928. * Gets or sets the pole target local offset
  37929. */
  37930. poleTargetLocalOffset: Vector3;
  37931. /**
  37932. * Gets or sets the pole angle
  37933. */
  37934. poleAngle: number;
  37935. /**
  37936. * Gets or sets the mesh associated with the controller
  37937. */
  37938. mesh: AbstractMesh;
  37939. /**
  37940. * 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)
  37941. */
  37942. slerpAmount: number;
  37943. private _bone1Quat;
  37944. private _bone1Mat;
  37945. private _bone2Ang;
  37946. private _bone1;
  37947. private _bone2;
  37948. private _bone1Length;
  37949. private _bone2Length;
  37950. private _maxAngle;
  37951. private _maxReach;
  37952. private _rightHandedSystem;
  37953. private _bendAxis;
  37954. private _slerping;
  37955. private _adjustRoll;
  37956. /**
  37957. * Gets or sets maximum allowed angle
  37958. */
  37959. maxAngle: number;
  37960. /**
  37961. * Creates a new BoneIKController
  37962. * @param mesh defines the mesh to control
  37963. * @param bone defines the bone to control
  37964. * @param options defines options to set up the controller
  37965. */
  37966. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37967. targetMesh?: AbstractMesh;
  37968. poleTargetMesh?: AbstractMesh;
  37969. poleTargetBone?: Bone;
  37970. poleTargetLocalOffset?: Vector3;
  37971. poleAngle?: number;
  37972. bendAxis?: Vector3;
  37973. maxAngle?: number;
  37974. slerpAmount?: number;
  37975. });
  37976. private _setMaxAngle;
  37977. /**
  37978. * Force the controller to update the bones
  37979. */
  37980. update(): void;
  37981. }
  37982. }
  37983. declare module "babylonjs/Bones/boneLookController" {
  37984. import { Vector3 } from "babylonjs/Maths/math.vector";
  37985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37986. import { Bone } from "babylonjs/Bones/bone";
  37987. import { Space } from "babylonjs/Maths/math.axis";
  37988. /**
  37989. * Class used to make a bone look toward a point in space
  37990. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37991. */
  37992. export class BoneLookController {
  37993. private static _tmpVecs;
  37994. private static _tmpQuat;
  37995. private static _tmpMats;
  37996. /**
  37997. * The target Vector3 that the bone will look at
  37998. */
  37999. target: Vector3;
  38000. /**
  38001. * The mesh that the bone is attached to
  38002. */
  38003. mesh: AbstractMesh;
  38004. /**
  38005. * The bone that will be looking to the target
  38006. */
  38007. bone: Bone;
  38008. /**
  38009. * The up axis of the coordinate system that is used when the bone is rotated
  38010. */
  38011. upAxis: Vector3;
  38012. /**
  38013. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38014. */
  38015. upAxisSpace: Space;
  38016. /**
  38017. * Used to make an adjustment to the yaw of the bone
  38018. */
  38019. adjustYaw: number;
  38020. /**
  38021. * Used to make an adjustment to the pitch of the bone
  38022. */
  38023. adjustPitch: number;
  38024. /**
  38025. * Used to make an adjustment to the roll of the bone
  38026. */
  38027. adjustRoll: number;
  38028. /**
  38029. * 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)
  38030. */
  38031. slerpAmount: number;
  38032. private _minYaw;
  38033. private _maxYaw;
  38034. private _minPitch;
  38035. private _maxPitch;
  38036. private _minYawSin;
  38037. private _minYawCos;
  38038. private _maxYawSin;
  38039. private _maxYawCos;
  38040. private _midYawConstraint;
  38041. private _minPitchTan;
  38042. private _maxPitchTan;
  38043. private _boneQuat;
  38044. private _slerping;
  38045. private _transformYawPitch;
  38046. private _transformYawPitchInv;
  38047. private _firstFrameSkipped;
  38048. private _yawRange;
  38049. private _fowardAxis;
  38050. /**
  38051. * Gets or sets the minimum yaw angle that the bone can look to
  38052. */
  38053. minYaw: number;
  38054. /**
  38055. * Gets or sets the maximum yaw angle that the bone can look to
  38056. */
  38057. maxYaw: number;
  38058. /**
  38059. * Gets or sets the minimum pitch angle that the bone can look to
  38060. */
  38061. minPitch: number;
  38062. /**
  38063. * Gets or sets the maximum pitch angle that the bone can look to
  38064. */
  38065. maxPitch: number;
  38066. /**
  38067. * Create a BoneLookController
  38068. * @param mesh the mesh that the bone belongs to
  38069. * @param bone the bone that will be looking to the target
  38070. * @param target the target Vector3 to look at
  38071. * @param options optional settings:
  38072. * * maxYaw: the maximum angle the bone will yaw to
  38073. * * minYaw: the minimum angle the bone will yaw to
  38074. * * maxPitch: the maximum angle the bone will pitch to
  38075. * * minPitch: the minimum angle the bone will yaw to
  38076. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38077. * * upAxis: the up axis of the coordinate system
  38078. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38079. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38080. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38081. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38082. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38083. * * adjustRoll: used to make an adjustment to the roll of the bone
  38084. **/
  38085. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38086. maxYaw?: number;
  38087. minYaw?: number;
  38088. maxPitch?: number;
  38089. minPitch?: number;
  38090. slerpAmount?: number;
  38091. upAxis?: Vector3;
  38092. upAxisSpace?: Space;
  38093. yawAxis?: Vector3;
  38094. pitchAxis?: Vector3;
  38095. adjustYaw?: number;
  38096. adjustPitch?: number;
  38097. adjustRoll?: number;
  38098. });
  38099. /**
  38100. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38101. */
  38102. update(): void;
  38103. private _getAngleDiff;
  38104. private _getAngleBetween;
  38105. private _isAngleBetween;
  38106. }
  38107. }
  38108. declare module "babylonjs/Bones/index" {
  38109. export * from "babylonjs/Bones/bone";
  38110. export * from "babylonjs/Bones/boneIKController";
  38111. export * from "babylonjs/Bones/boneLookController";
  38112. export * from "babylonjs/Bones/skeleton";
  38113. }
  38114. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38115. import { Nullable } from "babylonjs/types";
  38116. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38118. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38119. /**
  38120. * Manage the gamepad inputs to control an arc rotate camera.
  38121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38122. */
  38123. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38124. /**
  38125. * Defines the camera the input is attached to.
  38126. */
  38127. camera: ArcRotateCamera;
  38128. /**
  38129. * Defines the gamepad the input is gathering event from.
  38130. */
  38131. gamepad: Nullable<Gamepad>;
  38132. /**
  38133. * Defines the gamepad rotation sensiblity.
  38134. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38135. */
  38136. gamepadRotationSensibility: number;
  38137. /**
  38138. * Defines the gamepad move sensiblity.
  38139. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38140. */
  38141. gamepadMoveSensibility: number;
  38142. private _onGamepadConnectedObserver;
  38143. private _onGamepadDisconnectedObserver;
  38144. /**
  38145. * Attach the input controls to a specific dom element to get the input from.
  38146. * @param element Defines the element the controls should be listened from
  38147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38148. */
  38149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38150. /**
  38151. * Detach the current controls from the specified dom element.
  38152. * @param element Defines the element to stop listening the inputs from
  38153. */
  38154. detachControl(element: Nullable<HTMLElement>): void;
  38155. /**
  38156. * Update the current camera state depending on the inputs that have been used this frame.
  38157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38158. */
  38159. checkInputs(): void;
  38160. /**
  38161. * Gets the class name of the current intput.
  38162. * @returns the class name
  38163. */
  38164. getClassName(): string;
  38165. /**
  38166. * Get the friendly name associated with the input class.
  38167. * @returns the input friendly name
  38168. */
  38169. getSimpleName(): string;
  38170. }
  38171. }
  38172. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38173. import { Nullable } from "babylonjs/types";
  38174. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38175. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38176. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38177. interface ArcRotateCameraInputsManager {
  38178. /**
  38179. * Add orientation input support to the input manager.
  38180. * @returns the current input manager
  38181. */
  38182. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38183. }
  38184. }
  38185. /**
  38186. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38188. */
  38189. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38190. /**
  38191. * Defines the camera the input is attached to.
  38192. */
  38193. camera: ArcRotateCamera;
  38194. /**
  38195. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38196. */
  38197. alphaCorrection: number;
  38198. /**
  38199. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38200. */
  38201. gammaCorrection: number;
  38202. private _alpha;
  38203. private _gamma;
  38204. private _dirty;
  38205. private _deviceOrientationHandler;
  38206. /**
  38207. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38208. */
  38209. constructor();
  38210. /**
  38211. * Attach the input controls to a specific dom element to get the input from.
  38212. * @param element Defines the element the controls should be listened from
  38213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38214. */
  38215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38216. /** @hidden */
  38217. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38218. /**
  38219. * Update the current camera state depending on the inputs that have been used this frame.
  38220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38221. */
  38222. checkInputs(): void;
  38223. /**
  38224. * Detach the current controls from the specified dom element.
  38225. * @param element Defines the element to stop listening the inputs from
  38226. */
  38227. detachControl(element: Nullable<HTMLElement>): void;
  38228. /**
  38229. * Gets the class name of the current intput.
  38230. * @returns the class name
  38231. */
  38232. getClassName(): string;
  38233. /**
  38234. * Get the friendly name associated with the input class.
  38235. * @returns the input friendly name
  38236. */
  38237. getSimpleName(): string;
  38238. }
  38239. }
  38240. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38241. import { Nullable } from "babylonjs/types";
  38242. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38243. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38244. /**
  38245. * Listen to mouse events to control the camera.
  38246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38247. */
  38248. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38249. /**
  38250. * Defines the camera the input is attached to.
  38251. */
  38252. camera: FlyCamera;
  38253. /**
  38254. * Defines if touch is enabled. (Default is true.)
  38255. */
  38256. touchEnabled: boolean;
  38257. /**
  38258. * Defines the buttons associated with the input to handle camera rotation.
  38259. */
  38260. buttons: number[];
  38261. /**
  38262. * Assign buttons for Yaw control.
  38263. */
  38264. buttonsYaw: number[];
  38265. /**
  38266. * Assign buttons for Pitch control.
  38267. */
  38268. buttonsPitch: number[];
  38269. /**
  38270. * Assign buttons for Roll control.
  38271. */
  38272. buttonsRoll: number[];
  38273. /**
  38274. * Detect if any button is being pressed while mouse is moved.
  38275. * -1 = Mouse locked.
  38276. * 0 = Left button.
  38277. * 1 = Middle Button.
  38278. * 2 = Right Button.
  38279. */
  38280. activeButton: number;
  38281. /**
  38282. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38283. * Higher values reduce its sensitivity.
  38284. */
  38285. angularSensibility: number;
  38286. private _mousemoveCallback;
  38287. private _observer;
  38288. private _rollObserver;
  38289. private previousPosition;
  38290. private noPreventDefault;
  38291. private element;
  38292. /**
  38293. * Listen to mouse events to control the camera.
  38294. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38296. */
  38297. constructor(touchEnabled?: boolean);
  38298. /**
  38299. * Attach the mouse control to the HTML DOM element.
  38300. * @param element Defines the element that listens to the input events.
  38301. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38302. */
  38303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38304. /**
  38305. * Detach the current controls from the specified dom element.
  38306. * @param element Defines the element to stop listening the inputs from
  38307. */
  38308. detachControl(element: Nullable<HTMLElement>): void;
  38309. /**
  38310. * Gets the class name of the current input.
  38311. * @returns the class name.
  38312. */
  38313. getClassName(): string;
  38314. /**
  38315. * Get the friendly name associated with the input class.
  38316. * @returns the input's friendly name.
  38317. */
  38318. getSimpleName(): string;
  38319. private _pointerInput;
  38320. private _onMouseMove;
  38321. /**
  38322. * Rotate camera by mouse offset.
  38323. */
  38324. private rotateCamera;
  38325. }
  38326. }
  38327. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38328. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38329. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38330. /**
  38331. * Default Inputs manager for the FlyCamera.
  38332. * It groups all the default supported inputs for ease of use.
  38333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38334. */
  38335. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38336. /**
  38337. * Instantiates a new FlyCameraInputsManager.
  38338. * @param camera Defines the camera the inputs belong to.
  38339. */
  38340. constructor(camera: FlyCamera);
  38341. /**
  38342. * Add keyboard input support to the input manager.
  38343. * @returns the new FlyCameraKeyboardMoveInput().
  38344. */
  38345. addKeyboard(): FlyCameraInputsManager;
  38346. /**
  38347. * Add mouse input support to the input manager.
  38348. * @param touchEnabled Enable touch screen support.
  38349. * @returns the new FlyCameraMouseInput().
  38350. */
  38351. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38352. }
  38353. }
  38354. declare module "babylonjs/Cameras/flyCamera" {
  38355. import { Scene } from "babylonjs/scene";
  38356. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38358. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38359. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38360. /**
  38361. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38362. * such as in a 3D Space Shooter or a Flight Simulator.
  38363. */
  38364. export class FlyCamera extends TargetCamera {
  38365. /**
  38366. * Define the collision ellipsoid of the camera.
  38367. * This is helpful for simulating a camera body, like a player's body.
  38368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38369. */
  38370. ellipsoid: Vector3;
  38371. /**
  38372. * Define an offset for the position of the ellipsoid around the camera.
  38373. * This can be helpful if the camera is attached away from the player's body center,
  38374. * such as at its head.
  38375. */
  38376. ellipsoidOffset: Vector3;
  38377. /**
  38378. * Enable or disable collisions of the camera with the rest of the scene objects.
  38379. */
  38380. checkCollisions: boolean;
  38381. /**
  38382. * Enable or disable gravity on the camera.
  38383. */
  38384. applyGravity: boolean;
  38385. /**
  38386. * Define the current direction the camera is moving to.
  38387. */
  38388. cameraDirection: Vector3;
  38389. /**
  38390. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38391. * This overrides and empties cameraRotation.
  38392. */
  38393. rotationQuaternion: Quaternion;
  38394. /**
  38395. * Track Roll to maintain the wanted Rolling when looking around.
  38396. */
  38397. _trackRoll: number;
  38398. /**
  38399. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38400. */
  38401. rollCorrect: number;
  38402. /**
  38403. * Mimic a banked turn, Rolling the camera when Yawing.
  38404. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38405. */
  38406. bankedTurn: boolean;
  38407. /**
  38408. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38409. */
  38410. bankedTurnLimit: number;
  38411. /**
  38412. * Value of 0 disables the banked Roll.
  38413. * Value of 1 is equal to the Yaw angle in radians.
  38414. */
  38415. bankedTurnMultiplier: number;
  38416. /**
  38417. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38418. */
  38419. inputs: FlyCameraInputsManager;
  38420. /**
  38421. * Gets the input sensibility for mouse input.
  38422. * Higher values reduce sensitivity.
  38423. */
  38424. /**
  38425. * Sets the input sensibility for a mouse input.
  38426. * Higher values reduce sensitivity.
  38427. */
  38428. angularSensibility: number;
  38429. /**
  38430. * Get the keys for camera movement forward.
  38431. */
  38432. /**
  38433. * Set the keys for camera movement forward.
  38434. */
  38435. keysForward: number[];
  38436. /**
  38437. * Get the keys for camera movement backward.
  38438. */
  38439. keysBackward: number[];
  38440. /**
  38441. * Get the keys for camera movement up.
  38442. */
  38443. /**
  38444. * Set the keys for camera movement up.
  38445. */
  38446. keysUp: number[];
  38447. /**
  38448. * Get the keys for camera movement down.
  38449. */
  38450. /**
  38451. * Set the keys for camera movement down.
  38452. */
  38453. keysDown: number[];
  38454. /**
  38455. * Get the keys for camera movement left.
  38456. */
  38457. /**
  38458. * Set the keys for camera movement left.
  38459. */
  38460. keysLeft: number[];
  38461. /**
  38462. * Set the keys for camera movement right.
  38463. */
  38464. /**
  38465. * Set the keys for camera movement right.
  38466. */
  38467. keysRight: number[];
  38468. /**
  38469. * Event raised when the camera collides with a mesh in the scene.
  38470. */
  38471. onCollide: (collidedMesh: AbstractMesh) => void;
  38472. private _collider;
  38473. private _needMoveForGravity;
  38474. private _oldPosition;
  38475. private _diffPosition;
  38476. private _newPosition;
  38477. /** @hidden */
  38478. _localDirection: Vector3;
  38479. /** @hidden */
  38480. _transformedDirection: Vector3;
  38481. /**
  38482. * Instantiates a FlyCamera.
  38483. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38484. * such as in a 3D Space Shooter or a Flight Simulator.
  38485. * @param name Define the name of the camera in the scene.
  38486. * @param position Define the starting position of the camera in the scene.
  38487. * @param scene Define the scene the camera belongs to.
  38488. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38489. */
  38490. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38491. /**
  38492. * Attach a control to the HTML DOM element.
  38493. * @param element Defines the element that listens to the input events.
  38494. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38495. */
  38496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38497. /**
  38498. * Detach a control from the HTML DOM element.
  38499. * The camera will stop reacting to that input.
  38500. * @param element Defines the element that listens to the input events.
  38501. */
  38502. detachControl(element: HTMLElement): void;
  38503. private _collisionMask;
  38504. /**
  38505. * Get the mask that the camera ignores in collision events.
  38506. */
  38507. /**
  38508. * Set the mask that the camera ignores in collision events.
  38509. */
  38510. collisionMask: number;
  38511. /** @hidden */
  38512. _collideWithWorld(displacement: Vector3): void;
  38513. /** @hidden */
  38514. private _onCollisionPositionChange;
  38515. /** @hidden */
  38516. _checkInputs(): void;
  38517. /** @hidden */
  38518. _decideIfNeedsToMove(): boolean;
  38519. /** @hidden */
  38520. _updatePosition(): void;
  38521. /**
  38522. * Restore the Roll to its target value at the rate specified.
  38523. * @param rate - Higher means slower restoring.
  38524. * @hidden
  38525. */
  38526. restoreRoll(rate: number): void;
  38527. /**
  38528. * Destroy the camera and release the current resources held by it.
  38529. */
  38530. dispose(): void;
  38531. /**
  38532. * Get the current object class name.
  38533. * @returns the class name.
  38534. */
  38535. getClassName(): string;
  38536. }
  38537. }
  38538. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38539. import { Nullable } from "babylonjs/types";
  38540. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38541. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38542. /**
  38543. * Listen to keyboard events to control the camera.
  38544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38545. */
  38546. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38547. /**
  38548. * Defines the camera the input is attached to.
  38549. */
  38550. camera: FlyCamera;
  38551. /**
  38552. * The list of keyboard keys used to control the forward move of the camera.
  38553. */
  38554. keysForward: number[];
  38555. /**
  38556. * The list of keyboard keys used to control the backward move of the camera.
  38557. */
  38558. keysBackward: number[];
  38559. /**
  38560. * The list of keyboard keys used to control the forward move of the camera.
  38561. */
  38562. keysUp: number[];
  38563. /**
  38564. * The list of keyboard keys used to control the backward move of the camera.
  38565. */
  38566. keysDown: number[];
  38567. /**
  38568. * The list of keyboard keys used to control the right strafe move of the camera.
  38569. */
  38570. keysRight: number[];
  38571. /**
  38572. * The list of keyboard keys used to control the left strafe move of the camera.
  38573. */
  38574. keysLeft: number[];
  38575. private _keys;
  38576. private _onCanvasBlurObserver;
  38577. private _onKeyboardObserver;
  38578. private _engine;
  38579. private _scene;
  38580. /**
  38581. * Attach the input controls to a specific dom element to get the input from.
  38582. * @param element Defines the element the controls should be listened from
  38583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38584. */
  38585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38586. /**
  38587. * Detach the current controls from the specified dom element.
  38588. * @param element Defines the element to stop listening the inputs from
  38589. */
  38590. detachControl(element: Nullable<HTMLElement>): void;
  38591. /**
  38592. * Gets the class name of the current intput.
  38593. * @returns the class name
  38594. */
  38595. getClassName(): string;
  38596. /** @hidden */
  38597. _onLostFocus(e: FocusEvent): void;
  38598. /**
  38599. * Get the friendly name associated with the input class.
  38600. * @returns the input friendly name
  38601. */
  38602. getSimpleName(): string;
  38603. /**
  38604. * Update the current camera state depending on the inputs that have been used this frame.
  38605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38606. */
  38607. checkInputs(): void;
  38608. }
  38609. }
  38610. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38611. import { Nullable } from "babylonjs/types";
  38612. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38613. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38614. /**
  38615. * Manage the mouse wheel inputs to control a follow camera.
  38616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38617. */
  38618. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38619. /**
  38620. * Defines the camera the input is attached to.
  38621. */
  38622. camera: FollowCamera;
  38623. /**
  38624. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38625. */
  38626. axisControlRadius: boolean;
  38627. /**
  38628. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38629. */
  38630. axisControlHeight: boolean;
  38631. /**
  38632. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38633. */
  38634. axisControlRotation: boolean;
  38635. /**
  38636. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38637. * relation to mouseWheel events.
  38638. */
  38639. wheelPrecision: number;
  38640. /**
  38641. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38642. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38643. */
  38644. wheelDeltaPercentage: number;
  38645. private _wheel;
  38646. private _observer;
  38647. /**
  38648. * Attach the input controls to a specific dom element to get the input from.
  38649. * @param element Defines the element the controls should be listened from
  38650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38651. */
  38652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38653. /**
  38654. * Detach the current controls from the specified dom element.
  38655. * @param element Defines the element to stop listening the inputs from
  38656. */
  38657. detachControl(element: Nullable<HTMLElement>): void;
  38658. /**
  38659. * Gets the class name of the current intput.
  38660. * @returns the class name
  38661. */
  38662. getClassName(): string;
  38663. /**
  38664. * Get the friendly name associated with the input class.
  38665. * @returns the input friendly name
  38666. */
  38667. getSimpleName(): string;
  38668. }
  38669. }
  38670. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38671. import { Nullable } from "babylonjs/types";
  38672. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38673. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38674. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38675. /**
  38676. * Manage the pointers inputs to control an follow camera.
  38677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38678. */
  38679. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38680. /**
  38681. * Defines the camera the input is attached to.
  38682. */
  38683. camera: FollowCamera;
  38684. /**
  38685. * Gets the class name of the current input.
  38686. * @returns the class name
  38687. */
  38688. getClassName(): string;
  38689. /**
  38690. * Defines the pointer angular sensibility along the X axis or how fast is
  38691. * the camera rotating.
  38692. * A negative number will reverse the axis direction.
  38693. */
  38694. angularSensibilityX: number;
  38695. /**
  38696. * Defines the pointer angular sensibility along the Y axis or how fast is
  38697. * the camera rotating.
  38698. * A negative number will reverse the axis direction.
  38699. */
  38700. angularSensibilityY: number;
  38701. /**
  38702. * Defines the pointer pinch precision or how fast is the camera zooming.
  38703. * A negative number will reverse the axis direction.
  38704. */
  38705. pinchPrecision: number;
  38706. /**
  38707. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38708. * from 0.
  38709. * It defines the percentage of current camera.radius to use as delta when
  38710. * pinch zoom is used.
  38711. */
  38712. pinchDeltaPercentage: number;
  38713. /**
  38714. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38715. */
  38716. axisXControlRadius: boolean;
  38717. /**
  38718. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38719. */
  38720. axisXControlHeight: boolean;
  38721. /**
  38722. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38723. */
  38724. axisXControlRotation: boolean;
  38725. /**
  38726. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38727. */
  38728. axisYControlRadius: boolean;
  38729. /**
  38730. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38731. */
  38732. axisYControlHeight: boolean;
  38733. /**
  38734. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38735. */
  38736. axisYControlRotation: boolean;
  38737. /**
  38738. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38739. */
  38740. axisPinchControlRadius: boolean;
  38741. /**
  38742. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38743. */
  38744. axisPinchControlHeight: boolean;
  38745. /**
  38746. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38747. */
  38748. axisPinchControlRotation: boolean;
  38749. /**
  38750. * Log error messages if basic misconfiguration has occurred.
  38751. */
  38752. warningEnable: boolean;
  38753. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38754. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38755. private _warningCounter;
  38756. private _warning;
  38757. }
  38758. }
  38759. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38760. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38761. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38762. /**
  38763. * Default Inputs manager for the FollowCamera.
  38764. * It groups all the default supported inputs for ease of use.
  38765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38766. */
  38767. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38768. /**
  38769. * Instantiates a new FollowCameraInputsManager.
  38770. * @param camera Defines the camera the inputs belong to
  38771. */
  38772. constructor(camera: FollowCamera);
  38773. /**
  38774. * Add keyboard input support to the input manager.
  38775. * @returns the current input manager
  38776. */
  38777. addKeyboard(): FollowCameraInputsManager;
  38778. /**
  38779. * Add mouse wheel input support to the input manager.
  38780. * @returns the current input manager
  38781. */
  38782. addMouseWheel(): FollowCameraInputsManager;
  38783. /**
  38784. * Add pointers input support to the input manager.
  38785. * @returns the current input manager
  38786. */
  38787. addPointers(): FollowCameraInputsManager;
  38788. /**
  38789. * Add orientation input support to the input manager.
  38790. * @returns the current input manager
  38791. */
  38792. addVRDeviceOrientation(): FollowCameraInputsManager;
  38793. }
  38794. }
  38795. declare module "babylonjs/Cameras/followCamera" {
  38796. import { Nullable } from "babylonjs/types";
  38797. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38798. import { Scene } from "babylonjs/scene";
  38799. import { Vector3 } from "babylonjs/Maths/math.vector";
  38800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38801. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38802. /**
  38803. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38804. * an arc rotate version arcFollowCamera are available.
  38805. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38806. */
  38807. export class FollowCamera extends TargetCamera {
  38808. /**
  38809. * Distance the follow camera should follow an object at
  38810. */
  38811. radius: number;
  38812. /**
  38813. * Minimum allowed distance of the camera to the axis of rotation
  38814. * (The camera can not get closer).
  38815. * This can help limiting how the Camera is able to move in the scene.
  38816. */
  38817. lowerRadiusLimit: Nullable<number>;
  38818. /**
  38819. * Maximum allowed distance of the camera to the axis of rotation
  38820. * (The camera can not get further).
  38821. * This can help limiting how the Camera is able to move in the scene.
  38822. */
  38823. upperRadiusLimit: Nullable<number>;
  38824. /**
  38825. * Define a rotation offset between the camera and the object it follows
  38826. */
  38827. rotationOffset: number;
  38828. /**
  38829. * Minimum allowed angle to camera position relative to target object.
  38830. * This can help limiting how the Camera is able to move in the scene.
  38831. */
  38832. lowerRotationOffsetLimit: Nullable<number>;
  38833. /**
  38834. * Maximum allowed angle to camera position relative to target object.
  38835. * This can help limiting how the Camera is able to move in the scene.
  38836. */
  38837. upperRotationOffsetLimit: Nullable<number>;
  38838. /**
  38839. * Define a height offset between the camera and the object it follows.
  38840. * It can help following an object from the top (like a car chaing a plane)
  38841. */
  38842. heightOffset: number;
  38843. /**
  38844. * Minimum allowed height of camera position relative to target object.
  38845. * This can help limiting how the Camera is able to move in the scene.
  38846. */
  38847. lowerHeightOffsetLimit: Nullable<number>;
  38848. /**
  38849. * Maximum allowed height of camera position relative to target object.
  38850. * This can help limiting how the Camera is able to move in the scene.
  38851. */
  38852. upperHeightOffsetLimit: Nullable<number>;
  38853. /**
  38854. * Define how fast the camera can accelerate to follow it s target.
  38855. */
  38856. cameraAcceleration: number;
  38857. /**
  38858. * Define the speed limit of the camera following an object.
  38859. */
  38860. maxCameraSpeed: number;
  38861. /**
  38862. * Define the target of the camera.
  38863. */
  38864. lockedTarget: Nullable<AbstractMesh>;
  38865. /**
  38866. * Defines the input associated with the camera.
  38867. */
  38868. inputs: FollowCameraInputsManager;
  38869. /**
  38870. * Instantiates the follow camera.
  38871. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38872. * @param name Define the name of the camera in the scene
  38873. * @param position Define the position of the camera
  38874. * @param scene Define the scene the camera belong to
  38875. * @param lockedTarget Define the target of the camera
  38876. */
  38877. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38878. private _follow;
  38879. /**
  38880. * Attached controls to the current camera.
  38881. * @param element Defines the element the controls should be listened from
  38882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38883. */
  38884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38885. /**
  38886. * Detach the current controls from the camera.
  38887. * The camera will stop reacting to inputs.
  38888. * @param element Defines the element to stop listening the inputs from
  38889. */
  38890. detachControl(element: HTMLElement): void;
  38891. /** @hidden */
  38892. _checkInputs(): void;
  38893. private _checkLimits;
  38894. /**
  38895. * Gets the camera class name.
  38896. * @returns the class name
  38897. */
  38898. getClassName(): string;
  38899. }
  38900. /**
  38901. * Arc Rotate version of the follow camera.
  38902. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38903. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38904. */
  38905. export class ArcFollowCamera extends TargetCamera {
  38906. /** The longitudinal angle of the camera */
  38907. alpha: number;
  38908. /** The latitudinal angle of the camera */
  38909. beta: number;
  38910. /** The radius of the camera from its target */
  38911. radius: number;
  38912. /** Define the camera target (the messh it should follow) */
  38913. target: Nullable<AbstractMesh>;
  38914. private _cartesianCoordinates;
  38915. /**
  38916. * Instantiates a new ArcFollowCamera
  38917. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38918. * @param name Define the name of the camera
  38919. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38920. * @param beta Define the rotation angle of the camera around the elevation axis
  38921. * @param radius Define the radius of the camera from its target point
  38922. * @param target Define the target of the camera
  38923. * @param scene Define the scene the camera belongs to
  38924. */
  38925. constructor(name: string,
  38926. /** The longitudinal angle of the camera */
  38927. alpha: number,
  38928. /** The latitudinal angle of the camera */
  38929. beta: number,
  38930. /** The radius of the camera from its target */
  38931. radius: number,
  38932. /** Define the camera target (the messh it should follow) */
  38933. target: Nullable<AbstractMesh>, scene: Scene);
  38934. private _follow;
  38935. /** @hidden */
  38936. _checkInputs(): void;
  38937. /**
  38938. * Returns the class name of the object.
  38939. * It is mostly used internally for serialization purposes.
  38940. */
  38941. getClassName(): string;
  38942. }
  38943. }
  38944. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38945. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38946. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38947. import { Nullable } from "babylonjs/types";
  38948. /**
  38949. * Manage the keyboard inputs to control the movement of a follow camera.
  38950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38951. */
  38952. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38953. /**
  38954. * Defines the camera the input is attached to.
  38955. */
  38956. camera: FollowCamera;
  38957. /**
  38958. * Defines the list of key codes associated with the up action (increase heightOffset)
  38959. */
  38960. keysHeightOffsetIncr: number[];
  38961. /**
  38962. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38963. */
  38964. keysHeightOffsetDecr: number[];
  38965. /**
  38966. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38967. */
  38968. keysHeightOffsetModifierAlt: boolean;
  38969. /**
  38970. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38971. */
  38972. keysHeightOffsetModifierCtrl: boolean;
  38973. /**
  38974. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38975. */
  38976. keysHeightOffsetModifierShift: boolean;
  38977. /**
  38978. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38979. */
  38980. keysRotationOffsetIncr: number[];
  38981. /**
  38982. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38983. */
  38984. keysRotationOffsetDecr: number[];
  38985. /**
  38986. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38987. */
  38988. keysRotationOffsetModifierAlt: boolean;
  38989. /**
  38990. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38991. */
  38992. keysRotationOffsetModifierCtrl: boolean;
  38993. /**
  38994. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38995. */
  38996. keysRotationOffsetModifierShift: boolean;
  38997. /**
  38998. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38999. */
  39000. keysRadiusIncr: number[];
  39001. /**
  39002. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39003. */
  39004. keysRadiusDecr: number[];
  39005. /**
  39006. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39007. */
  39008. keysRadiusModifierAlt: boolean;
  39009. /**
  39010. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39011. */
  39012. keysRadiusModifierCtrl: boolean;
  39013. /**
  39014. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39015. */
  39016. keysRadiusModifierShift: boolean;
  39017. /**
  39018. * Defines the rate of change of heightOffset.
  39019. */
  39020. heightSensibility: number;
  39021. /**
  39022. * Defines the rate of change of rotationOffset.
  39023. */
  39024. rotationSensibility: number;
  39025. /**
  39026. * Defines the rate of change of radius.
  39027. */
  39028. radiusSensibility: number;
  39029. private _keys;
  39030. private _ctrlPressed;
  39031. private _altPressed;
  39032. private _shiftPressed;
  39033. private _onCanvasBlurObserver;
  39034. private _onKeyboardObserver;
  39035. private _engine;
  39036. private _scene;
  39037. /**
  39038. * Attach the input controls to a specific dom element to get the input from.
  39039. * @param element Defines the element the controls should be listened from
  39040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39041. */
  39042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39043. /**
  39044. * Detach the current controls from the specified dom element.
  39045. * @param element Defines the element to stop listening the inputs from
  39046. */
  39047. detachControl(element: Nullable<HTMLElement>): void;
  39048. /**
  39049. * Update the current camera state depending on the inputs that have been used this frame.
  39050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39051. */
  39052. checkInputs(): void;
  39053. /**
  39054. * Gets the class name of the current input.
  39055. * @returns the class name
  39056. */
  39057. getClassName(): string;
  39058. /**
  39059. * Get the friendly name associated with the input class.
  39060. * @returns the input friendly name
  39061. */
  39062. getSimpleName(): string;
  39063. /**
  39064. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39065. * allow modification of the heightOffset value.
  39066. */
  39067. private _modifierHeightOffset;
  39068. /**
  39069. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39070. * allow modification of the rotationOffset value.
  39071. */
  39072. private _modifierRotationOffset;
  39073. /**
  39074. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39075. * allow modification of the radius value.
  39076. */
  39077. private _modifierRadius;
  39078. }
  39079. }
  39080. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39081. import { Nullable } from "babylonjs/types";
  39082. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39084. import { Observable } from "babylonjs/Misc/observable";
  39085. module "babylonjs/Cameras/freeCameraInputsManager" {
  39086. interface FreeCameraInputsManager {
  39087. /**
  39088. * @hidden
  39089. */
  39090. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39091. /**
  39092. * Add orientation input support to the input manager.
  39093. * @returns the current input manager
  39094. */
  39095. addDeviceOrientation(): FreeCameraInputsManager;
  39096. }
  39097. }
  39098. /**
  39099. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39100. * Screen rotation is taken into account.
  39101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39102. */
  39103. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39104. private _camera;
  39105. private _screenOrientationAngle;
  39106. private _constantTranform;
  39107. private _screenQuaternion;
  39108. private _alpha;
  39109. private _beta;
  39110. private _gamma;
  39111. /**
  39112. * Can be used to detect if a device orientation sensor is availible on a device
  39113. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39114. * @returns a promise that will resolve on orientation change
  39115. */
  39116. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39117. /**
  39118. * @hidden
  39119. */
  39120. _onDeviceOrientationChangedObservable: Observable<void>;
  39121. /**
  39122. * Instantiates a new input
  39123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39124. */
  39125. constructor();
  39126. /**
  39127. * Define the camera controlled by the input.
  39128. */
  39129. camera: FreeCamera;
  39130. /**
  39131. * Attach the input controls to a specific dom element to get the input from.
  39132. * @param element Defines the element the controls should be listened from
  39133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39134. */
  39135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39136. private _orientationChanged;
  39137. private _deviceOrientation;
  39138. /**
  39139. * Detach the current controls from the specified dom element.
  39140. * @param element Defines the element to stop listening the inputs from
  39141. */
  39142. detachControl(element: Nullable<HTMLElement>): void;
  39143. /**
  39144. * Update the current camera state depending on the inputs that have been used this frame.
  39145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39146. */
  39147. checkInputs(): void;
  39148. /**
  39149. * Gets the class name of the current intput.
  39150. * @returns the class name
  39151. */
  39152. getClassName(): string;
  39153. /**
  39154. * Get the friendly name associated with the input class.
  39155. * @returns the input friendly name
  39156. */
  39157. getSimpleName(): string;
  39158. }
  39159. }
  39160. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39161. import { Nullable } from "babylonjs/types";
  39162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39164. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39165. /**
  39166. * Manage the gamepad inputs to control a free camera.
  39167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39168. */
  39169. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39170. /**
  39171. * Define the camera the input is attached to.
  39172. */
  39173. camera: FreeCamera;
  39174. /**
  39175. * Define the Gamepad controlling the input
  39176. */
  39177. gamepad: Nullable<Gamepad>;
  39178. /**
  39179. * Defines the gamepad rotation sensiblity.
  39180. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39181. */
  39182. gamepadAngularSensibility: number;
  39183. /**
  39184. * Defines the gamepad move sensiblity.
  39185. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39186. */
  39187. gamepadMoveSensibility: number;
  39188. private _onGamepadConnectedObserver;
  39189. private _onGamepadDisconnectedObserver;
  39190. private _cameraTransform;
  39191. private _deltaTransform;
  39192. private _vector3;
  39193. private _vector2;
  39194. /**
  39195. * Attach the input controls to a specific dom element to get the input from.
  39196. * @param element Defines the element the controls should be listened from
  39197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39198. */
  39199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39200. /**
  39201. * Detach the current controls from the specified dom element.
  39202. * @param element Defines the element to stop listening the inputs from
  39203. */
  39204. detachControl(element: Nullable<HTMLElement>): void;
  39205. /**
  39206. * Update the current camera state depending on the inputs that have been used this frame.
  39207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39208. */
  39209. checkInputs(): void;
  39210. /**
  39211. * Gets the class name of the current intput.
  39212. * @returns the class name
  39213. */
  39214. getClassName(): string;
  39215. /**
  39216. * Get the friendly name associated with the input class.
  39217. * @returns the input friendly name
  39218. */
  39219. getSimpleName(): string;
  39220. }
  39221. }
  39222. declare module "babylonjs/Misc/virtualJoystick" {
  39223. import { Nullable } from "babylonjs/types";
  39224. import { Vector3 } from "babylonjs/Maths/math.vector";
  39225. /**
  39226. * Defines the potential axis of a Joystick
  39227. */
  39228. export enum JoystickAxis {
  39229. /** X axis */
  39230. X = 0,
  39231. /** Y axis */
  39232. Y = 1,
  39233. /** Z axis */
  39234. Z = 2
  39235. }
  39236. /**
  39237. * Class used to define virtual joystick (used in touch mode)
  39238. */
  39239. export class VirtualJoystick {
  39240. /**
  39241. * Gets or sets a boolean indicating that left and right values must be inverted
  39242. */
  39243. reverseLeftRight: boolean;
  39244. /**
  39245. * Gets or sets a boolean indicating that up and down values must be inverted
  39246. */
  39247. reverseUpDown: boolean;
  39248. /**
  39249. * Gets the offset value for the position (ie. the change of the position value)
  39250. */
  39251. deltaPosition: Vector3;
  39252. /**
  39253. * Gets a boolean indicating if the virtual joystick was pressed
  39254. */
  39255. pressed: boolean;
  39256. /**
  39257. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39258. */
  39259. static Canvas: Nullable<HTMLCanvasElement>;
  39260. private static _globalJoystickIndex;
  39261. private static vjCanvasContext;
  39262. private static vjCanvasWidth;
  39263. private static vjCanvasHeight;
  39264. private static halfWidth;
  39265. private _action;
  39266. private _axisTargetedByLeftAndRight;
  39267. private _axisTargetedByUpAndDown;
  39268. private _joystickSensibility;
  39269. private _inversedSensibility;
  39270. private _joystickPointerID;
  39271. private _joystickColor;
  39272. private _joystickPointerPos;
  39273. private _joystickPreviousPointerPos;
  39274. private _joystickPointerStartPos;
  39275. private _deltaJoystickVector;
  39276. private _leftJoystick;
  39277. private _touches;
  39278. private _onPointerDownHandlerRef;
  39279. private _onPointerMoveHandlerRef;
  39280. private _onPointerUpHandlerRef;
  39281. private _onResize;
  39282. /**
  39283. * Creates a new virtual joystick
  39284. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39285. */
  39286. constructor(leftJoystick?: boolean);
  39287. /**
  39288. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39289. * @param newJoystickSensibility defines the new sensibility
  39290. */
  39291. setJoystickSensibility(newJoystickSensibility: number): void;
  39292. private _onPointerDown;
  39293. private _onPointerMove;
  39294. private _onPointerUp;
  39295. /**
  39296. * Change the color of the virtual joystick
  39297. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39298. */
  39299. setJoystickColor(newColor: string): void;
  39300. /**
  39301. * Defines a callback to call when the joystick is touched
  39302. * @param action defines the callback
  39303. */
  39304. setActionOnTouch(action: () => any): void;
  39305. /**
  39306. * Defines which axis you'd like to control for left & right
  39307. * @param axis defines the axis to use
  39308. */
  39309. setAxisForLeftRight(axis: JoystickAxis): void;
  39310. /**
  39311. * Defines which axis you'd like to control for up & down
  39312. * @param axis defines the axis to use
  39313. */
  39314. setAxisForUpDown(axis: JoystickAxis): void;
  39315. private _drawVirtualJoystick;
  39316. /**
  39317. * Release internal HTML canvas
  39318. */
  39319. releaseCanvas(): void;
  39320. }
  39321. }
  39322. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39323. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39324. import { Nullable } from "babylonjs/types";
  39325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39327. module "babylonjs/Cameras/freeCameraInputsManager" {
  39328. interface FreeCameraInputsManager {
  39329. /**
  39330. * Add virtual joystick input support to the input manager.
  39331. * @returns the current input manager
  39332. */
  39333. addVirtualJoystick(): FreeCameraInputsManager;
  39334. }
  39335. }
  39336. /**
  39337. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39339. */
  39340. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39341. /**
  39342. * Defines the camera the input is attached to.
  39343. */
  39344. camera: FreeCamera;
  39345. private _leftjoystick;
  39346. private _rightjoystick;
  39347. /**
  39348. * Gets the left stick of the virtual joystick.
  39349. * @returns The virtual Joystick
  39350. */
  39351. getLeftJoystick(): VirtualJoystick;
  39352. /**
  39353. * Gets the right stick of the virtual joystick.
  39354. * @returns The virtual Joystick
  39355. */
  39356. getRightJoystick(): VirtualJoystick;
  39357. /**
  39358. * Update the current camera state depending on the inputs that have been used this frame.
  39359. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39360. */
  39361. checkInputs(): void;
  39362. /**
  39363. * Attach the input controls to a specific dom element to get the input from.
  39364. * @param element Defines the element the controls should be listened from
  39365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39366. */
  39367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39368. /**
  39369. * Detach the current controls from the specified dom element.
  39370. * @param element Defines the element to stop listening the inputs from
  39371. */
  39372. detachControl(element: Nullable<HTMLElement>): void;
  39373. /**
  39374. * Gets the class name of the current intput.
  39375. * @returns the class name
  39376. */
  39377. getClassName(): string;
  39378. /**
  39379. * Get the friendly name associated with the input class.
  39380. * @returns the input friendly name
  39381. */
  39382. getSimpleName(): string;
  39383. }
  39384. }
  39385. declare module "babylonjs/Cameras/Inputs/index" {
  39386. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39387. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39388. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39389. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39390. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39391. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39392. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39393. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39394. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39395. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39396. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39397. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39398. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39399. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39400. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39401. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39402. }
  39403. declare module "babylonjs/Cameras/touchCamera" {
  39404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39405. import { Scene } from "babylonjs/scene";
  39406. import { Vector3 } from "babylonjs/Maths/math.vector";
  39407. /**
  39408. * This represents a FPS type of camera controlled by touch.
  39409. * This is like a universal camera minus the Gamepad controls.
  39410. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39411. */
  39412. export class TouchCamera extends FreeCamera {
  39413. /**
  39414. * Defines the touch sensibility for rotation.
  39415. * The higher the faster.
  39416. */
  39417. touchAngularSensibility: number;
  39418. /**
  39419. * Defines the touch sensibility for move.
  39420. * The higher the faster.
  39421. */
  39422. touchMoveSensibility: number;
  39423. /**
  39424. * Instantiates a new touch camera.
  39425. * This represents a FPS type of camera controlled by touch.
  39426. * This is like a universal camera minus the Gamepad controls.
  39427. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39428. * @param name Define the name of the camera in the scene
  39429. * @param position Define the start position of the camera in the scene
  39430. * @param scene Define the scene the camera belongs to
  39431. */
  39432. constructor(name: string, position: Vector3, scene: Scene);
  39433. /**
  39434. * Gets the current object class name.
  39435. * @return the class name
  39436. */
  39437. getClassName(): string;
  39438. /** @hidden */
  39439. _setupInputs(): void;
  39440. }
  39441. }
  39442. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39443. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39444. import { Scene } from "babylonjs/scene";
  39445. import { Vector3 } from "babylonjs/Maths/math.vector";
  39446. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39447. import { Axis } from "babylonjs/Maths/math.axis";
  39448. /**
  39449. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39450. * being tilted forward or back and left or right.
  39451. */
  39452. export class DeviceOrientationCamera extends FreeCamera {
  39453. private _initialQuaternion;
  39454. private _quaternionCache;
  39455. private _tmpDragQuaternion;
  39456. private _disablePointerInputWhenUsingDeviceOrientation;
  39457. /**
  39458. * Creates a new device orientation camera
  39459. * @param name The name of the camera
  39460. * @param position The start position camera
  39461. * @param scene The scene the camera belongs to
  39462. */
  39463. constructor(name: string, position: Vector3, scene: Scene);
  39464. /**
  39465. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39466. */
  39467. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39468. private _dragFactor;
  39469. /**
  39470. * Enabled turning on the y axis when the orientation sensor is active
  39471. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39472. */
  39473. enableHorizontalDragging(dragFactor?: number): void;
  39474. /**
  39475. * Gets the current instance class name ("DeviceOrientationCamera").
  39476. * This helps avoiding instanceof at run time.
  39477. * @returns the class name
  39478. */
  39479. getClassName(): string;
  39480. /**
  39481. * @hidden
  39482. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39483. */
  39484. _checkInputs(): void;
  39485. /**
  39486. * Reset the camera to its default orientation on the specified axis only.
  39487. * @param axis The axis to reset
  39488. */
  39489. resetToCurrentRotation(axis?: Axis): void;
  39490. }
  39491. }
  39492. declare module "babylonjs/Gamepads/xboxGamepad" {
  39493. import { Observable } from "babylonjs/Misc/observable";
  39494. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39495. /**
  39496. * Defines supported buttons for XBox360 compatible gamepads
  39497. */
  39498. export enum Xbox360Button {
  39499. /** A */
  39500. A = 0,
  39501. /** B */
  39502. B = 1,
  39503. /** X */
  39504. X = 2,
  39505. /** Y */
  39506. Y = 3,
  39507. /** Start */
  39508. Start = 4,
  39509. /** Back */
  39510. Back = 5,
  39511. /** Left button */
  39512. LB = 6,
  39513. /** Right button */
  39514. RB = 7,
  39515. /** Left stick */
  39516. LeftStick = 8,
  39517. /** Right stick */
  39518. RightStick = 9
  39519. }
  39520. /** Defines values for XBox360 DPad */
  39521. export enum Xbox360Dpad {
  39522. /** Up */
  39523. Up = 0,
  39524. /** Down */
  39525. Down = 1,
  39526. /** Left */
  39527. Left = 2,
  39528. /** Right */
  39529. Right = 3
  39530. }
  39531. /**
  39532. * Defines a XBox360 gamepad
  39533. */
  39534. export class Xbox360Pad extends Gamepad {
  39535. private _leftTrigger;
  39536. private _rightTrigger;
  39537. private _onlefttriggerchanged;
  39538. private _onrighttriggerchanged;
  39539. private _onbuttondown;
  39540. private _onbuttonup;
  39541. private _ondpaddown;
  39542. private _ondpadup;
  39543. /** Observable raised when a button is pressed */
  39544. onButtonDownObservable: Observable<Xbox360Button>;
  39545. /** Observable raised when a button is released */
  39546. onButtonUpObservable: Observable<Xbox360Button>;
  39547. /** Observable raised when a pad is pressed */
  39548. onPadDownObservable: Observable<Xbox360Dpad>;
  39549. /** Observable raised when a pad is released */
  39550. onPadUpObservable: Observable<Xbox360Dpad>;
  39551. private _buttonA;
  39552. private _buttonB;
  39553. private _buttonX;
  39554. private _buttonY;
  39555. private _buttonBack;
  39556. private _buttonStart;
  39557. private _buttonLB;
  39558. private _buttonRB;
  39559. private _buttonLeftStick;
  39560. private _buttonRightStick;
  39561. private _dPadUp;
  39562. private _dPadDown;
  39563. private _dPadLeft;
  39564. private _dPadRight;
  39565. private _isXboxOnePad;
  39566. /**
  39567. * Creates a new XBox360 gamepad object
  39568. * @param id defines the id of this gamepad
  39569. * @param index defines its index
  39570. * @param gamepad defines the internal HTML gamepad object
  39571. * @param xboxOne defines if it is a XBox One gamepad
  39572. */
  39573. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39574. /**
  39575. * Defines the callback to call when left trigger is pressed
  39576. * @param callback defines the callback to use
  39577. */
  39578. onlefttriggerchanged(callback: (value: number) => void): void;
  39579. /**
  39580. * Defines the callback to call when right trigger is pressed
  39581. * @param callback defines the callback to use
  39582. */
  39583. onrighttriggerchanged(callback: (value: number) => void): void;
  39584. /**
  39585. * Gets the left trigger value
  39586. */
  39587. /**
  39588. * Sets the left trigger value
  39589. */
  39590. leftTrigger: number;
  39591. /**
  39592. * Gets the right trigger value
  39593. */
  39594. /**
  39595. * Sets the right trigger value
  39596. */
  39597. rightTrigger: number;
  39598. /**
  39599. * Defines the callback to call when a button is pressed
  39600. * @param callback defines the callback to use
  39601. */
  39602. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39603. /**
  39604. * Defines the callback to call when a button is released
  39605. * @param callback defines the callback to use
  39606. */
  39607. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39608. /**
  39609. * Defines the callback to call when a pad is pressed
  39610. * @param callback defines the callback to use
  39611. */
  39612. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39613. /**
  39614. * Defines the callback to call when a pad is released
  39615. * @param callback defines the callback to use
  39616. */
  39617. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39618. private _setButtonValue;
  39619. private _setDPadValue;
  39620. /**
  39621. * Gets the value of the `A` button
  39622. */
  39623. /**
  39624. * Sets the value of the `A` button
  39625. */
  39626. buttonA: number;
  39627. /**
  39628. * Gets the value of the `B` button
  39629. */
  39630. /**
  39631. * Sets the value of the `B` button
  39632. */
  39633. buttonB: number;
  39634. /**
  39635. * Gets the value of the `X` button
  39636. */
  39637. /**
  39638. * Sets the value of the `X` button
  39639. */
  39640. buttonX: number;
  39641. /**
  39642. * Gets the value of the `Y` button
  39643. */
  39644. /**
  39645. * Sets the value of the `Y` button
  39646. */
  39647. buttonY: number;
  39648. /**
  39649. * Gets the value of the `Start` button
  39650. */
  39651. /**
  39652. * Sets the value of the `Start` button
  39653. */
  39654. buttonStart: number;
  39655. /**
  39656. * Gets the value of the `Back` button
  39657. */
  39658. /**
  39659. * Sets the value of the `Back` button
  39660. */
  39661. buttonBack: number;
  39662. /**
  39663. * Gets the value of the `Left` button
  39664. */
  39665. /**
  39666. * Sets the value of the `Left` button
  39667. */
  39668. buttonLB: number;
  39669. /**
  39670. * Gets the value of the `Right` button
  39671. */
  39672. /**
  39673. * Sets the value of the `Right` button
  39674. */
  39675. buttonRB: number;
  39676. /**
  39677. * Gets the value of the Left joystick
  39678. */
  39679. /**
  39680. * Sets the value of the Left joystick
  39681. */
  39682. buttonLeftStick: number;
  39683. /**
  39684. * Gets the value of the Right joystick
  39685. */
  39686. /**
  39687. * Sets the value of the Right joystick
  39688. */
  39689. buttonRightStick: number;
  39690. /**
  39691. * Gets the value of D-pad up
  39692. */
  39693. /**
  39694. * Sets the value of D-pad up
  39695. */
  39696. dPadUp: number;
  39697. /**
  39698. * Gets the value of D-pad down
  39699. */
  39700. /**
  39701. * Sets the value of D-pad down
  39702. */
  39703. dPadDown: number;
  39704. /**
  39705. * Gets the value of D-pad left
  39706. */
  39707. /**
  39708. * Sets the value of D-pad left
  39709. */
  39710. dPadLeft: number;
  39711. /**
  39712. * Gets the value of D-pad right
  39713. */
  39714. /**
  39715. * Sets the value of D-pad right
  39716. */
  39717. dPadRight: number;
  39718. /**
  39719. * Force the gamepad to synchronize with device values
  39720. */
  39721. update(): void;
  39722. /**
  39723. * Disposes the gamepad
  39724. */
  39725. dispose(): void;
  39726. }
  39727. }
  39728. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39729. import { Observable } from "babylonjs/Misc/observable";
  39730. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39731. /**
  39732. * Defines supported buttons for DualShock compatible gamepads
  39733. */
  39734. export enum DualShockButton {
  39735. /** Cross */
  39736. Cross = 0,
  39737. /** Circle */
  39738. Circle = 1,
  39739. /** Square */
  39740. Square = 2,
  39741. /** Triangle */
  39742. Triangle = 3,
  39743. /** Options */
  39744. Options = 4,
  39745. /** Share */
  39746. Share = 5,
  39747. /** L1 */
  39748. L1 = 6,
  39749. /** R1 */
  39750. R1 = 7,
  39751. /** Left stick */
  39752. LeftStick = 8,
  39753. /** Right stick */
  39754. RightStick = 9
  39755. }
  39756. /** Defines values for DualShock DPad */
  39757. export enum DualShockDpad {
  39758. /** Up */
  39759. Up = 0,
  39760. /** Down */
  39761. Down = 1,
  39762. /** Left */
  39763. Left = 2,
  39764. /** Right */
  39765. Right = 3
  39766. }
  39767. /**
  39768. * Defines a DualShock gamepad
  39769. */
  39770. export class DualShockPad extends Gamepad {
  39771. private _leftTrigger;
  39772. private _rightTrigger;
  39773. private _onlefttriggerchanged;
  39774. private _onrighttriggerchanged;
  39775. private _onbuttondown;
  39776. private _onbuttonup;
  39777. private _ondpaddown;
  39778. private _ondpadup;
  39779. /** Observable raised when a button is pressed */
  39780. onButtonDownObservable: Observable<DualShockButton>;
  39781. /** Observable raised when a button is released */
  39782. onButtonUpObservable: Observable<DualShockButton>;
  39783. /** Observable raised when a pad is pressed */
  39784. onPadDownObservable: Observable<DualShockDpad>;
  39785. /** Observable raised when a pad is released */
  39786. onPadUpObservable: Observable<DualShockDpad>;
  39787. private _buttonCross;
  39788. private _buttonCircle;
  39789. private _buttonSquare;
  39790. private _buttonTriangle;
  39791. private _buttonShare;
  39792. private _buttonOptions;
  39793. private _buttonL1;
  39794. private _buttonR1;
  39795. private _buttonLeftStick;
  39796. private _buttonRightStick;
  39797. private _dPadUp;
  39798. private _dPadDown;
  39799. private _dPadLeft;
  39800. private _dPadRight;
  39801. /**
  39802. * Creates a new DualShock gamepad object
  39803. * @param id defines the id of this gamepad
  39804. * @param index defines its index
  39805. * @param gamepad defines the internal HTML gamepad object
  39806. */
  39807. constructor(id: string, index: number, gamepad: any);
  39808. /**
  39809. * Defines the callback to call when left trigger is pressed
  39810. * @param callback defines the callback to use
  39811. */
  39812. onlefttriggerchanged(callback: (value: number) => void): void;
  39813. /**
  39814. * Defines the callback to call when right trigger is pressed
  39815. * @param callback defines the callback to use
  39816. */
  39817. onrighttriggerchanged(callback: (value: number) => void): void;
  39818. /**
  39819. * Gets the left trigger value
  39820. */
  39821. /**
  39822. * Sets the left trigger value
  39823. */
  39824. leftTrigger: number;
  39825. /**
  39826. * Gets the right trigger value
  39827. */
  39828. /**
  39829. * Sets the right trigger value
  39830. */
  39831. rightTrigger: number;
  39832. /**
  39833. * Defines the callback to call when a button is pressed
  39834. * @param callback defines the callback to use
  39835. */
  39836. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39837. /**
  39838. * Defines the callback to call when a button is released
  39839. * @param callback defines the callback to use
  39840. */
  39841. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39842. /**
  39843. * Defines the callback to call when a pad is pressed
  39844. * @param callback defines the callback to use
  39845. */
  39846. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39847. /**
  39848. * Defines the callback to call when a pad is released
  39849. * @param callback defines the callback to use
  39850. */
  39851. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39852. private _setButtonValue;
  39853. private _setDPadValue;
  39854. /**
  39855. * Gets the value of the `Cross` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Cross` button
  39859. */
  39860. buttonCross: number;
  39861. /**
  39862. * Gets the value of the `Circle` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Circle` button
  39866. */
  39867. buttonCircle: number;
  39868. /**
  39869. * Gets the value of the `Square` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Square` button
  39873. */
  39874. buttonSquare: number;
  39875. /**
  39876. * Gets the value of the `Triangle` button
  39877. */
  39878. /**
  39879. * Sets the value of the `Triangle` button
  39880. */
  39881. buttonTriangle: number;
  39882. /**
  39883. * Gets the value of the `Options` button
  39884. */
  39885. /**
  39886. * Sets the value of the `Options` button
  39887. */
  39888. buttonOptions: number;
  39889. /**
  39890. * Gets the value of the `Share` button
  39891. */
  39892. /**
  39893. * Sets the value of the `Share` button
  39894. */
  39895. buttonShare: number;
  39896. /**
  39897. * Gets the value of the `L1` button
  39898. */
  39899. /**
  39900. * Sets the value of the `L1` button
  39901. */
  39902. buttonL1: number;
  39903. /**
  39904. * Gets the value of the `R1` button
  39905. */
  39906. /**
  39907. * Sets the value of the `R1` button
  39908. */
  39909. buttonR1: number;
  39910. /**
  39911. * Gets the value of the Left joystick
  39912. */
  39913. /**
  39914. * Sets the value of the Left joystick
  39915. */
  39916. buttonLeftStick: number;
  39917. /**
  39918. * Gets the value of the Right joystick
  39919. */
  39920. /**
  39921. * Sets the value of the Right joystick
  39922. */
  39923. buttonRightStick: number;
  39924. /**
  39925. * Gets the value of D-pad up
  39926. */
  39927. /**
  39928. * Sets the value of D-pad up
  39929. */
  39930. dPadUp: number;
  39931. /**
  39932. * Gets the value of D-pad down
  39933. */
  39934. /**
  39935. * Sets the value of D-pad down
  39936. */
  39937. dPadDown: number;
  39938. /**
  39939. * Gets the value of D-pad left
  39940. */
  39941. /**
  39942. * Sets the value of D-pad left
  39943. */
  39944. dPadLeft: number;
  39945. /**
  39946. * Gets the value of D-pad right
  39947. */
  39948. /**
  39949. * Sets the value of D-pad right
  39950. */
  39951. dPadRight: number;
  39952. /**
  39953. * Force the gamepad to synchronize with device values
  39954. */
  39955. update(): void;
  39956. /**
  39957. * Disposes the gamepad
  39958. */
  39959. dispose(): void;
  39960. }
  39961. }
  39962. declare module "babylonjs/Gamepads/gamepadManager" {
  39963. import { Observable } from "babylonjs/Misc/observable";
  39964. import { Nullable } from "babylonjs/types";
  39965. import { Scene } from "babylonjs/scene";
  39966. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39967. /**
  39968. * Manager for handling gamepads
  39969. */
  39970. export class GamepadManager {
  39971. private _scene?;
  39972. private _babylonGamepads;
  39973. private _oneGamepadConnected;
  39974. /** @hidden */
  39975. _isMonitoring: boolean;
  39976. private _gamepadEventSupported;
  39977. private _gamepadSupport;
  39978. /**
  39979. * observable to be triggered when the gamepad controller has been connected
  39980. */
  39981. onGamepadConnectedObservable: Observable<Gamepad>;
  39982. /**
  39983. * observable to be triggered when the gamepad controller has been disconnected
  39984. */
  39985. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39986. private _onGamepadConnectedEvent;
  39987. private _onGamepadDisconnectedEvent;
  39988. /**
  39989. * Initializes the gamepad manager
  39990. * @param _scene BabylonJS scene
  39991. */
  39992. constructor(_scene?: Scene | undefined);
  39993. /**
  39994. * The gamepads in the game pad manager
  39995. */
  39996. readonly gamepads: Gamepad[];
  39997. /**
  39998. * Get the gamepad controllers based on type
  39999. * @param type The type of gamepad controller
  40000. * @returns Nullable gamepad
  40001. */
  40002. getGamepadByType(type?: number): Nullable<Gamepad>;
  40003. /**
  40004. * Disposes the gamepad manager
  40005. */
  40006. dispose(): void;
  40007. private _addNewGamepad;
  40008. private _startMonitoringGamepads;
  40009. private _stopMonitoringGamepads;
  40010. /** @hidden */
  40011. _checkGamepadsStatus(): void;
  40012. private _updateGamepadObjects;
  40013. }
  40014. }
  40015. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40016. import { Nullable } from "babylonjs/types";
  40017. import { Scene } from "babylonjs/scene";
  40018. import { ISceneComponent } from "babylonjs/sceneComponent";
  40019. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40020. module "babylonjs/scene" {
  40021. interface Scene {
  40022. /** @hidden */
  40023. _gamepadManager: Nullable<GamepadManager>;
  40024. /**
  40025. * Gets the gamepad manager associated with the scene
  40026. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40027. */
  40028. gamepadManager: GamepadManager;
  40029. }
  40030. }
  40031. module "babylonjs/Cameras/freeCameraInputsManager" {
  40032. /**
  40033. * Interface representing a free camera inputs manager
  40034. */
  40035. interface FreeCameraInputsManager {
  40036. /**
  40037. * Adds gamepad input support to the FreeCameraInputsManager.
  40038. * @returns the FreeCameraInputsManager
  40039. */
  40040. addGamepad(): FreeCameraInputsManager;
  40041. }
  40042. }
  40043. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40044. /**
  40045. * Interface representing an arc rotate camera inputs manager
  40046. */
  40047. interface ArcRotateCameraInputsManager {
  40048. /**
  40049. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40050. * @returns the camera inputs manager
  40051. */
  40052. addGamepad(): ArcRotateCameraInputsManager;
  40053. }
  40054. }
  40055. /**
  40056. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40057. */
  40058. export class GamepadSystemSceneComponent implements ISceneComponent {
  40059. /**
  40060. * The component name helpfull to identify the component in the list of scene components.
  40061. */
  40062. readonly name: string;
  40063. /**
  40064. * The scene the component belongs to.
  40065. */
  40066. scene: Scene;
  40067. /**
  40068. * Creates a new instance of the component for the given scene
  40069. * @param scene Defines the scene to register the component in
  40070. */
  40071. constructor(scene: Scene);
  40072. /**
  40073. * Registers the component in a given scene
  40074. */
  40075. register(): void;
  40076. /**
  40077. * Rebuilds the elements related to this component in case of
  40078. * context lost for instance.
  40079. */
  40080. rebuild(): void;
  40081. /**
  40082. * Disposes the component and the associated ressources
  40083. */
  40084. dispose(): void;
  40085. private _beforeCameraUpdate;
  40086. }
  40087. }
  40088. declare module "babylonjs/Cameras/universalCamera" {
  40089. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40090. import { Scene } from "babylonjs/scene";
  40091. import { Vector3 } from "babylonjs/Maths/math.vector";
  40092. import "babylonjs/Gamepads/gamepadSceneComponent";
  40093. /**
  40094. * 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,
  40095. * which still works and will still be found in many Playgrounds.
  40096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40097. */
  40098. export class UniversalCamera extends TouchCamera {
  40099. /**
  40100. * Defines the gamepad rotation sensiblity.
  40101. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40102. */
  40103. gamepadAngularSensibility: number;
  40104. /**
  40105. * Defines the gamepad move sensiblity.
  40106. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40107. */
  40108. gamepadMoveSensibility: number;
  40109. /**
  40110. * 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,
  40111. * which still works and will still be found in many Playgrounds.
  40112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40113. * @param name Define the name of the camera in the scene
  40114. * @param position Define the start position of the camera in the scene
  40115. * @param scene Define the scene the camera belongs to
  40116. */
  40117. constructor(name: string, position: Vector3, scene: Scene);
  40118. /**
  40119. * Gets the current object class name.
  40120. * @return the class name
  40121. */
  40122. getClassName(): string;
  40123. }
  40124. }
  40125. declare module "babylonjs/Cameras/gamepadCamera" {
  40126. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40127. import { Scene } from "babylonjs/scene";
  40128. import { Vector3 } from "babylonjs/Maths/math.vector";
  40129. /**
  40130. * This represents a FPS type of camera. This is only here for back compat purpose.
  40131. * Please use the UniversalCamera instead as both are identical.
  40132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40133. */
  40134. export class GamepadCamera extends UniversalCamera {
  40135. /**
  40136. * Instantiates a new Gamepad Camera
  40137. * This represents a FPS type of camera. This is only here for back compat purpose.
  40138. * Please use the UniversalCamera instead as both are identical.
  40139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40140. * @param name Define the name of the camera in the scene
  40141. * @param position Define the start position of the camera in the scene
  40142. * @param scene Define the scene the camera belongs to
  40143. */
  40144. constructor(name: string, position: Vector3, scene: Scene);
  40145. /**
  40146. * Gets the current object class name.
  40147. * @return the class name
  40148. */
  40149. getClassName(): string;
  40150. }
  40151. }
  40152. declare module "babylonjs/Shaders/pass.fragment" {
  40153. /** @hidden */
  40154. export var passPixelShader: {
  40155. name: string;
  40156. shader: string;
  40157. };
  40158. }
  40159. declare module "babylonjs/Shaders/passCube.fragment" {
  40160. /** @hidden */
  40161. export var passCubePixelShader: {
  40162. name: string;
  40163. shader: string;
  40164. };
  40165. }
  40166. declare module "babylonjs/PostProcesses/passPostProcess" {
  40167. import { Nullable } from "babylonjs/types";
  40168. import { Camera } from "babylonjs/Cameras/camera";
  40169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40170. import { Engine } from "babylonjs/Engines/engine";
  40171. import "babylonjs/Shaders/pass.fragment";
  40172. import "babylonjs/Shaders/passCube.fragment";
  40173. /**
  40174. * PassPostProcess which produces an output the same as it's input
  40175. */
  40176. export class PassPostProcess extends PostProcess {
  40177. /**
  40178. * Creates the PassPostProcess
  40179. * @param name The name of the effect.
  40180. * @param options The required width/height ratio to downsize to before computing the render pass.
  40181. * @param camera The camera to apply the render pass to.
  40182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40183. * @param engine The engine which the post process will be applied. (default: current engine)
  40184. * @param reusable If the post process can be reused on the same frame. (default: false)
  40185. * @param textureType The type of texture to be used when performing the post processing.
  40186. * @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)
  40187. */
  40188. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40189. }
  40190. /**
  40191. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40192. */
  40193. export class PassCubePostProcess extends PostProcess {
  40194. private _face;
  40195. /**
  40196. * Gets or sets the cube face to display.
  40197. * * 0 is +X
  40198. * * 1 is -X
  40199. * * 2 is +Y
  40200. * * 3 is -Y
  40201. * * 4 is +Z
  40202. * * 5 is -Z
  40203. */
  40204. face: number;
  40205. /**
  40206. * Creates the PassCubePostProcess
  40207. * @param name The name of the effect.
  40208. * @param options The required width/height ratio to downsize to before computing the render pass.
  40209. * @param camera The camera to apply the render pass to.
  40210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40211. * @param engine The engine which the post process will be applied. (default: current engine)
  40212. * @param reusable If the post process can be reused on the same frame. (default: false)
  40213. * @param textureType The type of texture to be used when performing the post processing.
  40214. * @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)
  40215. */
  40216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40217. }
  40218. }
  40219. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40220. /** @hidden */
  40221. export var anaglyphPixelShader: {
  40222. name: string;
  40223. shader: string;
  40224. };
  40225. }
  40226. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40227. import { Engine } from "babylonjs/Engines/engine";
  40228. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40229. import { Camera } from "babylonjs/Cameras/camera";
  40230. import "babylonjs/Shaders/anaglyph.fragment";
  40231. /**
  40232. * Postprocess used to generate anaglyphic rendering
  40233. */
  40234. export class AnaglyphPostProcess extends PostProcess {
  40235. private _passedProcess;
  40236. /**
  40237. * Creates a new AnaglyphPostProcess
  40238. * @param name defines postprocess name
  40239. * @param options defines creation options or target ratio scale
  40240. * @param rigCameras defines cameras using this postprocess
  40241. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40242. * @param engine defines hosting engine
  40243. * @param reusable defines if the postprocess will be reused multiple times per frame
  40244. */
  40245. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40246. }
  40247. }
  40248. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40249. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40250. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40251. import { Scene } from "babylonjs/scene";
  40252. import { Vector3 } from "babylonjs/Maths/math.vector";
  40253. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40254. /**
  40255. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40256. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40257. */
  40258. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40259. /**
  40260. * Creates a new AnaglyphArcRotateCamera
  40261. * @param name defines camera name
  40262. * @param alpha defines alpha angle (in radians)
  40263. * @param beta defines beta angle (in radians)
  40264. * @param radius defines radius
  40265. * @param target defines camera target
  40266. * @param interaxialDistance defines distance between each color axis
  40267. * @param scene defines the hosting scene
  40268. */
  40269. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40270. /**
  40271. * Gets camera class name
  40272. * @returns AnaglyphArcRotateCamera
  40273. */
  40274. getClassName(): string;
  40275. }
  40276. }
  40277. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40278. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40279. import { Scene } from "babylonjs/scene";
  40280. import { Vector3 } from "babylonjs/Maths/math.vector";
  40281. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40282. /**
  40283. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40284. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40285. */
  40286. export class AnaglyphFreeCamera extends FreeCamera {
  40287. /**
  40288. * Creates a new AnaglyphFreeCamera
  40289. * @param name defines camera name
  40290. * @param position defines initial position
  40291. * @param interaxialDistance defines distance between each color axis
  40292. * @param scene defines the hosting scene
  40293. */
  40294. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40295. /**
  40296. * Gets camera class name
  40297. * @returns AnaglyphFreeCamera
  40298. */
  40299. getClassName(): string;
  40300. }
  40301. }
  40302. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40303. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40304. import { Scene } from "babylonjs/scene";
  40305. import { Vector3 } from "babylonjs/Maths/math.vector";
  40306. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40307. /**
  40308. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40309. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40310. */
  40311. export class AnaglyphGamepadCamera extends GamepadCamera {
  40312. /**
  40313. * Creates a new AnaglyphGamepadCamera
  40314. * @param name defines camera name
  40315. * @param position defines initial position
  40316. * @param interaxialDistance defines distance between each color axis
  40317. * @param scene defines the hosting scene
  40318. */
  40319. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40320. /**
  40321. * Gets camera class name
  40322. * @returns AnaglyphGamepadCamera
  40323. */
  40324. getClassName(): string;
  40325. }
  40326. }
  40327. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40328. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40329. import { Scene } from "babylonjs/scene";
  40330. import { Vector3 } from "babylonjs/Maths/math.vector";
  40331. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40332. /**
  40333. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40334. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40335. */
  40336. export class AnaglyphUniversalCamera extends UniversalCamera {
  40337. /**
  40338. * Creates a new AnaglyphUniversalCamera
  40339. * @param name defines camera name
  40340. * @param position defines initial position
  40341. * @param interaxialDistance defines distance between each color axis
  40342. * @param scene defines the hosting scene
  40343. */
  40344. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40345. /**
  40346. * Gets camera class name
  40347. * @returns AnaglyphUniversalCamera
  40348. */
  40349. getClassName(): string;
  40350. }
  40351. }
  40352. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40353. /** @hidden */
  40354. export var stereoscopicInterlacePixelShader: {
  40355. name: string;
  40356. shader: string;
  40357. };
  40358. }
  40359. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40360. import { Camera } from "babylonjs/Cameras/camera";
  40361. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40362. import { Engine } from "babylonjs/Engines/engine";
  40363. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40364. /**
  40365. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40366. */
  40367. export class StereoscopicInterlacePostProcess extends PostProcess {
  40368. private _stepSize;
  40369. private _passedProcess;
  40370. /**
  40371. * Initializes a StereoscopicInterlacePostProcess
  40372. * @param name The name of the effect.
  40373. * @param rigCameras The rig cameras to be appled to the post process
  40374. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40376. * @param engine The engine which the post process will be applied. (default: current engine)
  40377. * @param reusable If the post process can be reused on the same frame. (default: false)
  40378. */
  40379. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40380. }
  40381. }
  40382. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40383. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40384. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40385. import { Scene } from "babylonjs/scene";
  40386. import { Vector3 } from "babylonjs/Maths/math.vector";
  40387. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40388. /**
  40389. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40390. * @see http://doc.babylonjs.com/features/cameras
  40391. */
  40392. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40393. /**
  40394. * Creates a new StereoscopicArcRotateCamera
  40395. * @param name defines camera name
  40396. * @param alpha defines alpha angle (in radians)
  40397. * @param beta defines beta angle (in radians)
  40398. * @param radius defines radius
  40399. * @param target defines camera target
  40400. * @param interaxialDistance defines distance between each color axis
  40401. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40402. * @param scene defines the hosting scene
  40403. */
  40404. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40405. /**
  40406. * Gets camera class name
  40407. * @returns StereoscopicArcRotateCamera
  40408. */
  40409. getClassName(): string;
  40410. }
  40411. }
  40412. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40413. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40414. import { Scene } from "babylonjs/scene";
  40415. import { Vector3 } from "babylonjs/Maths/math.vector";
  40416. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40417. /**
  40418. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40419. * @see http://doc.babylonjs.com/features/cameras
  40420. */
  40421. export class StereoscopicFreeCamera extends FreeCamera {
  40422. /**
  40423. * Creates a new StereoscopicFreeCamera
  40424. * @param name defines camera name
  40425. * @param position defines initial position
  40426. * @param interaxialDistance defines distance between each color axis
  40427. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40428. * @param scene defines the hosting scene
  40429. */
  40430. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40431. /**
  40432. * Gets camera class name
  40433. * @returns StereoscopicFreeCamera
  40434. */
  40435. getClassName(): string;
  40436. }
  40437. }
  40438. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40439. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40440. import { Scene } from "babylonjs/scene";
  40441. import { Vector3 } from "babylonjs/Maths/math.vector";
  40442. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40443. /**
  40444. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40445. * @see http://doc.babylonjs.com/features/cameras
  40446. */
  40447. export class StereoscopicGamepadCamera extends GamepadCamera {
  40448. /**
  40449. * Creates a new StereoscopicGamepadCamera
  40450. * @param name defines camera name
  40451. * @param position defines initial position
  40452. * @param interaxialDistance defines distance between each color axis
  40453. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40454. * @param scene defines the hosting scene
  40455. */
  40456. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40457. /**
  40458. * Gets camera class name
  40459. * @returns StereoscopicGamepadCamera
  40460. */
  40461. getClassName(): string;
  40462. }
  40463. }
  40464. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40465. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40466. import { Scene } from "babylonjs/scene";
  40467. import { Vector3 } from "babylonjs/Maths/math.vector";
  40468. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40469. /**
  40470. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40471. * @see http://doc.babylonjs.com/features/cameras
  40472. */
  40473. export class StereoscopicUniversalCamera extends UniversalCamera {
  40474. /**
  40475. * Creates a new StereoscopicUniversalCamera
  40476. * @param name defines camera name
  40477. * @param position defines initial position
  40478. * @param interaxialDistance defines distance between each color axis
  40479. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40480. * @param scene defines the hosting scene
  40481. */
  40482. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40483. /**
  40484. * Gets camera class name
  40485. * @returns StereoscopicUniversalCamera
  40486. */
  40487. getClassName(): string;
  40488. }
  40489. }
  40490. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40491. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40492. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40493. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40494. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40495. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40496. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40497. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40498. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40499. }
  40500. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40501. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40502. import { Scene } from "babylonjs/scene";
  40503. import { Vector3 } from "babylonjs/Maths/math.vector";
  40504. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40505. /**
  40506. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40507. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40508. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40509. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40510. */
  40511. export class VirtualJoysticksCamera extends FreeCamera {
  40512. /**
  40513. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40514. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40515. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40516. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40517. * @param name Define the name of the camera in the scene
  40518. * @param position Define the start position of the camera in the scene
  40519. * @param scene Define the scene the camera belongs to
  40520. */
  40521. constructor(name: string, position: Vector3, scene: Scene);
  40522. /**
  40523. * Gets the current object class name.
  40524. * @return the class name
  40525. */
  40526. getClassName(): string;
  40527. }
  40528. }
  40529. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40530. import { Matrix } from "babylonjs/Maths/math.vector";
  40531. /**
  40532. * This represents all the required metrics to create a VR camera.
  40533. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40534. */
  40535. export class VRCameraMetrics {
  40536. /**
  40537. * Define the horizontal resolution off the screen.
  40538. */
  40539. hResolution: number;
  40540. /**
  40541. * Define the vertical resolution off the screen.
  40542. */
  40543. vResolution: number;
  40544. /**
  40545. * Define the horizontal screen size.
  40546. */
  40547. hScreenSize: number;
  40548. /**
  40549. * Define the vertical screen size.
  40550. */
  40551. vScreenSize: number;
  40552. /**
  40553. * Define the vertical screen center position.
  40554. */
  40555. vScreenCenter: number;
  40556. /**
  40557. * Define the distance of the eyes to the screen.
  40558. */
  40559. eyeToScreenDistance: number;
  40560. /**
  40561. * Define the distance between both lenses
  40562. */
  40563. lensSeparationDistance: number;
  40564. /**
  40565. * Define the distance between both viewer's eyes.
  40566. */
  40567. interpupillaryDistance: number;
  40568. /**
  40569. * Define the distortion factor of the VR postprocess.
  40570. * Please, touch with care.
  40571. */
  40572. distortionK: number[];
  40573. /**
  40574. * Define the chromatic aberration correction factors for the VR post process.
  40575. */
  40576. chromaAbCorrection: number[];
  40577. /**
  40578. * Define the scale factor of the post process.
  40579. * The smaller the better but the slower.
  40580. */
  40581. postProcessScaleFactor: number;
  40582. /**
  40583. * Define an offset for the lens center.
  40584. */
  40585. lensCenterOffset: number;
  40586. /**
  40587. * Define if the current vr camera should compensate the distortion of the lense or not.
  40588. */
  40589. compensateDistortion: boolean;
  40590. /**
  40591. * Defines if multiview should be enabled when rendering (Default: false)
  40592. */
  40593. multiviewEnabled: boolean;
  40594. /**
  40595. * Gets the rendering aspect ratio based on the provided resolutions.
  40596. */
  40597. readonly aspectRatio: number;
  40598. /**
  40599. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40600. */
  40601. readonly aspectRatioFov: number;
  40602. /**
  40603. * @hidden
  40604. */
  40605. readonly leftHMatrix: Matrix;
  40606. /**
  40607. * @hidden
  40608. */
  40609. readonly rightHMatrix: Matrix;
  40610. /**
  40611. * @hidden
  40612. */
  40613. readonly leftPreViewMatrix: Matrix;
  40614. /**
  40615. * @hidden
  40616. */
  40617. readonly rightPreViewMatrix: Matrix;
  40618. /**
  40619. * Get the default VRMetrics based on the most generic setup.
  40620. * @returns the default vr metrics
  40621. */
  40622. static GetDefault(): VRCameraMetrics;
  40623. }
  40624. }
  40625. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40626. /** @hidden */
  40627. export var vrDistortionCorrectionPixelShader: {
  40628. name: string;
  40629. shader: string;
  40630. };
  40631. }
  40632. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40633. import { Camera } from "babylonjs/Cameras/camera";
  40634. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40635. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40636. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40637. /**
  40638. * VRDistortionCorrectionPostProcess used for mobile VR
  40639. */
  40640. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40641. private _isRightEye;
  40642. private _distortionFactors;
  40643. private _postProcessScaleFactor;
  40644. private _lensCenterOffset;
  40645. private _scaleIn;
  40646. private _scaleFactor;
  40647. private _lensCenter;
  40648. /**
  40649. * Initializes the VRDistortionCorrectionPostProcess
  40650. * @param name The name of the effect.
  40651. * @param camera The camera to apply the render pass to.
  40652. * @param isRightEye If this is for the right eye distortion
  40653. * @param vrMetrics All the required metrics for the VR camera
  40654. */
  40655. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40656. }
  40657. }
  40658. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40659. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40660. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40661. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40662. import { Scene } from "babylonjs/scene";
  40663. import { Vector3 } from "babylonjs/Maths/math.vector";
  40664. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40665. import "babylonjs/Cameras/RigModes/vrRigMode";
  40666. /**
  40667. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40668. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40669. */
  40670. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40671. /**
  40672. * Creates a new VRDeviceOrientationArcRotateCamera
  40673. * @param name defines camera name
  40674. * @param alpha defines the camera rotation along the logitudinal axis
  40675. * @param beta defines the camera rotation along the latitudinal axis
  40676. * @param radius defines the camera distance from its target
  40677. * @param target defines the camera target
  40678. * @param scene defines the scene the camera belongs to
  40679. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40681. */
  40682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40683. /**
  40684. * Gets camera class name
  40685. * @returns VRDeviceOrientationArcRotateCamera
  40686. */
  40687. getClassName(): string;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40691. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40692. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40693. import { Scene } from "babylonjs/scene";
  40694. import { Vector3 } from "babylonjs/Maths/math.vector";
  40695. import "babylonjs/Cameras/RigModes/vrRigMode";
  40696. /**
  40697. * Camera used to simulate VR rendering (based on FreeCamera)
  40698. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40699. */
  40700. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40701. /**
  40702. * Creates a new VRDeviceOrientationFreeCamera
  40703. * @param name defines camera name
  40704. * @param position defines the start position of the camera
  40705. * @param scene defines the scene the camera belongs to
  40706. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40707. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40708. */
  40709. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40710. /**
  40711. * Gets camera class name
  40712. * @returns VRDeviceOrientationFreeCamera
  40713. */
  40714. getClassName(): string;
  40715. }
  40716. }
  40717. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40718. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40719. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40720. import { Scene } from "babylonjs/scene";
  40721. import { Vector3 } from "babylonjs/Maths/math.vector";
  40722. import "babylonjs/Gamepads/gamepadSceneComponent";
  40723. /**
  40724. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40725. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40726. */
  40727. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40728. /**
  40729. * Creates a new VRDeviceOrientationGamepadCamera
  40730. * @param name defines camera name
  40731. * @param position defines the start position of the camera
  40732. * @param scene defines the scene the camera belongs to
  40733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40735. */
  40736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40737. /**
  40738. * Gets camera class name
  40739. * @returns VRDeviceOrientationGamepadCamera
  40740. */
  40741. getClassName(): string;
  40742. }
  40743. }
  40744. declare module "babylonjs/Materials/pushMaterial" {
  40745. import { Nullable } from "babylonjs/types";
  40746. import { Scene } from "babylonjs/scene";
  40747. import { Matrix } from "babylonjs/Maths/math.vector";
  40748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40749. import { Mesh } from "babylonjs/Meshes/mesh";
  40750. import { Material } from "babylonjs/Materials/material";
  40751. import { Effect } from "babylonjs/Materials/effect";
  40752. /**
  40753. * Base class of materials working in push mode in babylon JS
  40754. * @hidden
  40755. */
  40756. export class PushMaterial extends Material {
  40757. protected _activeEffect: Effect;
  40758. protected _normalMatrix: Matrix;
  40759. /**
  40760. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40761. * This means that the material can keep using a previous shader while a new one is being compiled.
  40762. * This is mostly used when shader parallel compilation is supported (true by default)
  40763. */
  40764. allowShaderHotSwapping: boolean;
  40765. constructor(name: string, scene: Scene);
  40766. getEffect(): Effect;
  40767. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40768. /**
  40769. * Binds the given world matrix to the active effect
  40770. *
  40771. * @param world the matrix to bind
  40772. */
  40773. bindOnlyWorldMatrix(world: Matrix): void;
  40774. /**
  40775. * Binds the given normal matrix to the active effect
  40776. *
  40777. * @param normalMatrix the matrix to bind
  40778. */
  40779. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40780. bind(world: Matrix, mesh?: Mesh): void;
  40781. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40782. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40783. }
  40784. }
  40785. declare module "babylonjs/Materials/materialFlags" {
  40786. /**
  40787. * This groups all the flags used to control the materials channel.
  40788. */
  40789. export class MaterialFlags {
  40790. private static _DiffuseTextureEnabled;
  40791. /**
  40792. * Are diffuse textures enabled in the application.
  40793. */
  40794. static DiffuseTextureEnabled: boolean;
  40795. private static _AmbientTextureEnabled;
  40796. /**
  40797. * Are ambient textures enabled in the application.
  40798. */
  40799. static AmbientTextureEnabled: boolean;
  40800. private static _OpacityTextureEnabled;
  40801. /**
  40802. * Are opacity textures enabled in the application.
  40803. */
  40804. static OpacityTextureEnabled: boolean;
  40805. private static _ReflectionTextureEnabled;
  40806. /**
  40807. * Are reflection textures enabled in the application.
  40808. */
  40809. static ReflectionTextureEnabled: boolean;
  40810. private static _EmissiveTextureEnabled;
  40811. /**
  40812. * Are emissive textures enabled in the application.
  40813. */
  40814. static EmissiveTextureEnabled: boolean;
  40815. private static _SpecularTextureEnabled;
  40816. /**
  40817. * Are specular textures enabled in the application.
  40818. */
  40819. static SpecularTextureEnabled: boolean;
  40820. private static _BumpTextureEnabled;
  40821. /**
  40822. * Are bump textures enabled in the application.
  40823. */
  40824. static BumpTextureEnabled: boolean;
  40825. private static _LightmapTextureEnabled;
  40826. /**
  40827. * Are lightmap textures enabled in the application.
  40828. */
  40829. static LightmapTextureEnabled: boolean;
  40830. private static _RefractionTextureEnabled;
  40831. /**
  40832. * Are refraction textures enabled in the application.
  40833. */
  40834. static RefractionTextureEnabled: boolean;
  40835. private static _ColorGradingTextureEnabled;
  40836. /**
  40837. * Are color grading textures enabled in the application.
  40838. */
  40839. static ColorGradingTextureEnabled: boolean;
  40840. private static _FresnelEnabled;
  40841. /**
  40842. * Are fresnels enabled in the application.
  40843. */
  40844. static FresnelEnabled: boolean;
  40845. private static _ClearCoatTextureEnabled;
  40846. /**
  40847. * Are clear coat textures enabled in the application.
  40848. */
  40849. static ClearCoatTextureEnabled: boolean;
  40850. private static _ClearCoatBumpTextureEnabled;
  40851. /**
  40852. * Are clear coat bump textures enabled in the application.
  40853. */
  40854. static ClearCoatBumpTextureEnabled: boolean;
  40855. private static _ClearCoatTintTextureEnabled;
  40856. /**
  40857. * Are clear coat tint textures enabled in the application.
  40858. */
  40859. static ClearCoatTintTextureEnabled: boolean;
  40860. private static _SheenTextureEnabled;
  40861. /**
  40862. * Are sheen textures enabled in the application.
  40863. */
  40864. static SheenTextureEnabled: boolean;
  40865. private static _AnisotropicTextureEnabled;
  40866. /**
  40867. * Are anisotropic textures enabled in the application.
  40868. */
  40869. static AnisotropicTextureEnabled: boolean;
  40870. private static _ThicknessTextureEnabled;
  40871. /**
  40872. * Are thickness textures enabled in the application.
  40873. */
  40874. static ThicknessTextureEnabled: boolean;
  40875. }
  40876. }
  40877. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40878. /** @hidden */
  40879. export var defaultFragmentDeclaration: {
  40880. name: string;
  40881. shader: string;
  40882. };
  40883. }
  40884. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40885. /** @hidden */
  40886. export var defaultUboDeclaration: {
  40887. name: string;
  40888. shader: string;
  40889. };
  40890. }
  40891. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40892. /** @hidden */
  40893. export var lightFragmentDeclaration: {
  40894. name: string;
  40895. shader: string;
  40896. };
  40897. }
  40898. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40899. /** @hidden */
  40900. export var lightUboDeclaration: {
  40901. name: string;
  40902. shader: string;
  40903. };
  40904. }
  40905. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40906. /** @hidden */
  40907. export var lightsFragmentFunctions: {
  40908. name: string;
  40909. shader: string;
  40910. };
  40911. }
  40912. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40913. /** @hidden */
  40914. export var shadowsFragmentFunctions: {
  40915. name: string;
  40916. shader: string;
  40917. };
  40918. }
  40919. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40920. /** @hidden */
  40921. export var fresnelFunction: {
  40922. name: string;
  40923. shader: string;
  40924. };
  40925. }
  40926. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40927. /** @hidden */
  40928. export var reflectionFunction: {
  40929. name: string;
  40930. shader: string;
  40931. };
  40932. }
  40933. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40934. /** @hidden */
  40935. export var bumpFragmentFunctions: {
  40936. name: string;
  40937. shader: string;
  40938. };
  40939. }
  40940. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40941. /** @hidden */
  40942. export var logDepthDeclaration: {
  40943. name: string;
  40944. shader: string;
  40945. };
  40946. }
  40947. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40948. /** @hidden */
  40949. export var bumpFragment: {
  40950. name: string;
  40951. shader: string;
  40952. };
  40953. }
  40954. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40955. /** @hidden */
  40956. export var depthPrePass: {
  40957. name: string;
  40958. shader: string;
  40959. };
  40960. }
  40961. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40962. /** @hidden */
  40963. export var lightFragment: {
  40964. name: string;
  40965. shader: string;
  40966. };
  40967. }
  40968. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40969. /** @hidden */
  40970. export var logDepthFragment: {
  40971. name: string;
  40972. shader: string;
  40973. };
  40974. }
  40975. declare module "babylonjs/Shaders/default.fragment" {
  40976. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40977. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40978. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40979. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40980. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40981. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40982. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40983. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40984. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40985. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40986. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40987. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40988. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40989. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40990. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40991. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40992. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40993. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40994. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40995. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40996. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40997. /** @hidden */
  40998. export var defaultPixelShader: {
  40999. name: string;
  41000. shader: string;
  41001. };
  41002. }
  41003. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41004. /** @hidden */
  41005. export var defaultVertexDeclaration: {
  41006. name: string;
  41007. shader: string;
  41008. };
  41009. }
  41010. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41011. /** @hidden */
  41012. export var bumpVertexDeclaration: {
  41013. name: string;
  41014. shader: string;
  41015. };
  41016. }
  41017. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41018. /** @hidden */
  41019. export var bumpVertex: {
  41020. name: string;
  41021. shader: string;
  41022. };
  41023. }
  41024. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41025. /** @hidden */
  41026. export var fogVertex: {
  41027. name: string;
  41028. shader: string;
  41029. };
  41030. }
  41031. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41032. /** @hidden */
  41033. export var shadowsVertex: {
  41034. name: string;
  41035. shader: string;
  41036. };
  41037. }
  41038. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41039. /** @hidden */
  41040. export var pointCloudVertex: {
  41041. name: string;
  41042. shader: string;
  41043. };
  41044. }
  41045. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41046. /** @hidden */
  41047. export var logDepthVertex: {
  41048. name: string;
  41049. shader: string;
  41050. };
  41051. }
  41052. declare module "babylonjs/Shaders/default.vertex" {
  41053. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41054. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41055. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41056. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41057. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41058. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41059. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41060. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41061. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41062. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41063. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41064. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41065. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41066. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41067. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41068. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41069. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41070. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41071. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41072. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41073. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41074. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41075. /** @hidden */
  41076. export var defaultVertexShader: {
  41077. name: string;
  41078. shader: string;
  41079. };
  41080. }
  41081. declare module "babylonjs/Materials/standardMaterial" {
  41082. import { SmartArray } from "babylonjs/Misc/smartArray";
  41083. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41084. import { Nullable } from "babylonjs/types";
  41085. import { Scene } from "babylonjs/scene";
  41086. import { Matrix } from "babylonjs/Maths/math.vector";
  41087. import { Color3 } from "babylonjs/Maths/math.color";
  41088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41090. import { Mesh } from "babylonjs/Meshes/mesh";
  41091. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41092. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41093. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41094. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41095. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41097. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41098. import "babylonjs/Shaders/default.fragment";
  41099. import "babylonjs/Shaders/default.vertex";
  41100. /** @hidden */
  41101. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41102. MAINUV1: boolean;
  41103. MAINUV2: boolean;
  41104. DIFFUSE: boolean;
  41105. DIFFUSEDIRECTUV: number;
  41106. AMBIENT: boolean;
  41107. AMBIENTDIRECTUV: number;
  41108. OPACITY: boolean;
  41109. OPACITYDIRECTUV: number;
  41110. OPACITYRGB: boolean;
  41111. REFLECTION: boolean;
  41112. EMISSIVE: boolean;
  41113. EMISSIVEDIRECTUV: number;
  41114. SPECULAR: boolean;
  41115. SPECULARDIRECTUV: number;
  41116. BUMP: boolean;
  41117. BUMPDIRECTUV: number;
  41118. PARALLAX: boolean;
  41119. PARALLAXOCCLUSION: boolean;
  41120. SPECULAROVERALPHA: boolean;
  41121. CLIPPLANE: boolean;
  41122. CLIPPLANE2: boolean;
  41123. CLIPPLANE3: boolean;
  41124. CLIPPLANE4: boolean;
  41125. ALPHATEST: boolean;
  41126. DEPTHPREPASS: boolean;
  41127. ALPHAFROMDIFFUSE: boolean;
  41128. POINTSIZE: boolean;
  41129. FOG: boolean;
  41130. SPECULARTERM: boolean;
  41131. DIFFUSEFRESNEL: boolean;
  41132. OPACITYFRESNEL: boolean;
  41133. REFLECTIONFRESNEL: boolean;
  41134. REFRACTIONFRESNEL: boolean;
  41135. EMISSIVEFRESNEL: boolean;
  41136. FRESNEL: boolean;
  41137. NORMAL: boolean;
  41138. UV1: boolean;
  41139. UV2: boolean;
  41140. VERTEXCOLOR: boolean;
  41141. VERTEXALPHA: boolean;
  41142. NUM_BONE_INFLUENCERS: number;
  41143. BonesPerMesh: number;
  41144. BONETEXTURE: boolean;
  41145. INSTANCES: boolean;
  41146. GLOSSINESS: boolean;
  41147. ROUGHNESS: boolean;
  41148. EMISSIVEASILLUMINATION: boolean;
  41149. LINKEMISSIVEWITHDIFFUSE: boolean;
  41150. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41151. LIGHTMAP: boolean;
  41152. LIGHTMAPDIRECTUV: number;
  41153. OBJECTSPACE_NORMALMAP: boolean;
  41154. USELIGHTMAPASSHADOWMAP: boolean;
  41155. REFLECTIONMAP_3D: boolean;
  41156. REFLECTIONMAP_SPHERICAL: boolean;
  41157. REFLECTIONMAP_PLANAR: boolean;
  41158. REFLECTIONMAP_CUBIC: boolean;
  41159. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41160. REFLECTIONMAP_PROJECTION: boolean;
  41161. REFLECTIONMAP_SKYBOX: boolean;
  41162. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41163. REFLECTIONMAP_EXPLICIT: boolean;
  41164. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41165. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41166. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41167. INVERTCUBICMAP: boolean;
  41168. LOGARITHMICDEPTH: boolean;
  41169. REFRACTION: boolean;
  41170. REFRACTIONMAP_3D: boolean;
  41171. REFLECTIONOVERALPHA: boolean;
  41172. TWOSIDEDLIGHTING: boolean;
  41173. SHADOWFLOAT: boolean;
  41174. MORPHTARGETS: boolean;
  41175. MORPHTARGETS_NORMAL: boolean;
  41176. MORPHTARGETS_TANGENT: boolean;
  41177. MORPHTARGETS_UV: boolean;
  41178. NUM_MORPH_INFLUENCERS: number;
  41179. NONUNIFORMSCALING: boolean;
  41180. PREMULTIPLYALPHA: boolean;
  41181. IMAGEPROCESSING: boolean;
  41182. VIGNETTE: boolean;
  41183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41184. VIGNETTEBLENDMODEOPAQUE: boolean;
  41185. TONEMAPPING: boolean;
  41186. TONEMAPPING_ACES: boolean;
  41187. CONTRAST: boolean;
  41188. COLORCURVES: boolean;
  41189. COLORGRADING: boolean;
  41190. COLORGRADING3D: boolean;
  41191. SAMPLER3DGREENDEPTH: boolean;
  41192. SAMPLER3DBGRMAP: boolean;
  41193. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41194. MULTIVIEW: boolean;
  41195. /**
  41196. * If the reflection texture on this material is in linear color space
  41197. * @hidden
  41198. */
  41199. IS_REFLECTION_LINEAR: boolean;
  41200. /**
  41201. * If the refraction texture on this material is in linear color space
  41202. * @hidden
  41203. */
  41204. IS_REFRACTION_LINEAR: boolean;
  41205. EXPOSURE: boolean;
  41206. constructor();
  41207. setReflectionMode(modeToEnable: string): void;
  41208. }
  41209. /**
  41210. * This is the default material used in Babylon. It is the best trade off between quality
  41211. * and performances.
  41212. * @see http://doc.babylonjs.com/babylon101/materials
  41213. */
  41214. export class StandardMaterial extends PushMaterial {
  41215. private _diffuseTexture;
  41216. /**
  41217. * The basic texture of the material as viewed under a light.
  41218. */
  41219. diffuseTexture: Nullable<BaseTexture>;
  41220. private _ambientTexture;
  41221. /**
  41222. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41223. */
  41224. ambientTexture: Nullable<BaseTexture>;
  41225. private _opacityTexture;
  41226. /**
  41227. * Define the transparency of the material from a texture.
  41228. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41229. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41230. */
  41231. opacityTexture: Nullable<BaseTexture>;
  41232. private _reflectionTexture;
  41233. /**
  41234. * Define the texture used to display the reflection.
  41235. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41236. */
  41237. reflectionTexture: Nullable<BaseTexture>;
  41238. private _emissiveTexture;
  41239. /**
  41240. * Define texture of the material as if self lit.
  41241. * This will be mixed in the final result even in the absence of light.
  41242. */
  41243. emissiveTexture: Nullable<BaseTexture>;
  41244. private _specularTexture;
  41245. /**
  41246. * Define how the color and intensity of the highlight given by the light in the material.
  41247. */
  41248. specularTexture: Nullable<BaseTexture>;
  41249. private _bumpTexture;
  41250. /**
  41251. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41252. * 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.
  41253. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41254. */
  41255. bumpTexture: Nullable<BaseTexture>;
  41256. private _lightmapTexture;
  41257. /**
  41258. * Complex lighting can be computationally expensive to compute at runtime.
  41259. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41260. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41261. */
  41262. lightmapTexture: Nullable<BaseTexture>;
  41263. private _refractionTexture;
  41264. /**
  41265. * Define the texture used to display the refraction.
  41266. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41267. */
  41268. refractionTexture: Nullable<BaseTexture>;
  41269. /**
  41270. * The color of the material lit by the environmental background lighting.
  41271. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41272. */
  41273. ambientColor: Color3;
  41274. /**
  41275. * The basic color of the material as viewed under a light.
  41276. */
  41277. diffuseColor: Color3;
  41278. /**
  41279. * Define how the color and intensity of the highlight given by the light in the material.
  41280. */
  41281. specularColor: Color3;
  41282. /**
  41283. * Define the color of the material as if self lit.
  41284. * This will be mixed in the final result even in the absence of light.
  41285. */
  41286. emissiveColor: Color3;
  41287. /**
  41288. * Defines how sharp are the highlights in the material.
  41289. * The bigger the value the sharper giving a more glossy feeling to the result.
  41290. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41291. */
  41292. specularPower: number;
  41293. private _useAlphaFromDiffuseTexture;
  41294. /**
  41295. * Does the transparency come from the diffuse texture alpha channel.
  41296. */
  41297. useAlphaFromDiffuseTexture: boolean;
  41298. private _useEmissiveAsIllumination;
  41299. /**
  41300. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41301. */
  41302. useEmissiveAsIllumination: boolean;
  41303. private _linkEmissiveWithDiffuse;
  41304. /**
  41305. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41306. * the emissive level when the final color is close to one.
  41307. */
  41308. linkEmissiveWithDiffuse: boolean;
  41309. private _useSpecularOverAlpha;
  41310. /**
  41311. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41312. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41313. */
  41314. useSpecularOverAlpha: boolean;
  41315. private _useReflectionOverAlpha;
  41316. /**
  41317. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41318. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41319. */
  41320. useReflectionOverAlpha: boolean;
  41321. private _disableLighting;
  41322. /**
  41323. * Does lights from the scene impacts this material.
  41324. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41325. */
  41326. disableLighting: boolean;
  41327. private _useObjectSpaceNormalMap;
  41328. /**
  41329. * Allows using an object space normal map (instead of tangent space).
  41330. */
  41331. useObjectSpaceNormalMap: boolean;
  41332. private _useParallax;
  41333. /**
  41334. * Is parallax enabled or not.
  41335. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41336. */
  41337. useParallax: boolean;
  41338. private _useParallaxOcclusion;
  41339. /**
  41340. * Is parallax occlusion enabled or not.
  41341. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41342. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41343. */
  41344. useParallaxOcclusion: boolean;
  41345. /**
  41346. * 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.
  41347. */
  41348. parallaxScaleBias: number;
  41349. private _roughness;
  41350. /**
  41351. * Helps to define how blurry the reflections should appears in the material.
  41352. */
  41353. roughness: number;
  41354. /**
  41355. * In case of refraction, define the value of the index of refraction.
  41356. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41357. */
  41358. indexOfRefraction: number;
  41359. /**
  41360. * Invert the refraction texture alongside the y axis.
  41361. * It can be useful with procedural textures or probe for instance.
  41362. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41363. */
  41364. invertRefractionY: boolean;
  41365. /**
  41366. * Defines the alpha limits in alpha test mode.
  41367. */
  41368. alphaCutOff: number;
  41369. private _useLightmapAsShadowmap;
  41370. /**
  41371. * In case of light mapping, define whether the map contains light or shadow informations.
  41372. */
  41373. useLightmapAsShadowmap: boolean;
  41374. private _diffuseFresnelParameters;
  41375. /**
  41376. * Define the diffuse fresnel parameters of the material.
  41377. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41378. */
  41379. diffuseFresnelParameters: FresnelParameters;
  41380. private _opacityFresnelParameters;
  41381. /**
  41382. * Define the opacity fresnel parameters of the material.
  41383. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41384. */
  41385. opacityFresnelParameters: FresnelParameters;
  41386. private _reflectionFresnelParameters;
  41387. /**
  41388. * Define the reflection fresnel parameters of the material.
  41389. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41390. */
  41391. reflectionFresnelParameters: FresnelParameters;
  41392. private _refractionFresnelParameters;
  41393. /**
  41394. * Define the refraction fresnel parameters of the material.
  41395. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41396. */
  41397. refractionFresnelParameters: FresnelParameters;
  41398. private _emissiveFresnelParameters;
  41399. /**
  41400. * Define the emissive fresnel parameters of the material.
  41401. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41402. */
  41403. emissiveFresnelParameters: FresnelParameters;
  41404. private _useReflectionFresnelFromSpecular;
  41405. /**
  41406. * If true automatically deducts the fresnels values from the material specularity.
  41407. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41408. */
  41409. useReflectionFresnelFromSpecular: boolean;
  41410. private _useGlossinessFromSpecularMapAlpha;
  41411. /**
  41412. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41413. */
  41414. useGlossinessFromSpecularMapAlpha: boolean;
  41415. private _maxSimultaneousLights;
  41416. /**
  41417. * Defines the maximum number of lights that can be used in the material
  41418. */
  41419. maxSimultaneousLights: number;
  41420. private _invertNormalMapX;
  41421. /**
  41422. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41423. */
  41424. invertNormalMapX: boolean;
  41425. private _invertNormalMapY;
  41426. /**
  41427. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41428. */
  41429. invertNormalMapY: boolean;
  41430. private _twoSidedLighting;
  41431. /**
  41432. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41433. */
  41434. twoSidedLighting: boolean;
  41435. /**
  41436. * Default configuration related to image processing available in the standard Material.
  41437. */
  41438. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41439. /**
  41440. * Gets the image processing configuration used either in this material.
  41441. */
  41442. /**
  41443. * Sets the Default image processing configuration used either in the this material.
  41444. *
  41445. * If sets to null, the scene one is in use.
  41446. */
  41447. imageProcessingConfiguration: ImageProcessingConfiguration;
  41448. /**
  41449. * Keep track of the image processing observer to allow dispose and replace.
  41450. */
  41451. private _imageProcessingObserver;
  41452. /**
  41453. * Attaches a new image processing configuration to the Standard Material.
  41454. * @param configuration
  41455. */
  41456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41457. /**
  41458. * Gets wether the color curves effect is enabled.
  41459. */
  41460. /**
  41461. * Sets wether the color curves effect is enabled.
  41462. */
  41463. cameraColorCurvesEnabled: boolean;
  41464. /**
  41465. * Gets wether the color grading effect is enabled.
  41466. */
  41467. /**
  41468. * Gets wether the color grading effect is enabled.
  41469. */
  41470. cameraColorGradingEnabled: boolean;
  41471. /**
  41472. * Gets wether tonemapping is enabled or not.
  41473. */
  41474. /**
  41475. * Sets wether tonemapping is enabled or not
  41476. */
  41477. cameraToneMappingEnabled: boolean;
  41478. /**
  41479. * The camera exposure used on this material.
  41480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41481. * This corresponds to a photographic exposure.
  41482. */
  41483. /**
  41484. * The camera exposure used on this material.
  41485. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41486. * This corresponds to a photographic exposure.
  41487. */
  41488. cameraExposure: number;
  41489. /**
  41490. * Gets The camera contrast used on this material.
  41491. */
  41492. /**
  41493. * Sets The camera contrast used on this material.
  41494. */
  41495. cameraContrast: number;
  41496. /**
  41497. * Gets the Color Grading 2D Lookup Texture.
  41498. */
  41499. /**
  41500. * Sets the Color Grading 2D Lookup Texture.
  41501. */
  41502. cameraColorGradingTexture: Nullable<BaseTexture>;
  41503. /**
  41504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41506. * 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;
  41507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41508. */
  41509. /**
  41510. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41511. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41512. * 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;
  41513. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41514. */
  41515. cameraColorCurves: Nullable<ColorCurves>;
  41516. /**
  41517. * Custom callback helping to override the default shader used in the material.
  41518. */
  41519. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41520. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41521. protected _worldViewProjectionMatrix: Matrix;
  41522. protected _globalAmbientColor: Color3;
  41523. protected _useLogarithmicDepth: boolean;
  41524. /**
  41525. * Instantiates a new standard material.
  41526. * This is the default material used in Babylon. It is the best trade off between quality
  41527. * and performances.
  41528. * @see http://doc.babylonjs.com/babylon101/materials
  41529. * @param name Define the name of the material in the scene
  41530. * @param scene Define the scene the material belong to
  41531. */
  41532. constructor(name: string, scene: Scene);
  41533. /**
  41534. * Gets a boolean indicating that current material needs to register RTT
  41535. */
  41536. readonly hasRenderTargetTextures: boolean;
  41537. /**
  41538. * Gets the current class name of the material e.g. "StandardMaterial"
  41539. * Mainly use in serialization.
  41540. * @returns the class name
  41541. */
  41542. getClassName(): string;
  41543. /**
  41544. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41545. * You can try switching to logarithmic depth.
  41546. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41547. */
  41548. useLogarithmicDepth: boolean;
  41549. /**
  41550. * Specifies if the material will require alpha blending
  41551. * @returns a boolean specifying if alpha blending is needed
  41552. */
  41553. needAlphaBlending(): boolean;
  41554. /**
  41555. * Specifies if this material should be rendered in alpha test mode
  41556. * @returns a boolean specifying if an alpha test is needed.
  41557. */
  41558. needAlphaTesting(): boolean;
  41559. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41560. /**
  41561. * Get the texture used for alpha test purpose.
  41562. * @returns the diffuse texture in case of the standard material.
  41563. */
  41564. getAlphaTestTexture(): Nullable<BaseTexture>;
  41565. /**
  41566. * Get if the submesh is ready to be used and all its information available.
  41567. * Child classes can use it to update shaders
  41568. * @param mesh defines the mesh to check
  41569. * @param subMesh defines which submesh to check
  41570. * @param useInstances specifies that instances should be used
  41571. * @returns a boolean indicating that the submesh is ready or not
  41572. */
  41573. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41574. /**
  41575. * Builds the material UBO layouts.
  41576. * Used internally during the effect preparation.
  41577. */
  41578. buildUniformLayout(): void;
  41579. /**
  41580. * Unbinds the material from the mesh
  41581. */
  41582. unbind(): void;
  41583. /**
  41584. * Binds the submesh to this material by preparing the effect and shader to draw
  41585. * @param world defines the world transformation matrix
  41586. * @param mesh defines the mesh containing the submesh
  41587. * @param subMesh defines the submesh to bind the material to
  41588. */
  41589. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41590. /**
  41591. * Get the list of animatables in the material.
  41592. * @returns the list of animatables object used in the material
  41593. */
  41594. getAnimatables(): IAnimatable[];
  41595. /**
  41596. * Gets the active textures from the material
  41597. * @returns an array of textures
  41598. */
  41599. getActiveTextures(): BaseTexture[];
  41600. /**
  41601. * Specifies if the material uses a texture
  41602. * @param texture defines the texture to check against the material
  41603. * @returns a boolean specifying if the material uses the texture
  41604. */
  41605. hasTexture(texture: BaseTexture): boolean;
  41606. /**
  41607. * Disposes the material
  41608. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41609. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41610. */
  41611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41612. /**
  41613. * Makes a duplicate of the material, and gives it a new name
  41614. * @param name defines the new name for the duplicated material
  41615. * @returns the cloned material
  41616. */
  41617. clone(name: string): StandardMaterial;
  41618. /**
  41619. * Serializes this material in a JSON representation
  41620. * @returns the serialized material object
  41621. */
  41622. serialize(): any;
  41623. /**
  41624. * Creates a standard material from parsed material data
  41625. * @param source defines the JSON representation of the material
  41626. * @param scene defines the hosting scene
  41627. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41628. * @returns a new standard material
  41629. */
  41630. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41631. /**
  41632. * Are diffuse textures enabled in the application.
  41633. */
  41634. static DiffuseTextureEnabled: boolean;
  41635. /**
  41636. * Are ambient textures enabled in the application.
  41637. */
  41638. static AmbientTextureEnabled: boolean;
  41639. /**
  41640. * Are opacity textures enabled in the application.
  41641. */
  41642. static OpacityTextureEnabled: boolean;
  41643. /**
  41644. * Are reflection textures enabled in the application.
  41645. */
  41646. static ReflectionTextureEnabled: boolean;
  41647. /**
  41648. * Are emissive textures enabled in the application.
  41649. */
  41650. static EmissiveTextureEnabled: boolean;
  41651. /**
  41652. * Are specular textures enabled in the application.
  41653. */
  41654. static SpecularTextureEnabled: boolean;
  41655. /**
  41656. * Are bump textures enabled in the application.
  41657. */
  41658. static BumpTextureEnabled: boolean;
  41659. /**
  41660. * Are lightmap textures enabled in the application.
  41661. */
  41662. static LightmapTextureEnabled: boolean;
  41663. /**
  41664. * Are refraction textures enabled in the application.
  41665. */
  41666. static RefractionTextureEnabled: boolean;
  41667. /**
  41668. * Are color grading textures enabled in the application.
  41669. */
  41670. static ColorGradingTextureEnabled: boolean;
  41671. /**
  41672. * Are fresnels enabled in the application.
  41673. */
  41674. static FresnelEnabled: boolean;
  41675. }
  41676. }
  41677. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41678. import { Scene } from "babylonjs/scene";
  41679. import { Texture } from "babylonjs/Materials/Textures/texture";
  41680. /**
  41681. * A class extending Texture allowing drawing on a texture
  41682. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41683. */
  41684. export class DynamicTexture extends Texture {
  41685. private _generateMipMaps;
  41686. private _canvas;
  41687. private _context;
  41688. private _engine;
  41689. /**
  41690. * Creates a DynamicTexture
  41691. * @param name defines the name of the texture
  41692. * @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
  41693. * @param scene defines the scene where you want the texture
  41694. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41695. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41696. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41697. */
  41698. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41699. /**
  41700. * Get the current class name of the texture useful for serialization or dynamic coding.
  41701. * @returns "DynamicTexture"
  41702. */
  41703. getClassName(): string;
  41704. /**
  41705. * Gets the current state of canRescale
  41706. */
  41707. readonly canRescale: boolean;
  41708. private _recreate;
  41709. /**
  41710. * Scales the texture
  41711. * @param ratio the scale factor to apply to both width and height
  41712. */
  41713. scale(ratio: number): void;
  41714. /**
  41715. * Resizes the texture
  41716. * @param width the new width
  41717. * @param height the new height
  41718. */
  41719. scaleTo(width: number, height: number): void;
  41720. /**
  41721. * Gets the context of the canvas used by the texture
  41722. * @returns the canvas context of the dynamic texture
  41723. */
  41724. getContext(): CanvasRenderingContext2D;
  41725. /**
  41726. * Clears the texture
  41727. */
  41728. clear(): void;
  41729. /**
  41730. * Updates the texture
  41731. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41732. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41733. */
  41734. update(invertY?: boolean, premulAlpha?: boolean): void;
  41735. /**
  41736. * Draws text onto the texture
  41737. * @param text defines the text to be drawn
  41738. * @param x defines the placement of the text from the left
  41739. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41740. * @param font defines the font to be used with font-style, font-size, font-name
  41741. * @param color defines the color used for the text
  41742. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41743. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41744. * @param update defines whether texture is immediately update (default is true)
  41745. */
  41746. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41747. /**
  41748. * Clones the texture
  41749. * @returns the clone of the texture.
  41750. */
  41751. clone(): DynamicTexture;
  41752. /**
  41753. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41754. * @returns a serialized dynamic texture object
  41755. */
  41756. serialize(): any;
  41757. /** @hidden */
  41758. _rebuild(): void;
  41759. }
  41760. }
  41761. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41762. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41763. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41764. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41765. /** @hidden */
  41766. export var imageProcessingPixelShader: {
  41767. name: string;
  41768. shader: string;
  41769. };
  41770. }
  41771. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41772. import { Nullable } from "babylonjs/types";
  41773. import { Color4 } from "babylonjs/Maths/math.color";
  41774. import { Camera } from "babylonjs/Cameras/camera";
  41775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41776. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41777. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41779. import { Engine } from "babylonjs/Engines/engine";
  41780. import "babylonjs/Shaders/imageProcessing.fragment";
  41781. import "babylonjs/Shaders/postprocess.vertex";
  41782. /**
  41783. * ImageProcessingPostProcess
  41784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41785. */
  41786. export class ImageProcessingPostProcess extends PostProcess {
  41787. /**
  41788. * Default configuration related to image processing available in the PBR Material.
  41789. */
  41790. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41791. /**
  41792. * Gets the image processing configuration used either in this material.
  41793. */
  41794. /**
  41795. * Sets the Default image processing configuration used either in the this material.
  41796. *
  41797. * If sets to null, the scene one is in use.
  41798. */
  41799. imageProcessingConfiguration: ImageProcessingConfiguration;
  41800. /**
  41801. * Keep track of the image processing observer to allow dispose and replace.
  41802. */
  41803. private _imageProcessingObserver;
  41804. /**
  41805. * Attaches a new image processing configuration to the PBR Material.
  41806. * @param configuration
  41807. */
  41808. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41809. /**
  41810. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41811. */
  41812. /**
  41813. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41814. */
  41815. colorCurves: Nullable<ColorCurves>;
  41816. /**
  41817. * Gets wether the color curves effect is enabled.
  41818. */
  41819. /**
  41820. * Sets wether the color curves effect is enabled.
  41821. */
  41822. colorCurvesEnabled: boolean;
  41823. /**
  41824. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41825. */
  41826. /**
  41827. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41828. */
  41829. colorGradingTexture: Nullable<BaseTexture>;
  41830. /**
  41831. * Gets wether the color grading effect is enabled.
  41832. */
  41833. /**
  41834. * Gets wether the color grading effect is enabled.
  41835. */
  41836. colorGradingEnabled: boolean;
  41837. /**
  41838. * Gets exposure used in the effect.
  41839. */
  41840. /**
  41841. * Sets exposure used in the effect.
  41842. */
  41843. exposure: number;
  41844. /**
  41845. * Gets wether tonemapping is enabled or not.
  41846. */
  41847. /**
  41848. * Sets wether tonemapping is enabled or not
  41849. */
  41850. toneMappingEnabled: boolean;
  41851. /**
  41852. * Gets the type of tone mapping effect.
  41853. */
  41854. /**
  41855. * Sets the type of tone mapping effect.
  41856. */
  41857. toneMappingType: number;
  41858. /**
  41859. * Gets contrast used in the effect.
  41860. */
  41861. /**
  41862. * Sets contrast used in the effect.
  41863. */
  41864. contrast: number;
  41865. /**
  41866. * Gets Vignette stretch size.
  41867. */
  41868. /**
  41869. * Sets Vignette stretch size.
  41870. */
  41871. vignetteStretch: number;
  41872. /**
  41873. * Gets Vignette centre X Offset.
  41874. */
  41875. /**
  41876. * Sets Vignette centre X Offset.
  41877. */
  41878. vignetteCentreX: number;
  41879. /**
  41880. * Gets Vignette centre Y Offset.
  41881. */
  41882. /**
  41883. * Sets Vignette centre Y Offset.
  41884. */
  41885. vignetteCentreY: number;
  41886. /**
  41887. * Gets Vignette weight or intensity of the vignette effect.
  41888. */
  41889. /**
  41890. * Sets Vignette weight or intensity of the vignette effect.
  41891. */
  41892. vignetteWeight: number;
  41893. /**
  41894. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41895. * if vignetteEnabled is set to true.
  41896. */
  41897. /**
  41898. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41899. * if vignetteEnabled is set to true.
  41900. */
  41901. vignetteColor: Color4;
  41902. /**
  41903. * Gets Camera field of view used by the Vignette effect.
  41904. */
  41905. /**
  41906. * Sets Camera field of view used by the Vignette effect.
  41907. */
  41908. vignetteCameraFov: number;
  41909. /**
  41910. * Gets the vignette blend mode allowing different kind of effect.
  41911. */
  41912. /**
  41913. * Sets the vignette blend mode allowing different kind of effect.
  41914. */
  41915. vignetteBlendMode: number;
  41916. /**
  41917. * Gets wether the vignette effect is enabled.
  41918. */
  41919. /**
  41920. * Sets wether the vignette effect is enabled.
  41921. */
  41922. vignetteEnabled: boolean;
  41923. private _fromLinearSpace;
  41924. /**
  41925. * Gets wether the input of the processing is in Gamma or Linear Space.
  41926. */
  41927. /**
  41928. * Sets wether the input of the processing is in Gamma or Linear Space.
  41929. */
  41930. fromLinearSpace: boolean;
  41931. /**
  41932. * Defines cache preventing GC.
  41933. */
  41934. private _defines;
  41935. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41936. /**
  41937. * "ImageProcessingPostProcess"
  41938. * @returns "ImageProcessingPostProcess"
  41939. */
  41940. getClassName(): string;
  41941. protected _updateParameters(): void;
  41942. dispose(camera?: Camera): void;
  41943. }
  41944. }
  41945. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41946. import { Scene } from "babylonjs/scene";
  41947. import { Color3 } from "babylonjs/Maths/math.color";
  41948. import { Mesh } from "babylonjs/Meshes/mesh";
  41949. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41950. import { Nullable } from "babylonjs/types";
  41951. /**
  41952. * Class containing static functions to help procedurally build meshes
  41953. */
  41954. export class GroundBuilder {
  41955. /**
  41956. * Creates a ground mesh
  41957. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41958. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41960. * @param name defines the name of the mesh
  41961. * @param options defines the options used to create the mesh
  41962. * @param scene defines the hosting scene
  41963. * @returns the ground mesh
  41964. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41965. */
  41966. static CreateGround(name: string, options: {
  41967. width?: number;
  41968. height?: number;
  41969. subdivisions?: number;
  41970. subdivisionsX?: number;
  41971. subdivisionsY?: number;
  41972. updatable?: boolean;
  41973. }, scene: any): Mesh;
  41974. /**
  41975. * Creates a tiled ground mesh
  41976. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41977. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41978. * * 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
  41979. * * 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
  41980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41981. * @param name defines the name of the mesh
  41982. * @param options defines the options used to create the mesh
  41983. * @param scene defines the hosting scene
  41984. * @returns the tiled ground mesh
  41985. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41986. */
  41987. static CreateTiledGround(name: string, options: {
  41988. xmin: number;
  41989. zmin: number;
  41990. xmax: number;
  41991. zmax: number;
  41992. subdivisions?: {
  41993. w: number;
  41994. h: number;
  41995. };
  41996. precision?: {
  41997. w: number;
  41998. h: number;
  41999. };
  42000. updatable?: boolean;
  42001. }, scene?: Nullable<Scene>): Mesh;
  42002. /**
  42003. * Creates a ground mesh from a height map
  42004. * * The parameter `url` sets the URL of the height map image resource.
  42005. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42006. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42007. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42008. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42009. * * 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.
  42010. * * 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).
  42011. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42013. * @param name defines the name of the mesh
  42014. * @param url defines the url to the height map
  42015. * @param options defines the options used to create the mesh
  42016. * @param scene defines the hosting scene
  42017. * @returns the ground mesh
  42018. * @see https://doc.babylonjs.com/babylon101/height_map
  42019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42020. */
  42021. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42022. width?: number;
  42023. height?: number;
  42024. subdivisions?: number;
  42025. minHeight?: number;
  42026. maxHeight?: number;
  42027. colorFilter?: Color3;
  42028. alphaFilter?: number;
  42029. updatable?: boolean;
  42030. onReady?: (mesh: GroundMesh) => void;
  42031. }, scene?: Nullable<Scene>): GroundMesh;
  42032. }
  42033. }
  42034. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42035. import { Vector4 } from "babylonjs/Maths/math.vector";
  42036. import { Mesh } from "babylonjs/Meshes/mesh";
  42037. /**
  42038. * Class containing static functions to help procedurally build meshes
  42039. */
  42040. export class TorusBuilder {
  42041. /**
  42042. * Creates a torus mesh
  42043. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42044. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42045. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42049. * @param name defines the name of the mesh
  42050. * @param options defines the options used to create the mesh
  42051. * @param scene defines the hosting scene
  42052. * @returns the torus mesh
  42053. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42054. */
  42055. static CreateTorus(name: string, options: {
  42056. diameter?: number;
  42057. thickness?: number;
  42058. tessellation?: number;
  42059. updatable?: boolean;
  42060. sideOrientation?: number;
  42061. frontUVs?: Vector4;
  42062. backUVs?: Vector4;
  42063. }, scene: any): Mesh;
  42064. }
  42065. }
  42066. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42067. import { Vector4 } from "babylonjs/Maths/math.vector";
  42068. import { Color4 } from "babylonjs/Maths/math.color";
  42069. import { Mesh } from "babylonjs/Meshes/mesh";
  42070. /**
  42071. * Class containing static functions to help procedurally build meshes
  42072. */
  42073. export class CylinderBuilder {
  42074. /**
  42075. * Creates a cylinder or a cone mesh
  42076. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42077. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42078. * * 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.
  42079. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42080. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42081. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42082. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42083. * * 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).
  42084. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42085. * * 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).
  42086. * * 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
  42087. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42088. * * 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
  42089. * * 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.
  42090. * * If `enclose` is false, a ring surface is one element.
  42091. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42092. * * 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
  42093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42096. * @param name defines the name of the mesh
  42097. * @param options defines the options used to create the mesh
  42098. * @param scene defines the hosting scene
  42099. * @returns the cylinder mesh
  42100. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42101. */
  42102. static CreateCylinder(name: string, options: {
  42103. height?: number;
  42104. diameterTop?: number;
  42105. diameterBottom?: number;
  42106. diameter?: number;
  42107. tessellation?: number;
  42108. subdivisions?: number;
  42109. arc?: number;
  42110. faceColors?: Color4[];
  42111. faceUV?: Vector4[];
  42112. updatable?: boolean;
  42113. hasRings?: boolean;
  42114. enclose?: boolean;
  42115. cap?: number;
  42116. sideOrientation?: number;
  42117. frontUVs?: Vector4;
  42118. backUVs?: Vector4;
  42119. }, scene: any): Mesh;
  42120. }
  42121. }
  42122. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42123. import { Observable } from "babylonjs/Misc/observable";
  42124. import { Nullable } from "babylonjs/types";
  42125. import { Camera } from "babylonjs/Cameras/camera";
  42126. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42127. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42128. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42129. import { Scene } from "babylonjs/scene";
  42130. import { Vector3 } from "babylonjs/Maths/math.vector";
  42131. import { Color3 } from "babylonjs/Maths/math.color";
  42132. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42134. import { Mesh } from "babylonjs/Meshes/mesh";
  42135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42136. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42137. import "babylonjs/Meshes/Builders/groundBuilder";
  42138. import "babylonjs/Meshes/Builders/torusBuilder";
  42139. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42140. import "babylonjs/Gamepads/gamepadSceneComponent";
  42141. import "babylonjs/Animations/animatable";
  42142. /**
  42143. * Options to modify the vr teleportation behavior.
  42144. */
  42145. export interface VRTeleportationOptions {
  42146. /**
  42147. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42148. */
  42149. floorMeshName?: string;
  42150. /**
  42151. * A list of meshes to be used as the teleportation floor. (default: empty)
  42152. */
  42153. floorMeshes?: Mesh[];
  42154. }
  42155. /**
  42156. * Options to modify the vr experience helper's behavior.
  42157. */
  42158. export interface VRExperienceHelperOptions extends WebVROptions {
  42159. /**
  42160. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42161. */
  42162. createDeviceOrientationCamera?: boolean;
  42163. /**
  42164. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42165. */
  42166. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42167. /**
  42168. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42169. */
  42170. laserToggle?: boolean;
  42171. /**
  42172. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42173. */
  42174. floorMeshes?: Mesh[];
  42175. /**
  42176. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42177. */
  42178. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42179. }
  42180. /**
  42181. * Event containing information after VR has been entered
  42182. */
  42183. export class OnAfterEnteringVRObservableEvent {
  42184. /**
  42185. * If entering vr was successful
  42186. */
  42187. success: boolean;
  42188. }
  42189. /**
  42190. * Helps to quickly add VR support to an existing scene.
  42191. * See http://doc.babylonjs.com/how_to/webvr_helper
  42192. */
  42193. export class VRExperienceHelper {
  42194. /** Options to modify the vr experience helper's behavior. */
  42195. webVROptions: VRExperienceHelperOptions;
  42196. private _scene;
  42197. private _position;
  42198. private _btnVR;
  42199. private _btnVRDisplayed;
  42200. private _webVRsupported;
  42201. private _webVRready;
  42202. private _webVRrequesting;
  42203. private _webVRpresenting;
  42204. private _hasEnteredVR;
  42205. private _fullscreenVRpresenting;
  42206. private _canvas;
  42207. private _webVRCamera;
  42208. private _vrDeviceOrientationCamera;
  42209. private _deviceOrientationCamera;
  42210. private _existingCamera;
  42211. private _onKeyDown;
  42212. private _onVrDisplayPresentChange;
  42213. private _onVRDisplayChanged;
  42214. private _onVRRequestPresentStart;
  42215. private _onVRRequestPresentComplete;
  42216. /**
  42217. * 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)
  42218. */
  42219. enableGazeEvenWhenNoPointerLock: boolean;
  42220. /**
  42221. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42222. */
  42223. exitVROnDoubleTap: boolean;
  42224. /**
  42225. * Observable raised right before entering VR.
  42226. */
  42227. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42228. /**
  42229. * Observable raised when entering VR has completed.
  42230. */
  42231. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42232. /**
  42233. * Observable raised when exiting VR.
  42234. */
  42235. onExitingVRObservable: Observable<VRExperienceHelper>;
  42236. /**
  42237. * Observable raised when controller mesh is loaded.
  42238. */
  42239. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42240. /** Return this.onEnteringVRObservable
  42241. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42242. */
  42243. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42244. /** Return this.onExitingVRObservable
  42245. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42246. */
  42247. readonly onExitingVR: Observable<VRExperienceHelper>;
  42248. /** Return this.onControllerMeshLoadedObservable
  42249. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42250. */
  42251. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42252. private _rayLength;
  42253. private _useCustomVRButton;
  42254. private _teleportationRequested;
  42255. private _teleportActive;
  42256. private _floorMeshName;
  42257. private _floorMeshesCollection;
  42258. private _rotationAllowed;
  42259. private _teleportBackwardsVector;
  42260. private _teleportationTarget;
  42261. private _isDefaultTeleportationTarget;
  42262. private _postProcessMove;
  42263. private _teleportationFillColor;
  42264. private _teleportationBorderColor;
  42265. private _rotationAngle;
  42266. private _haloCenter;
  42267. private _cameraGazer;
  42268. private _padSensibilityUp;
  42269. private _padSensibilityDown;
  42270. private _leftController;
  42271. private _rightController;
  42272. /**
  42273. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42274. */
  42275. onNewMeshSelected: Observable<AbstractMesh>;
  42276. /**
  42277. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42278. */
  42279. onNewMeshPicked: Observable<PickingInfo>;
  42280. private _circleEase;
  42281. /**
  42282. * Observable raised before camera teleportation
  42283. */
  42284. onBeforeCameraTeleport: Observable<Vector3>;
  42285. /**
  42286. * Observable raised after camera teleportation
  42287. */
  42288. onAfterCameraTeleport: Observable<Vector3>;
  42289. /**
  42290. * Observable raised when current selected mesh gets unselected
  42291. */
  42292. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42293. private _raySelectionPredicate;
  42294. /**
  42295. * To be optionaly changed by user to define custom ray selection
  42296. */
  42297. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42298. /**
  42299. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42300. */
  42301. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42302. /**
  42303. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42304. */
  42305. teleportationEnabled: boolean;
  42306. private _defaultHeight;
  42307. private _teleportationInitialized;
  42308. private _interactionsEnabled;
  42309. private _interactionsRequested;
  42310. private _displayGaze;
  42311. private _displayLaserPointer;
  42312. /**
  42313. * The mesh used to display where the user is going to teleport.
  42314. */
  42315. /**
  42316. * Sets the mesh to be used to display where the user is going to teleport.
  42317. */
  42318. teleportationTarget: Mesh;
  42319. /**
  42320. * 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
  42321. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42322. * See http://doc.babylonjs.com/resources/baking_transformations
  42323. */
  42324. gazeTrackerMesh: Mesh;
  42325. /**
  42326. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42327. */
  42328. updateGazeTrackerScale: boolean;
  42329. /**
  42330. * If the gaze trackers color should be updated when selecting meshes
  42331. */
  42332. updateGazeTrackerColor: boolean;
  42333. /**
  42334. * The gaze tracking mesh corresponding to the left controller
  42335. */
  42336. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42337. /**
  42338. * The gaze tracking mesh corresponding to the right controller
  42339. */
  42340. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42341. /**
  42342. * If the ray of the gaze should be displayed.
  42343. */
  42344. /**
  42345. * Sets if the ray of the gaze should be displayed.
  42346. */
  42347. displayGaze: boolean;
  42348. /**
  42349. * If the ray of the LaserPointer should be displayed.
  42350. */
  42351. /**
  42352. * Sets if the ray of the LaserPointer should be displayed.
  42353. */
  42354. displayLaserPointer: boolean;
  42355. /**
  42356. * The deviceOrientationCamera used as the camera when not in VR.
  42357. */
  42358. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42359. /**
  42360. * Based on the current WebVR support, returns the current VR camera used.
  42361. */
  42362. readonly currentVRCamera: Nullable<Camera>;
  42363. /**
  42364. * The webVRCamera which is used when in VR.
  42365. */
  42366. readonly webVRCamera: WebVRFreeCamera;
  42367. /**
  42368. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42369. */
  42370. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42371. /**
  42372. * The html button that is used to trigger entering into VR.
  42373. */
  42374. readonly vrButton: Nullable<HTMLButtonElement>;
  42375. private readonly _teleportationRequestInitiated;
  42376. /**
  42377. * Defines wether or not Pointer lock should be requested when switching to
  42378. * full screen.
  42379. */
  42380. requestPointerLockOnFullScreen: boolean;
  42381. /**
  42382. * Instantiates a VRExperienceHelper.
  42383. * Helps to quickly add VR support to an existing scene.
  42384. * @param scene The scene the VRExperienceHelper belongs to.
  42385. * @param webVROptions Options to modify the vr experience helper's behavior.
  42386. */
  42387. constructor(scene: Scene,
  42388. /** Options to modify the vr experience helper's behavior. */
  42389. webVROptions?: VRExperienceHelperOptions);
  42390. private _onDefaultMeshLoaded;
  42391. private _onResize;
  42392. private _onFullscreenChange;
  42393. /**
  42394. * Gets a value indicating if we are currently in VR mode.
  42395. */
  42396. readonly isInVRMode: boolean;
  42397. private onVrDisplayPresentChange;
  42398. private onVRDisplayChanged;
  42399. private moveButtonToBottomRight;
  42400. private displayVRButton;
  42401. private updateButtonVisibility;
  42402. private _cachedAngularSensibility;
  42403. /**
  42404. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42405. * Otherwise, will use the fullscreen API.
  42406. */
  42407. enterVR(): void;
  42408. /**
  42409. * Attempt to exit VR, or fullscreen.
  42410. */
  42411. exitVR(): void;
  42412. /**
  42413. * The position of the vr experience helper.
  42414. */
  42415. /**
  42416. * Sets the position of the vr experience helper.
  42417. */
  42418. position: Vector3;
  42419. /**
  42420. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42421. */
  42422. enableInteractions(): void;
  42423. private readonly _noControllerIsActive;
  42424. private beforeRender;
  42425. private _isTeleportationFloor;
  42426. /**
  42427. * Adds a floor mesh to be used for teleportation.
  42428. * @param floorMesh the mesh to be used for teleportation.
  42429. */
  42430. addFloorMesh(floorMesh: Mesh): void;
  42431. /**
  42432. * Removes a floor mesh from being used for teleportation.
  42433. * @param floorMesh the mesh to be removed.
  42434. */
  42435. removeFloorMesh(floorMesh: Mesh): void;
  42436. /**
  42437. * Enables interactions and teleportation using the VR controllers and gaze.
  42438. * @param vrTeleportationOptions options to modify teleportation behavior.
  42439. */
  42440. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42441. private _onNewGamepadConnected;
  42442. private _tryEnableInteractionOnController;
  42443. private _onNewGamepadDisconnected;
  42444. private _enableInteractionOnController;
  42445. private _checkTeleportWithRay;
  42446. private _checkRotate;
  42447. private _checkTeleportBackwards;
  42448. private _enableTeleportationOnController;
  42449. private _createTeleportationCircles;
  42450. private _displayTeleportationTarget;
  42451. private _hideTeleportationTarget;
  42452. private _rotateCamera;
  42453. private _moveTeleportationSelectorTo;
  42454. private _workingVector;
  42455. private _workingQuaternion;
  42456. private _workingMatrix;
  42457. /**
  42458. * Teleports the users feet to the desired location
  42459. * @param location The location where the user's feet should be placed
  42460. */
  42461. teleportCamera(location: Vector3): void;
  42462. private _convertNormalToDirectionOfRay;
  42463. private _castRayAndSelectObject;
  42464. private _notifySelectedMeshUnselected;
  42465. /**
  42466. * Sets the color of the laser ray from the vr controllers.
  42467. * @param color new color for the ray.
  42468. */
  42469. changeLaserColor(color: Color3): void;
  42470. /**
  42471. * Sets the color of the ray from the vr headsets gaze.
  42472. * @param color new color for the ray.
  42473. */
  42474. changeGazeColor(color: Color3): void;
  42475. /**
  42476. * Exits VR and disposes of the vr experience helper
  42477. */
  42478. dispose(): void;
  42479. /**
  42480. * Gets the name of the VRExperienceHelper class
  42481. * @returns "VRExperienceHelper"
  42482. */
  42483. getClassName(): string;
  42484. }
  42485. }
  42486. declare module "babylonjs/Cameras/VR/index" {
  42487. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42488. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42489. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42490. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42491. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42492. export * from "babylonjs/Cameras/VR/webVRCamera";
  42493. }
  42494. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42495. import { Observable } from "babylonjs/Misc/observable";
  42496. import { Nullable } from "babylonjs/types";
  42497. import { IDisposable, Scene } from "babylonjs/scene";
  42498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42499. /**
  42500. * Manages an XRSession to work with Babylon's engine
  42501. * @see https://doc.babylonjs.com/how_to/webxr
  42502. */
  42503. export class WebXRSessionManager implements IDisposable {
  42504. private scene;
  42505. /**
  42506. * Fires every time a new xrFrame arrives which can be used to update the camera
  42507. */
  42508. onXRFrameObservable: Observable<any>;
  42509. /**
  42510. * Fires when the xr session is ended either by the device or manually done
  42511. */
  42512. onXRSessionEnded: Observable<any>;
  42513. /**
  42514. * Underlying xr session
  42515. */
  42516. session: XRSession;
  42517. /**
  42518. * Type of reference space used when creating the session
  42519. */
  42520. referenceSpace: XRReferenceSpace;
  42521. /** @hidden */
  42522. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42523. /**
  42524. * Current XR frame
  42525. */
  42526. currentFrame: Nullable<XRFrame>;
  42527. private _xrNavigator;
  42528. private baseLayer;
  42529. /**
  42530. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42531. * @param scene The scene which the session should be created for
  42532. */
  42533. constructor(scene: Scene);
  42534. /**
  42535. * Initializes the manager
  42536. * After initialization enterXR can be called to start an XR session
  42537. * @returns Promise which resolves after it is initialized
  42538. */
  42539. initializeAsync(): Promise<void>;
  42540. /**
  42541. * Initializes an xr session
  42542. * @param xrSessionMode mode to initialize
  42543. * @returns a promise which will resolve once the session has been initialized
  42544. */
  42545. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42546. /**
  42547. * Sets the reference space on the xr session
  42548. * @param referenceSpace space to set
  42549. * @returns a promise that will resolve once the reference space has been set
  42550. */
  42551. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42552. /**
  42553. * Updates the render state of the session
  42554. * @param state state to set
  42555. * @returns a promise that resolves once the render state has been updated
  42556. */
  42557. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42558. /**
  42559. * Starts rendering to the xr layer
  42560. * @returns a promise that will resolve once rendering has started
  42561. */
  42562. startRenderingToXRAsync(): Promise<void>;
  42563. /**
  42564. * Stops the xrSession and restores the renderloop
  42565. * @returns Promise which resolves after it exits XR
  42566. */
  42567. exitXRAsync(): Promise<unknown>;
  42568. /**
  42569. * Checks if a session would be supported for the creation options specified
  42570. * @param sessionMode session mode to check if supported eg. immersive-vr
  42571. * @returns true if supported
  42572. */
  42573. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42574. /**
  42575. * @hidden
  42576. * Converts the render layer of xrSession to a render target
  42577. * @param session session to create render target for
  42578. * @param scene scene the new render target should be created for
  42579. */
  42580. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42581. /**
  42582. * Disposes of the session manager
  42583. */
  42584. dispose(): void;
  42585. }
  42586. }
  42587. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42588. import { Scene } from "babylonjs/scene";
  42589. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42590. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42591. /**
  42592. * WebXR Camera which holds the views for the xrSession
  42593. * @see https://doc.babylonjs.com/how_to/webxr
  42594. */
  42595. export class WebXRCamera extends FreeCamera {
  42596. private static _TmpMatrix;
  42597. /**
  42598. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42599. * @param name the name of the camera
  42600. * @param scene the scene to add the camera to
  42601. */
  42602. constructor(name: string, scene: Scene);
  42603. private _updateNumberOfRigCameras;
  42604. /** @hidden */
  42605. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42606. /**
  42607. * Updates the cameras position from the current pose information of the XR session
  42608. * @param xrSessionManager the session containing pose information
  42609. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42610. */
  42611. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42615. import { Nullable } from "babylonjs/types";
  42616. import { IDisposable } from "babylonjs/scene";
  42617. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42618. /**
  42619. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42620. */
  42621. export class WebXRManagedOutputCanvas implements IDisposable {
  42622. private helper;
  42623. private _canvas;
  42624. /**
  42625. * xrpresent context of the canvas which can be used to display/mirror xr content
  42626. */
  42627. canvasContext: WebGLRenderingContext;
  42628. /**
  42629. * xr layer for the canvas
  42630. */
  42631. xrLayer: Nullable<XRWebGLLayer>;
  42632. /**
  42633. * Initializes the xr layer for the session
  42634. * @param xrSession xr session
  42635. * @returns a promise that will resolve once the XR Layer has been created
  42636. */
  42637. initializeXRLayerAsync(xrSession: any): any;
  42638. /**
  42639. * Initializes the canvas to be added/removed upon entering/exiting xr
  42640. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42641. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42642. */
  42643. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42644. /**
  42645. * Disposes of the object
  42646. */
  42647. dispose(): void;
  42648. private _setManagedOutputCanvas;
  42649. private _addCanvas;
  42650. private _removeCanvas;
  42651. }
  42652. }
  42653. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42654. import { Observable } from "babylonjs/Misc/observable";
  42655. import { IDisposable, Scene } from "babylonjs/scene";
  42656. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42658. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42659. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42660. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42661. /**
  42662. * States of the webXR experience
  42663. */
  42664. export enum WebXRState {
  42665. /**
  42666. * Transitioning to being in XR mode
  42667. */
  42668. ENTERING_XR = 0,
  42669. /**
  42670. * Transitioning to non XR mode
  42671. */
  42672. EXITING_XR = 1,
  42673. /**
  42674. * In XR mode and presenting
  42675. */
  42676. IN_XR = 2,
  42677. /**
  42678. * Not entered XR mode
  42679. */
  42680. NOT_IN_XR = 3
  42681. }
  42682. /**
  42683. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42684. * @see https://doc.babylonjs.com/how_to/webxr
  42685. */
  42686. export class WebXRExperienceHelper implements IDisposable {
  42687. private scene;
  42688. /**
  42689. * 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
  42690. */
  42691. container: AbstractMesh;
  42692. /**
  42693. * Camera used to render xr content
  42694. */
  42695. camera: WebXRCamera;
  42696. /**
  42697. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42698. */
  42699. state: WebXRState;
  42700. private _setState;
  42701. private static _TmpVector;
  42702. /**
  42703. * Fires when the state of the experience helper has changed
  42704. */
  42705. onStateChangedObservable: Observable<WebXRState>;
  42706. /** Session manager used to keep track of xr session */
  42707. sessionManager: WebXRSessionManager;
  42708. private _nonVRCamera;
  42709. private _originalSceneAutoClear;
  42710. private _supported;
  42711. /**
  42712. * Creates the experience helper
  42713. * @param scene the scene to attach the experience helper to
  42714. * @returns a promise for the experience helper
  42715. */
  42716. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42717. /**
  42718. * Creates a WebXRExperienceHelper
  42719. * @param scene The scene the helper should be created in
  42720. */
  42721. private constructor();
  42722. /**
  42723. * Exits XR mode and returns the scene to its original state
  42724. * @returns promise that resolves after xr mode has exited
  42725. */
  42726. exitXRAsync(): Promise<unknown>;
  42727. /**
  42728. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42729. * @param sessionCreationOptions options for the XR session
  42730. * @param referenceSpaceType frame of reference of the XR session
  42731. * @param outputCanvas the output canvas that will be used to enter XR mode
  42732. * @returns promise that resolves after xr mode has entered
  42733. */
  42734. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42735. /**
  42736. * Updates the global position of the camera by moving the camera's container
  42737. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42738. * @param position The desired global position of the camera
  42739. */
  42740. setPositionOfCameraUsingContainer(position: Vector3): void;
  42741. /**
  42742. * Rotates the xr camera by rotating the camera's container around the camera's position
  42743. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42744. * @param rotation the desired quaternion rotation to apply to the camera
  42745. */
  42746. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42747. /**
  42748. * Disposes of the experience helper
  42749. */
  42750. dispose(): void;
  42751. }
  42752. }
  42753. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42754. import { Nullable } from "babylonjs/types";
  42755. import { Observable } from "babylonjs/Misc/observable";
  42756. import { IDisposable, Scene } from "babylonjs/scene";
  42757. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42758. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42759. /**
  42760. * Button which can be used to enter a different mode of XR
  42761. */
  42762. export class WebXREnterExitUIButton {
  42763. /** button element */
  42764. element: HTMLElement;
  42765. /** XR initialization options for the button */
  42766. sessionMode: XRSessionMode;
  42767. /** Reference space type */
  42768. referenceSpaceType: XRReferenceSpaceType;
  42769. /**
  42770. * Creates a WebXREnterExitUIButton
  42771. * @param element button element
  42772. * @param sessionMode XR initialization session mode
  42773. * @param referenceSpaceType the type of reference space to be used
  42774. */
  42775. constructor(
  42776. /** button element */
  42777. element: HTMLElement,
  42778. /** XR initialization options for the button */
  42779. sessionMode: XRSessionMode,
  42780. /** Reference space type */
  42781. referenceSpaceType: XRReferenceSpaceType);
  42782. /**
  42783. * Overwritable function which can be used to update the button's visuals when the state changes
  42784. * @param activeButton the current active button in the UI
  42785. */
  42786. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42787. }
  42788. /**
  42789. * Options to create the webXR UI
  42790. */
  42791. export class WebXREnterExitUIOptions {
  42792. /**
  42793. * Context to enter xr with
  42794. */
  42795. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42796. /**
  42797. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42798. */
  42799. customButtons?: Array<WebXREnterExitUIButton>;
  42800. }
  42801. /**
  42802. * UI to allow the user to enter/exit XR mode
  42803. */
  42804. export class WebXREnterExitUI implements IDisposable {
  42805. private scene;
  42806. private _overlay;
  42807. private _buttons;
  42808. private _activeButton;
  42809. /**
  42810. * Fired every time the active button is changed.
  42811. *
  42812. * When xr is entered via a button that launches xr that button will be the callback parameter
  42813. *
  42814. * When exiting xr the callback parameter will be null)
  42815. */
  42816. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42817. /**
  42818. * Creates UI to allow the user to enter/exit XR mode
  42819. * @param scene the scene to add the ui to
  42820. * @param helper the xr experience helper to enter/exit xr with
  42821. * @param options options to configure the UI
  42822. * @returns the created ui
  42823. */
  42824. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42825. private constructor();
  42826. private _updateButtons;
  42827. /**
  42828. * Disposes of the object
  42829. */
  42830. dispose(): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Cameras/XR/webXRController" {
  42834. import { Nullable } from "babylonjs/types";
  42835. import { Observable } from "babylonjs/Misc/observable";
  42836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42837. import { Ray } from "babylonjs/Culling/ray";
  42838. import { Scene } from "babylonjs/scene";
  42839. /**
  42840. * Represents an XR input
  42841. */
  42842. export class WebXRController {
  42843. private scene;
  42844. /** The underlying input source for the controller */
  42845. inputSource: XRInputSource;
  42846. private parentContainer;
  42847. /**
  42848. * 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
  42849. */
  42850. grip?: AbstractMesh;
  42851. /**
  42852. * Pointer which can be used to select objects or attach a visible laser to
  42853. */
  42854. pointer: AbstractMesh;
  42855. /**
  42856. * Event that fires when the controller is removed/disposed
  42857. */
  42858. onDisposeObservable: Observable<{}>;
  42859. private _tmpMatrix;
  42860. private _tmpQuaternion;
  42861. private _tmpVector;
  42862. /**
  42863. * Creates the controller
  42864. * @see https://doc.babylonjs.com/how_to/webxr
  42865. * @param scene the scene which the controller should be associated to
  42866. * @param inputSource the underlying input source for the controller
  42867. * @param parentContainer parent that the controller meshes should be children of
  42868. */
  42869. constructor(scene: Scene,
  42870. /** The underlying input source for the controller */
  42871. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42872. /**
  42873. * Updates the controller pose based on the given XRFrame
  42874. * @param xrFrame xr frame to update the pose with
  42875. * @param referenceSpace reference space to use
  42876. */
  42877. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42878. /**
  42879. * Gets a world space ray coming from the controller
  42880. * @param result the resulting ray
  42881. */
  42882. getWorldPointerRayToRef(result: Ray): void;
  42883. /**
  42884. * Disposes of the object
  42885. */
  42886. dispose(): void;
  42887. }
  42888. }
  42889. declare module "babylonjs/Cameras/XR/webXRInput" {
  42890. import { Observable } from "babylonjs/Misc/observable";
  42891. import { IDisposable } from "babylonjs/scene";
  42892. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42893. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42894. /**
  42895. * XR input used to track XR inputs such as controllers/rays
  42896. */
  42897. export class WebXRInput implements IDisposable {
  42898. /**
  42899. * Base experience the input listens to
  42900. */
  42901. baseExperience: WebXRExperienceHelper;
  42902. /**
  42903. * XR controllers being tracked
  42904. */
  42905. controllers: Array<WebXRController>;
  42906. private _frameObserver;
  42907. private _stateObserver;
  42908. /**
  42909. * Event when a controller has been connected/added
  42910. */
  42911. onControllerAddedObservable: Observable<WebXRController>;
  42912. /**
  42913. * Event when a controller has been removed/disconnected
  42914. */
  42915. onControllerRemovedObservable: Observable<WebXRController>;
  42916. /**
  42917. * Initializes the WebXRInput
  42918. * @param baseExperience experience helper which the input should be created for
  42919. */
  42920. constructor(
  42921. /**
  42922. * Base experience the input listens to
  42923. */
  42924. baseExperience: WebXRExperienceHelper);
  42925. private _onInputSourcesChange;
  42926. private _addAndRemoveControllers;
  42927. /**
  42928. * Disposes of the object
  42929. */
  42930. dispose(): void;
  42931. }
  42932. }
  42933. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42935. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42936. /**
  42937. * Enables teleportation
  42938. */
  42939. export class WebXRControllerTeleportation {
  42940. private _teleportationFillColor;
  42941. private _teleportationBorderColor;
  42942. private _tmpRay;
  42943. private _tmpVector;
  42944. /**
  42945. * Creates a WebXRControllerTeleportation
  42946. * @param input input manager to add teleportation to
  42947. * @param floorMeshes floormeshes which can be teleported to
  42948. */
  42949. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42950. }
  42951. }
  42952. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42953. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42954. /**
  42955. * Handles pointer input automatically for the pointer of XR controllers
  42956. */
  42957. export class WebXRControllerPointerSelection {
  42958. private static _idCounter;
  42959. private _tmpRay;
  42960. /**
  42961. * Creates a WebXRControllerPointerSelection
  42962. * @param input input manager to setup pointer selection
  42963. */
  42964. constructor(input: WebXRInput);
  42965. private _convertNormalToDirectionOfRay;
  42966. private _updatePointerDistance;
  42967. }
  42968. }
  42969. declare module "babylonjs/Loading/sceneLoader" {
  42970. import { Observable } from "babylonjs/Misc/observable";
  42971. import { Nullable } from "babylonjs/types";
  42972. import { Scene } from "babylonjs/scene";
  42973. import { Engine } from "babylonjs/Engines/engine";
  42974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42975. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42976. import { AssetContainer } from "babylonjs/assetContainer";
  42977. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42978. import { Skeleton } from "babylonjs/Bones/skeleton";
  42979. /**
  42980. * Class used to represent data loading progression
  42981. */
  42982. export class SceneLoaderProgressEvent {
  42983. /** defines if data length to load can be evaluated */
  42984. readonly lengthComputable: boolean;
  42985. /** defines the loaded data length */
  42986. readonly loaded: number;
  42987. /** defines the data length to load */
  42988. readonly total: number;
  42989. /**
  42990. * Create a new progress event
  42991. * @param lengthComputable defines if data length to load can be evaluated
  42992. * @param loaded defines the loaded data length
  42993. * @param total defines the data length to load
  42994. */
  42995. constructor(
  42996. /** defines if data length to load can be evaluated */
  42997. lengthComputable: boolean,
  42998. /** defines the loaded data length */
  42999. loaded: number,
  43000. /** defines the data length to load */
  43001. total: number);
  43002. /**
  43003. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43004. * @param event defines the source event
  43005. * @returns a new SceneLoaderProgressEvent
  43006. */
  43007. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43008. }
  43009. /**
  43010. * Interface used by SceneLoader plugins to define supported file extensions
  43011. */
  43012. export interface ISceneLoaderPluginExtensions {
  43013. /**
  43014. * Defines the list of supported extensions
  43015. */
  43016. [extension: string]: {
  43017. isBinary: boolean;
  43018. };
  43019. }
  43020. /**
  43021. * Interface used by SceneLoader plugin factory
  43022. */
  43023. export interface ISceneLoaderPluginFactory {
  43024. /**
  43025. * Defines the name of the factory
  43026. */
  43027. name: string;
  43028. /**
  43029. * Function called to create a new plugin
  43030. * @return the new plugin
  43031. */
  43032. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43033. /**
  43034. * Boolean indicating if the plugin can direct load specific data
  43035. */
  43036. canDirectLoad?: (data: string) => boolean;
  43037. }
  43038. /**
  43039. * Interface used to define a SceneLoader plugin
  43040. */
  43041. export interface ISceneLoaderPlugin {
  43042. /**
  43043. * The friendly name of this plugin.
  43044. */
  43045. name: string;
  43046. /**
  43047. * The file extensions supported by this plugin.
  43048. */
  43049. extensions: string | ISceneLoaderPluginExtensions;
  43050. /**
  43051. * Import meshes into a scene.
  43052. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43053. * @param scene The scene to import into
  43054. * @param data The data to import
  43055. * @param rootUrl The root url for scene and resources
  43056. * @param meshes The meshes array to import into
  43057. * @param particleSystems The particle systems array to import into
  43058. * @param skeletons The skeletons array to import into
  43059. * @param onError The callback when import fails
  43060. * @returns True if successful or false otherwise
  43061. */
  43062. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43063. /**
  43064. * Load into a scene.
  43065. * @param scene The scene to load into
  43066. * @param data The data to import
  43067. * @param rootUrl The root url for scene and resources
  43068. * @param onError The callback when import fails
  43069. * @returns true if successful or false otherwise
  43070. */
  43071. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43072. /**
  43073. * The callback that returns true if the data can be directly loaded.
  43074. */
  43075. canDirectLoad?: (data: string) => boolean;
  43076. /**
  43077. * The callback that allows custom handling of the root url based on the response url.
  43078. */
  43079. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43080. /**
  43081. * Load into an asset container.
  43082. * @param scene The scene to load into
  43083. * @param data The data to import
  43084. * @param rootUrl The root url for scene and resources
  43085. * @param onError The callback when import fails
  43086. * @returns The loaded asset container
  43087. */
  43088. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43089. }
  43090. /**
  43091. * Interface used to define an async SceneLoader plugin
  43092. */
  43093. export interface ISceneLoaderPluginAsync {
  43094. /**
  43095. * The friendly name of this plugin.
  43096. */
  43097. name: string;
  43098. /**
  43099. * The file extensions supported by this plugin.
  43100. */
  43101. extensions: string | ISceneLoaderPluginExtensions;
  43102. /**
  43103. * Import meshes into a scene.
  43104. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43105. * @param scene The scene to import into
  43106. * @param data The data to import
  43107. * @param rootUrl The root url for scene and resources
  43108. * @param onProgress The callback when the load progresses
  43109. * @param fileName Defines the name of the file to load
  43110. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43111. */
  43112. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43113. meshes: AbstractMesh[];
  43114. particleSystems: IParticleSystem[];
  43115. skeletons: Skeleton[];
  43116. animationGroups: AnimationGroup[];
  43117. }>;
  43118. /**
  43119. * Load into a scene.
  43120. * @param scene The scene to load into
  43121. * @param data The data to import
  43122. * @param rootUrl The root url for scene and resources
  43123. * @param onProgress The callback when the load progresses
  43124. * @param fileName Defines the name of the file to load
  43125. * @returns Nothing
  43126. */
  43127. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43128. /**
  43129. * The callback that returns true if the data can be directly loaded.
  43130. */
  43131. canDirectLoad?: (data: string) => boolean;
  43132. /**
  43133. * The callback that allows custom handling of the root url based on the response url.
  43134. */
  43135. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43136. /**
  43137. * Load into an asset container.
  43138. * @param scene The scene to load into
  43139. * @param data The data to import
  43140. * @param rootUrl The root url for scene and resources
  43141. * @param onProgress The callback when the load progresses
  43142. * @param fileName Defines the name of the file to load
  43143. * @returns The loaded asset container
  43144. */
  43145. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43146. }
  43147. /**
  43148. * Class used to load scene from various file formats using registered plugins
  43149. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43150. */
  43151. export class SceneLoader {
  43152. /**
  43153. * No logging while loading
  43154. */
  43155. static readonly NO_LOGGING: number;
  43156. /**
  43157. * Minimal logging while loading
  43158. */
  43159. static readonly MINIMAL_LOGGING: number;
  43160. /**
  43161. * Summary logging while loading
  43162. */
  43163. static readonly SUMMARY_LOGGING: number;
  43164. /**
  43165. * Detailled logging while loading
  43166. */
  43167. static readonly DETAILED_LOGGING: number;
  43168. /**
  43169. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43170. */
  43171. static ForceFullSceneLoadingForIncremental: boolean;
  43172. /**
  43173. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43174. */
  43175. static ShowLoadingScreen: boolean;
  43176. /**
  43177. * Defines the current logging level (while loading the scene)
  43178. * @ignorenaming
  43179. */
  43180. static loggingLevel: number;
  43181. /**
  43182. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43183. */
  43184. static CleanBoneMatrixWeights: boolean;
  43185. /**
  43186. * Event raised when a plugin is used to load a scene
  43187. */
  43188. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43189. private static _registeredPlugins;
  43190. private static _getDefaultPlugin;
  43191. private static _getPluginForExtension;
  43192. private static _getPluginForDirectLoad;
  43193. private static _getPluginForFilename;
  43194. private static _getDirectLoad;
  43195. private static _loadData;
  43196. private static _getFileInfo;
  43197. /**
  43198. * Gets a plugin that can load the given extension
  43199. * @param extension defines the extension to load
  43200. * @returns a plugin or null if none works
  43201. */
  43202. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43203. /**
  43204. * Gets a boolean indicating that the given extension can be loaded
  43205. * @param extension defines the extension to load
  43206. * @returns true if the extension is supported
  43207. */
  43208. static IsPluginForExtensionAvailable(extension: string): boolean;
  43209. /**
  43210. * Adds a new plugin to the list of registered plugins
  43211. * @param plugin defines the plugin to add
  43212. */
  43213. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43214. /**
  43215. * Import meshes into a scene
  43216. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43217. * @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)
  43218. * @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)
  43219. * @param scene the instance of BABYLON.Scene to append to
  43220. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43221. * @param onProgress a callback with a progress event for each file being loaded
  43222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43223. * @param pluginExtension the extension used to determine the plugin
  43224. * @returns The loaded plugin
  43225. */
  43226. 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>;
  43227. /**
  43228. * Import meshes into a scene
  43229. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43230. * @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)
  43231. * @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)
  43232. * @param scene the instance of BABYLON.Scene to append to
  43233. * @param onProgress a callback with a progress event for each file being loaded
  43234. * @param pluginExtension the extension used to determine the plugin
  43235. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43236. */
  43237. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43238. meshes: AbstractMesh[];
  43239. particleSystems: IParticleSystem[];
  43240. skeletons: Skeleton[];
  43241. animationGroups: AnimationGroup[];
  43242. }>;
  43243. /**
  43244. * Load a scene
  43245. * @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)
  43246. * @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)
  43247. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43248. * @param onSuccess a callback with the scene when import succeeds
  43249. * @param onProgress a callback with a progress event for each file being loaded
  43250. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43251. * @param pluginExtension the extension used to determine the plugin
  43252. * @returns The loaded plugin
  43253. */
  43254. 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>;
  43255. /**
  43256. * Load a scene
  43257. * @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)
  43258. * @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)
  43259. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43260. * @param onProgress a callback with a progress event for each file being loaded
  43261. * @param pluginExtension the extension used to determine the plugin
  43262. * @returns The loaded scene
  43263. */
  43264. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43265. /**
  43266. * Append a scene
  43267. * @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)
  43268. * @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)
  43269. * @param scene is the instance of BABYLON.Scene to append to
  43270. * @param onSuccess a callback with the scene when import succeeds
  43271. * @param onProgress a callback with a progress event for each file being loaded
  43272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43273. * @param pluginExtension the extension used to determine the plugin
  43274. * @returns The loaded plugin
  43275. */
  43276. 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>;
  43277. /**
  43278. * Append a scene
  43279. * @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)
  43280. * @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)
  43281. * @param scene is the instance of BABYLON.Scene to append to
  43282. * @param onProgress a callback with a progress event for each file being loaded
  43283. * @param pluginExtension the extension used to determine the plugin
  43284. * @returns The given scene
  43285. */
  43286. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43287. /**
  43288. * Load a scene into an asset container
  43289. * @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)
  43290. * @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)
  43291. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43292. * @param onSuccess a callback with the scene when import succeeds
  43293. * @param onProgress a callback with a progress event for each file being loaded
  43294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43295. * @param pluginExtension the extension used to determine the plugin
  43296. * @returns The loaded plugin
  43297. */
  43298. 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>;
  43299. /**
  43300. * Load a scene into an asset container
  43301. * @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)
  43302. * @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)
  43303. * @param scene is the instance of Scene to append to
  43304. * @param onProgress a callback with a progress event for each file being loaded
  43305. * @param pluginExtension the extension used to determine the plugin
  43306. * @returns The loaded asset container
  43307. */
  43308. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43309. }
  43310. }
  43311. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43312. import { Scene } from "babylonjs/scene";
  43313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43314. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43315. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43316. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43317. /**
  43318. * Generic Controller
  43319. */
  43320. export class GenericController extends WebVRController {
  43321. /**
  43322. * Base Url for the controller model.
  43323. */
  43324. static readonly MODEL_BASE_URL: string;
  43325. /**
  43326. * File name for the controller model.
  43327. */
  43328. static readonly MODEL_FILENAME: string;
  43329. /**
  43330. * Creates a new GenericController from a gamepad
  43331. * @param vrGamepad the gamepad that the controller should be created from
  43332. */
  43333. constructor(vrGamepad: any);
  43334. /**
  43335. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43336. * @param scene scene in which to add meshes
  43337. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43338. */
  43339. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43340. /**
  43341. * Called once for each button that changed state since the last frame
  43342. * @param buttonIdx Which button index changed
  43343. * @param state New state of the button
  43344. * @param changes Which properties on the state changed since last frame
  43345. */
  43346. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43347. }
  43348. }
  43349. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43350. import { Observable } from "babylonjs/Misc/observable";
  43351. import { Scene } from "babylonjs/scene";
  43352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43353. import { Ray } from "babylonjs/Culling/ray";
  43354. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43355. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43356. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43357. /**
  43358. * Defines the WindowsMotionController object that the state of the windows motion controller
  43359. */
  43360. export class WindowsMotionController extends WebVRController {
  43361. /**
  43362. * The base url used to load the left and right controller models
  43363. */
  43364. static MODEL_BASE_URL: string;
  43365. /**
  43366. * The name of the left controller model file
  43367. */
  43368. static MODEL_LEFT_FILENAME: string;
  43369. /**
  43370. * The name of the right controller model file
  43371. */
  43372. static MODEL_RIGHT_FILENAME: string;
  43373. /**
  43374. * The controller name prefix for this controller type
  43375. */
  43376. static readonly GAMEPAD_ID_PREFIX: string;
  43377. /**
  43378. * The controller id pattern for this controller type
  43379. */
  43380. private static readonly GAMEPAD_ID_PATTERN;
  43381. private _loadedMeshInfo;
  43382. private readonly _mapping;
  43383. /**
  43384. * Fired when the trackpad on this controller is clicked
  43385. */
  43386. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43387. /**
  43388. * Fired when the trackpad on this controller is modified
  43389. */
  43390. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43391. /**
  43392. * The current x and y values of this controller's trackpad
  43393. */
  43394. trackpad: StickValues;
  43395. /**
  43396. * Creates a new WindowsMotionController from a gamepad
  43397. * @param vrGamepad the gamepad that the controller should be created from
  43398. */
  43399. constructor(vrGamepad: any);
  43400. /**
  43401. * Fired when the trigger on this controller is modified
  43402. */
  43403. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43404. /**
  43405. * Fired when the menu button on this controller is modified
  43406. */
  43407. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43408. /**
  43409. * Fired when the grip button on this controller is modified
  43410. */
  43411. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43412. /**
  43413. * Fired when the thumbstick button on this controller is modified
  43414. */
  43415. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43416. /**
  43417. * Fired when the touchpad button on this controller is modified
  43418. */
  43419. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43420. /**
  43421. * Fired when the touchpad values on this controller are modified
  43422. */
  43423. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43424. private _updateTrackpad;
  43425. /**
  43426. * Called once per frame by the engine.
  43427. */
  43428. update(): void;
  43429. /**
  43430. * Called once for each button that changed state since the last frame
  43431. * @param buttonIdx Which button index changed
  43432. * @param state New state of the button
  43433. * @param changes Which properties on the state changed since last frame
  43434. */
  43435. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43436. /**
  43437. * Moves the buttons on the controller mesh based on their current state
  43438. * @param buttonName the name of the button to move
  43439. * @param buttonValue the value of the button which determines the buttons new position
  43440. */
  43441. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43442. /**
  43443. * Moves the axis on the controller mesh based on its current state
  43444. * @param axis the index of the axis
  43445. * @param axisValue the value of the axis which determines the meshes new position
  43446. * @hidden
  43447. */
  43448. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43449. /**
  43450. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43451. * @param scene scene in which to add meshes
  43452. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43453. */
  43454. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43455. /**
  43456. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43457. * can be transformed by button presses and axes values, based on this._mapping.
  43458. *
  43459. * @param scene scene in which the meshes exist
  43460. * @param meshes list of meshes that make up the controller model to process
  43461. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43462. */
  43463. private processModel;
  43464. private createMeshInfo;
  43465. /**
  43466. * Gets the ray of the controller in the direction the controller is pointing
  43467. * @param length the length the resulting ray should be
  43468. * @returns a ray in the direction the controller is pointing
  43469. */
  43470. getForwardRay(length?: number): Ray;
  43471. /**
  43472. * Disposes of the controller
  43473. */
  43474. dispose(): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43482. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43483. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43484. /**
  43485. * Oculus Touch Controller
  43486. */
  43487. export class OculusTouchController extends WebVRController {
  43488. /**
  43489. * Base Url for the controller model.
  43490. */
  43491. static MODEL_BASE_URL: string;
  43492. /**
  43493. * File name for the left controller model.
  43494. */
  43495. static MODEL_LEFT_FILENAME: string;
  43496. /**
  43497. * File name for the right controller model.
  43498. */
  43499. static MODEL_RIGHT_FILENAME: string;
  43500. /**
  43501. * Base Url for the Quest controller model.
  43502. */
  43503. static QUEST_MODEL_BASE_URL: string;
  43504. /**
  43505. * @hidden
  43506. * If the controllers are running on a device that needs the updated Quest controller models
  43507. */
  43508. static _IsQuest: boolean;
  43509. /**
  43510. * Fired when the secondary trigger on this controller is modified
  43511. */
  43512. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43513. /**
  43514. * Fired when the thumb rest on this controller is modified
  43515. */
  43516. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43517. /**
  43518. * Creates a new OculusTouchController from a gamepad
  43519. * @param vrGamepad the gamepad that the controller should be created from
  43520. */
  43521. constructor(vrGamepad: any);
  43522. /**
  43523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43524. * @param scene scene in which to add meshes
  43525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43526. */
  43527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43528. /**
  43529. * Fired when the A button on this controller is modified
  43530. */
  43531. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the B button on this controller is modified
  43534. */
  43535. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the X button on this controller is modified
  43538. */
  43539. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the Y button on this controller is modified
  43542. */
  43543. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Called once for each button that changed state since the last frame
  43546. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43547. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43548. * 2) secondary trigger (same)
  43549. * 3) A (right) X (left), touch, pressed = value
  43550. * 4) B / Y
  43551. * 5) thumb rest
  43552. * @param buttonIdx Which button index changed
  43553. * @param state New state of the button
  43554. * @param changes Which properties on the state changed since last frame
  43555. */
  43556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43557. }
  43558. }
  43559. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43560. import { Scene } from "babylonjs/scene";
  43561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43562. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43563. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43564. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43565. import { Observable } from "babylonjs/Misc/observable";
  43566. /**
  43567. * Vive Controller
  43568. */
  43569. export class ViveController extends WebVRController {
  43570. /**
  43571. * Base Url for the controller model.
  43572. */
  43573. static MODEL_BASE_URL: string;
  43574. /**
  43575. * File name for the controller model.
  43576. */
  43577. static MODEL_FILENAME: string;
  43578. /**
  43579. * Creates a new ViveController from a gamepad
  43580. * @param vrGamepad the gamepad that the controller should be created from
  43581. */
  43582. constructor(vrGamepad: any);
  43583. /**
  43584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43585. * @param scene scene in which to add meshes
  43586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43587. */
  43588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43589. /**
  43590. * Fired when the left button on this controller is modified
  43591. */
  43592. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43593. /**
  43594. * Fired when the right button on this controller is modified
  43595. */
  43596. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43597. /**
  43598. * Fired when the menu button on this controller is modified
  43599. */
  43600. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43601. /**
  43602. * Called once for each button that changed state since the last frame
  43603. * Vive mapping:
  43604. * 0: touchpad
  43605. * 1: trigger
  43606. * 2: left AND right buttons
  43607. * 3: menu button
  43608. * @param buttonIdx Which button index changed
  43609. * @param state New state of the button
  43610. * @param changes Which properties on the state changed since last frame
  43611. */
  43612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43613. }
  43614. }
  43615. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43616. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43617. /**
  43618. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43619. */
  43620. export class WebXRControllerModelLoader {
  43621. /**
  43622. * Creates the WebXRControllerModelLoader
  43623. * @param input xr input that creates the controllers
  43624. */
  43625. constructor(input: WebXRInput);
  43626. }
  43627. }
  43628. declare module "babylonjs/Cameras/XR/index" {
  43629. export * from "babylonjs/Cameras/XR/webXRCamera";
  43630. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43631. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43632. export * from "babylonjs/Cameras/XR/webXRInput";
  43633. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43634. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43635. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43636. export * from "babylonjs/Cameras/XR/webXRController";
  43637. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43638. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43639. }
  43640. declare module "babylonjs/Cameras/RigModes/index" {
  43641. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43642. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43643. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43644. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43645. }
  43646. declare module "babylonjs/Cameras/index" {
  43647. export * from "babylonjs/Cameras/Inputs/index";
  43648. export * from "babylonjs/Cameras/cameraInputsManager";
  43649. export * from "babylonjs/Cameras/camera";
  43650. export * from "babylonjs/Cameras/targetCamera";
  43651. export * from "babylonjs/Cameras/freeCamera";
  43652. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43653. export * from "babylonjs/Cameras/touchCamera";
  43654. export * from "babylonjs/Cameras/arcRotateCamera";
  43655. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43656. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43657. export * from "babylonjs/Cameras/flyCamera";
  43658. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43659. export * from "babylonjs/Cameras/followCamera";
  43660. export * from "babylonjs/Cameras/gamepadCamera";
  43661. export * from "babylonjs/Cameras/Stereoscopic/index";
  43662. export * from "babylonjs/Cameras/universalCamera";
  43663. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43664. export * from "babylonjs/Cameras/VR/index";
  43665. export * from "babylonjs/Cameras/XR/index";
  43666. export * from "babylonjs/Cameras/RigModes/index";
  43667. }
  43668. declare module "babylonjs/Collisions/index" {
  43669. export * from "babylonjs/Collisions/collider";
  43670. export * from "babylonjs/Collisions/collisionCoordinator";
  43671. export * from "babylonjs/Collisions/pickingInfo";
  43672. export * from "babylonjs/Collisions/intersectionInfo";
  43673. export * from "babylonjs/Collisions/meshCollisionData";
  43674. }
  43675. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43676. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43677. import { Vector3 } from "babylonjs/Maths/math.vector";
  43678. import { Ray } from "babylonjs/Culling/ray";
  43679. import { Plane } from "babylonjs/Maths/math.plane";
  43680. /**
  43681. * Contains an array of blocks representing the octree
  43682. */
  43683. export interface IOctreeContainer<T> {
  43684. /**
  43685. * Blocks within the octree
  43686. */
  43687. blocks: Array<OctreeBlock<T>>;
  43688. }
  43689. /**
  43690. * Class used to store a cell in an octree
  43691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43692. */
  43693. export class OctreeBlock<T> {
  43694. /**
  43695. * Gets the content of the current block
  43696. */
  43697. entries: T[];
  43698. /**
  43699. * Gets the list of block children
  43700. */
  43701. blocks: Array<OctreeBlock<T>>;
  43702. private _depth;
  43703. private _maxDepth;
  43704. private _capacity;
  43705. private _minPoint;
  43706. private _maxPoint;
  43707. private _boundingVectors;
  43708. private _creationFunc;
  43709. /**
  43710. * Creates a new block
  43711. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43712. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43713. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43714. * @param depth defines the current depth of this block in the octree
  43715. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43716. * @param creationFunc defines a callback to call when an element is added to the block
  43717. */
  43718. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43719. /**
  43720. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43721. */
  43722. readonly capacity: number;
  43723. /**
  43724. * Gets the minimum vector (in world space) of the block's bounding box
  43725. */
  43726. readonly minPoint: Vector3;
  43727. /**
  43728. * Gets the maximum vector (in world space) of the block's bounding box
  43729. */
  43730. readonly maxPoint: Vector3;
  43731. /**
  43732. * Add a new element to this block
  43733. * @param entry defines the element to add
  43734. */
  43735. addEntry(entry: T): void;
  43736. /**
  43737. * Remove an element from this block
  43738. * @param entry defines the element to remove
  43739. */
  43740. removeEntry(entry: T): void;
  43741. /**
  43742. * Add an array of elements to this block
  43743. * @param entries defines the array of elements to add
  43744. */
  43745. addEntries(entries: T[]): void;
  43746. /**
  43747. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43748. * @param frustumPlanes defines the frustum planes to test
  43749. * @param selection defines the array to store current content if selection is positive
  43750. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43751. */
  43752. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43753. /**
  43754. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43755. * @param sphereCenter defines the bounding sphere center
  43756. * @param sphereRadius defines the bounding sphere radius
  43757. * @param selection defines the array to store current content if selection is positive
  43758. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43759. */
  43760. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43761. /**
  43762. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43763. * @param ray defines the ray to test with
  43764. * @param selection defines the array to store current content if selection is positive
  43765. */
  43766. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43767. /**
  43768. * Subdivide the content into child blocks (this block will then be empty)
  43769. */
  43770. createInnerBlocks(): void;
  43771. /**
  43772. * @hidden
  43773. */
  43774. 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;
  43775. }
  43776. }
  43777. declare module "babylonjs/Culling/Octrees/octree" {
  43778. import { SmartArray } from "babylonjs/Misc/smartArray";
  43779. import { Vector3 } from "babylonjs/Maths/math.vector";
  43780. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43782. import { Ray } from "babylonjs/Culling/ray";
  43783. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43784. import { Plane } from "babylonjs/Maths/math.plane";
  43785. /**
  43786. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43788. */
  43789. export class Octree<T> {
  43790. /** 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.) */
  43791. maxDepth: number;
  43792. /**
  43793. * Blocks within the octree containing objects
  43794. */
  43795. blocks: Array<OctreeBlock<T>>;
  43796. /**
  43797. * Content stored in the octree
  43798. */
  43799. dynamicContent: T[];
  43800. private _maxBlockCapacity;
  43801. private _selectionContent;
  43802. private _creationFunc;
  43803. /**
  43804. * Creates a octree
  43805. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43806. * @param creationFunc function to be used to instatiate the octree
  43807. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43808. * @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.)
  43809. */
  43810. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43811. /** 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.) */
  43812. maxDepth?: number);
  43813. /**
  43814. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43815. * @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);
  43816. * @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);
  43817. * @param entries meshes to be added to the octree blocks
  43818. */
  43819. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43820. /**
  43821. * Adds a mesh to the octree
  43822. * @param entry Mesh to add to the octree
  43823. */
  43824. addMesh(entry: T): void;
  43825. /**
  43826. * Remove an element from the octree
  43827. * @param entry defines the element to remove
  43828. */
  43829. removeMesh(entry: T): void;
  43830. /**
  43831. * Selects an array of meshes within the frustum
  43832. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43833. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43834. * @returns array of meshes within the frustum
  43835. */
  43836. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43837. /**
  43838. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43839. * @param sphereCenter defines the bounding sphere center
  43840. * @param sphereRadius defines the bounding sphere radius
  43841. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43842. * @returns an array of objects that intersect the sphere
  43843. */
  43844. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43845. /**
  43846. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43847. * @param ray defines the ray to test with
  43848. * @returns array of intersected objects
  43849. */
  43850. intersectsRay(ray: Ray): SmartArray<T>;
  43851. /**
  43852. * Adds a mesh into the octree block if it intersects the block
  43853. */
  43854. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43855. /**
  43856. * Adds a submesh into the octree block if it intersects the block
  43857. */
  43858. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43859. }
  43860. }
  43861. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43862. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43863. import { Scene } from "babylonjs/scene";
  43864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43866. import { Ray } from "babylonjs/Culling/ray";
  43867. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43868. import { Collider } from "babylonjs/Collisions/collider";
  43869. module "babylonjs/scene" {
  43870. interface Scene {
  43871. /**
  43872. * @hidden
  43873. * Backing Filed
  43874. */
  43875. _selectionOctree: Octree<AbstractMesh>;
  43876. /**
  43877. * Gets the octree used to boost mesh selection (picking)
  43878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43879. */
  43880. selectionOctree: Octree<AbstractMesh>;
  43881. /**
  43882. * Creates or updates the octree used to boost selection (picking)
  43883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43884. * @param maxCapacity defines the maximum capacity per leaf
  43885. * @param maxDepth defines the maximum depth of the octree
  43886. * @returns an octree of AbstractMesh
  43887. */
  43888. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43889. }
  43890. }
  43891. module "babylonjs/Meshes/abstractMesh" {
  43892. interface AbstractMesh {
  43893. /**
  43894. * @hidden
  43895. * Backing Field
  43896. */
  43897. _submeshesOctree: Octree<SubMesh>;
  43898. /**
  43899. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43900. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43901. * @param maxCapacity defines the maximum size of each block (64 by default)
  43902. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43903. * @returns the new octree
  43904. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43905. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43906. */
  43907. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43908. }
  43909. }
  43910. /**
  43911. * Defines the octree scene component responsible to manage any octrees
  43912. * in a given scene.
  43913. */
  43914. export class OctreeSceneComponent {
  43915. /**
  43916. * The component name help to identify the component in the list of scene components.
  43917. */
  43918. readonly name: string;
  43919. /**
  43920. * The scene the component belongs to.
  43921. */
  43922. scene: Scene;
  43923. /**
  43924. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43925. */
  43926. readonly checksIsEnabled: boolean;
  43927. /**
  43928. * Creates a new instance of the component for the given scene
  43929. * @param scene Defines the scene to register the component in
  43930. */
  43931. constructor(scene: Scene);
  43932. /**
  43933. * Registers the component in a given scene
  43934. */
  43935. register(): void;
  43936. /**
  43937. * Return the list of active meshes
  43938. * @returns the list of active meshes
  43939. */
  43940. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43941. /**
  43942. * Return the list of active sub meshes
  43943. * @param mesh The mesh to get the candidates sub meshes from
  43944. * @returns the list of active sub meshes
  43945. */
  43946. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43947. private _tempRay;
  43948. /**
  43949. * Return the list of sub meshes intersecting with a given local ray
  43950. * @param mesh defines the mesh to find the submesh for
  43951. * @param localRay defines the ray in local space
  43952. * @returns the list of intersecting sub meshes
  43953. */
  43954. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43955. /**
  43956. * Return the list of sub meshes colliding with a collider
  43957. * @param mesh defines the mesh to find the submesh for
  43958. * @param collider defines the collider to evaluate the collision against
  43959. * @returns the list of colliding sub meshes
  43960. */
  43961. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43962. /**
  43963. * Rebuilds the elements related to this component in case of
  43964. * context lost for instance.
  43965. */
  43966. rebuild(): void;
  43967. /**
  43968. * Disposes the component and the associated ressources.
  43969. */
  43970. dispose(): void;
  43971. }
  43972. }
  43973. declare module "babylonjs/Culling/Octrees/index" {
  43974. export * from "babylonjs/Culling/Octrees/octree";
  43975. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43976. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43977. }
  43978. declare module "babylonjs/Culling/index" {
  43979. export * from "babylonjs/Culling/boundingBox";
  43980. export * from "babylonjs/Culling/boundingInfo";
  43981. export * from "babylonjs/Culling/boundingSphere";
  43982. export * from "babylonjs/Culling/Octrees/index";
  43983. export * from "babylonjs/Culling/ray";
  43984. }
  43985. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43986. import { IDisposable, Scene } from "babylonjs/scene";
  43987. import { Nullable } from "babylonjs/types";
  43988. import { Observable } from "babylonjs/Misc/observable";
  43989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43990. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43991. import { Camera } from "babylonjs/Cameras/camera";
  43992. /**
  43993. * Renders a layer on top of an existing scene
  43994. */
  43995. export class UtilityLayerRenderer implements IDisposable {
  43996. /** the original scene that will be rendered on top of */
  43997. originalScene: Scene;
  43998. private _pointerCaptures;
  43999. private _lastPointerEvents;
  44000. private static _DefaultUtilityLayer;
  44001. private static _DefaultKeepDepthUtilityLayer;
  44002. private _sharedGizmoLight;
  44003. private _renderCamera;
  44004. /**
  44005. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44006. * @returns the camera that is used when rendering the utility layer
  44007. */
  44008. getRenderCamera(): Nullable<Camera>;
  44009. /**
  44010. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44011. * @param cam the camera that should be used when rendering the utility layer
  44012. */
  44013. setRenderCamera(cam: Nullable<Camera>): void;
  44014. /**
  44015. * @hidden
  44016. * Light which used by gizmos to get light shading
  44017. */
  44018. _getSharedGizmoLight(): HemisphericLight;
  44019. /**
  44020. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44021. */
  44022. pickUtilitySceneFirst: boolean;
  44023. /**
  44024. * 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)
  44025. */
  44026. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44027. /**
  44028. * 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)
  44029. */
  44030. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44031. /**
  44032. * The scene that is rendered on top of the original scene
  44033. */
  44034. utilityLayerScene: Scene;
  44035. /**
  44036. * If the utility layer should automatically be rendered on top of existing scene
  44037. */
  44038. shouldRender: boolean;
  44039. /**
  44040. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44041. */
  44042. onlyCheckPointerDownEvents: boolean;
  44043. /**
  44044. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44045. */
  44046. processAllEvents: boolean;
  44047. /**
  44048. * Observable raised when the pointer move from the utility layer scene to the main scene
  44049. */
  44050. onPointerOutObservable: Observable<number>;
  44051. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44052. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44053. private _afterRenderObserver;
  44054. private _sceneDisposeObserver;
  44055. private _originalPointerObserver;
  44056. /**
  44057. * Instantiates a UtilityLayerRenderer
  44058. * @param originalScene the original scene that will be rendered on top of
  44059. * @param handleEvents boolean indicating if the utility layer should handle events
  44060. */
  44061. constructor(
  44062. /** the original scene that will be rendered on top of */
  44063. originalScene: Scene, handleEvents?: boolean);
  44064. private _notifyObservers;
  44065. /**
  44066. * Renders the utility layers scene on top of the original scene
  44067. */
  44068. render(): void;
  44069. /**
  44070. * Disposes of the renderer
  44071. */
  44072. dispose(): void;
  44073. private _updateCamera;
  44074. }
  44075. }
  44076. declare module "babylonjs/Gizmos/gizmo" {
  44077. import { Nullable } from "babylonjs/types";
  44078. import { IDisposable } from "babylonjs/scene";
  44079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44080. import { Mesh } from "babylonjs/Meshes/mesh";
  44081. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44082. /**
  44083. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44084. */
  44085. export class Gizmo implements IDisposable {
  44086. /** The utility layer the gizmo will be added to */
  44087. gizmoLayer: UtilityLayerRenderer;
  44088. /**
  44089. * The root mesh of the gizmo
  44090. */
  44091. _rootMesh: Mesh;
  44092. private _attachedMesh;
  44093. /**
  44094. * Ratio for the scale of the gizmo (Default: 1)
  44095. */
  44096. scaleRatio: number;
  44097. /**
  44098. * If a custom mesh has been set (Default: false)
  44099. */
  44100. protected _customMeshSet: boolean;
  44101. /**
  44102. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44103. * * When set, interactions will be enabled
  44104. */
  44105. attachedMesh: Nullable<AbstractMesh>;
  44106. /**
  44107. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44108. * @param mesh The mesh to replace the default mesh of the gizmo
  44109. */
  44110. setCustomMesh(mesh: Mesh): void;
  44111. /**
  44112. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44113. */
  44114. updateGizmoRotationToMatchAttachedMesh: boolean;
  44115. /**
  44116. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44117. */
  44118. updateGizmoPositionToMatchAttachedMesh: boolean;
  44119. /**
  44120. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44121. */
  44122. updateScale: boolean;
  44123. protected _interactionsEnabled: boolean;
  44124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44125. private _beforeRenderObserver;
  44126. private _tempVector;
  44127. /**
  44128. * Creates a gizmo
  44129. * @param gizmoLayer The utility layer the gizmo will be added to
  44130. */
  44131. constructor(
  44132. /** The utility layer the gizmo will be added to */
  44133. gizmoLayer?: UtilityLayerRenderer);
  44134. /**
  44135. * Updates the gizmo to match the attached mesh's position/rotation
  44136. */
  44137. protected _update(): void;
  44138. /**
  44139. * Disposes of the gizmo
  44140. */
  44141. dispose(): void;
  44142. }
  44143. }
  44144. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44145. import { Observable } from "babylonjs/Misc/observable";
  44146. import { Nullable } from "babylonjs/types";
  44147. import { Vector3 } from "babylonjs/Maths/math.vector";
  44148. import { Color3 } from "babylonjs/Maths/math.color";
  44149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44151. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44152. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44153. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44154. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44155. import { Scene } from "babylonjs/scene";
  44156. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44157. /**
  44158. * Single plane drag gizmo
  44159. */
  44160. export class PlaneDragGizmo extends Gizmo {
  44161. /**
  44162. * Drag behavior responsible for the gizmos dragging interactions
  44163. */
  44164. dragBehavior: PointerDragBehavior;
  44165. private _pointerObserver;
  44166. /**
  44167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44168. */
  44169. snapDistance: number;
  44170. /**
  44171. * Event that fires each time the gizmo snaps to a new location.
  44172. * * snapDistance is the the change in distance
  44173. */
  44174. onSnapObservable: Observable<{
  44175. snapDistance: number;
  44176. }>;
  44177. private _plane;
  44178. private _coloredMaterial;
  44179. private _hoverMaterial;
  44180. private _isEnabled;
  44181. private _parent;
  44182. /** @hidden */
  44183. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44184. /** @hidden */
  44185. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44186. /**
  44187. * Creates a PlaneDragGizmo
  44188. * @param gizmoLayer The utility layer the gizmo will be added to
  44189. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44190. * @param color The color of the gizmo
  44191. */
  44192. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44194. /**
  44195. * If the gizmo is enabled
  44196. */
  44197. isEnabled: boolean;
  44198. /**
  44199. * Disposes of the gizmo
  44200. */
  44201. dispose(): void;
  44202. }
  44203. }
  44204. declare module "babylonjs/Gizmos/positionGizmo" {
  44205. import { Observable } from "babylonjs/Misc/observable";
  44206. import { Nullable } from "babylonjs/types";
  44207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44208. import { Mesh } from "babylonjs/Meshes/mesh";
  44209. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44210. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44211. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44212. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44213. /**
  44214. * Gizmo that enables dragging a mesh along 3 axis
  44215. */
  44216. export class PositionGizmo extends Gizmo {
  44217. /**
  44218. * Internal gizmo used for interactions on the x axis
  44219. */
  44220. xGizmo: AxisDragGizmo;
  44221. /**
  44222. * Internal gizmo used for interactions on the y axis
  44223. */
  44224. yGizmo: AxisDragGizmo;
  44225. /**
  44226. * Internal gizmo used for interactions on the z axis
  44227. */
  44228. zGizmo: AxisDragGizmo;
  44229. /**
  44230. * Internal gizmo used for interactions on the yz plane
  44231. */
  44232. xPlaneGizmo: PlaneDragGizmo;
  44233. /**
  44234. * Internal gizmo used for interactions on the xz plane
  44235. */
  44236. yPlaneGizmo: PlaneDragGizmo;
  44237. /**
  44238. * Internal gizmo used for interactions on the xy plane
  44239. */
  44240. zPlaneGizmo: PlaneDragGizmo;
  44241. /**
  44242. * private variables
  44243. */
  44244. private _meshAttached;
  44245. private _updateGizmoRotationToMatchAttachedMesh;
  44246. private _snapDistance;
  44247. private _scaleRatio;
  44248. /** Fires an event when any of it's sub gizmos are dragged */
  44249. onDragStartObservable: Observable<unknown>;
  44250. /** Fires an event when any of it's sub gizmos are released from dragging */
  44251. onDragEndObservable: Observable<unknown>;
  44252. /**
  44253. * If set to true, planar drag is enabled
  44254. */
  44255. private _planarGizmoEnabled;
  44256. attachedMesh: Nullable<AbstractMesh>;
  44257. /**
  44258. * Creates a PositionGizmo
  44259. * @param gizmoLayer The utility layer the gizmo will be added to
  44260. */
  44261. constructor(gizmoLayer?: UtilityLayerRenderer);
  44262. /**
  44263. * If the planar drag gizmo is enabled
  44264. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44265. */
  44266. planarGizmoEnabled: boolean;
  44267. updateGizmoRotationToMatchAttachedMesh: boolean;
  44268. /**
  44269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44270. */
  44271. snapDistance: number;
  44272. /**
  44273. * Ratio for the scale of the gizmo (Default: 1)
  44274. */
  44275. scaleRatio: number;
  44276. /**
  44277. * Disposes of the gizmo
  44278. */
  44279. dispose(): void;
  44280. /**
  44281. * CustomMeshes are not supported by this gizmo
  44282. * @param mesh The mesh to replace the default mesh of the gizmo
  44283. */
  44284. setCustomMesh(mesh: Mesh): void;
  44285. }
  44286. }
  44287. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44288. import { Observable } from "babylonjs/Misc/observable";
  44289. import { Nullable } from "babylonjs/types";
  44290. import { Vector3 } from "babylonjs/Maths/math.vector";
  44291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44294. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44295. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44296. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44297. import { Scene } from "babylonjs/scene";
  44298. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44299. import { Color3 } from "babylonjs/Maths/math.color";
  44300. /**
  44301. * Single axis drag gizmo
  44302. */
  44303. export class AxisDragGizmo extends Gizmo {
  44304. /**
  44305. * Drag behavior responsible for the gizmos dragging interactions
  44306. */
  44307. dragBehavior: PointerDragBehavior;
  44308. private _pointerObserver;
  44309. /**
  44310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44311. */
  44312. snapDistance: number;
  44313. /**
  44314. * Event that fires each time the gizmo snaps to a new location.
  44315. * * snapDistance is the the change in distance
  44316. */
  44317. onSnapObservable: Observable<{
  44318. snapDistance: number;
  44319. }>;
  44320. private _isEnabled;
  44321. private _parent;
  44322. private _arrow;
  44323. private _coloredMaterial;
  44324. private _hoverMaterial;
  44325. /** @hidden */
  44326. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44327. /** @hidden */
  44328. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44329. /**
  44330. * Creates an AxisDragGizmo
  44331. * @param gizmoLayer The utility layer the gizmo will be added to
  44332. * @param dragAxis The axis which the gizmo will be able to drag on
  44333. * @param color The color of the gizmo
  44334. */
  44335. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44336. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44337. /**
  44338. * If the gizmo is enabled
  44339. */
  44340. isEnabled: boolean;
  44341. /**
  44342. * Disposes of the gizmo
  44343. */
  44344. dispose(): void;
  44345. }
  44346. }
  44347. declare module "babylonjs/Debug/axesViewer" {
  44348. import { Vector3 } from "babylonjs/Maths/math.vector";
  44349. import { Nullable } from "babylonjs/types";
  44350. import { Scene } from "babylonjs/scene";
  44351. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44352. /**
  44353. * The Axes viewer will show 3 axes in a specific point in space
  44354. */
  44355. export class AxesViewer {
  44356. private _xAxis;
  44357. private _yAxis;
  44358. private _zAxis;
  44359. private _scaleLinesFactor;
  44360. private _instanced;
  44361. /**
  44362. * Gets the hosting scene
  44363. */
  44364. scene: Scene;
  44365. /**
  44366. * Gets or sets a number used to scale line length
  44367. */
  44368. scaleLines: number;
  44369. /** Gets the node hierarchy used to render x-axis */
  44370. readonly xAxis: TransformNode;
  44371. /** Gets the node hierarchy used to render y-axis */
  44372. readonly yAxis: TransformNode;
  44373. /** Gets the node hierarchy used to render z-axis */
  44374. readonly zAxis: TransformNode;
  44375. /**
  44376. * Creates a new AxesViewer
  44377. * @param scene defines the hosting scene
  44378. * @param scaleLines defines a number used to scale line length (1 by default)
  44379. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44380. * @param xAxis defines the node hierarchy used to render the x-axis
  44381. * @param yAxis defines the node hierarchy used to render the y-axis
  44382. * @param zAxis defines the node hierarchy used to render the z-axis
  44383. */
  44384. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44385. /**
  44386. * Force the viewer to update
  44387. * @param position defines the position of the viewer
  44388. * @param xaxis defines the x axis of the viewer
  44389. * @param yaxis defines the y axis of the viewer
  44390. * @param zaxis defines the z axis of the viewer
  44391. */
  44392. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44393. /**
  44394. * Creates an instance of this axes viewer.
  44395. * @returns a new axes viewer with instanced meshes
  44396. */
  44397. createInstance(): AxesViewer;
  44398. /** Releases resources */
  44399. dispose(): void;
  44400. private static _SetRenderingGroupId;
  44401. }
  44402. }
  44403. declare module "babylonjs/Debug/boneAxesViewer" {
  44404. import { Nullable } from "babylonjs/types";
  44405. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44406. import { Vector3 } from "babylonjs/Maths/math.vector";
  44407. import { Mesh } from "babylonjs/Meshes/mesh";
  44408. import { Bone } from "babylonjs/Bones/bone";
  44409. import { Scene } from "babylonjs/scene";
  44410. /**
  44411. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44412. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44413. */
  44414. export class BoneAxesViewer extends AxesViewer {
  44415. /**
  44416. * Gets or sets the target mesh where to display the axes viewer
  44417. */
  44418. mesh: Nullable<Mesh>;
  44419. /**
  44420. * Gets or sets the target bone where to display the axes viewer
  44421. */
  44422. bone: Nullable<Bone>;
  44423. /** Gets current position */
  44424. pos: Vector3;
  44425. /** Gets direction of X axis */
  44426. xaxis: Vector3;
  44427. /** Gets direction of Y axis */
  44428. yaxis: Vector3;
  44429. /** Gets direction of Z axis */
  44430. zaxis: Vector3;
  44431. /**
  44432. * Creates a new BoneAxesViewer
  44433. * @param scene defines the hosting scene
  44434. * @param bone defines the target bone
  44435. * @param mesh defines the target mesh
  44436. * @param scaleLines defines a scaling factor for line length (1 by default)
  44437. */
  44438. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44439. /**
  44440. * Force the viewer to update
  44441. */
  44442. update(): void;
  44443. /** Releases resources */
  44444. dispose(): void;
  44445. }
  44446. }
  44447. declare module "babylonjs/Debug/debugLayer" {
  44448. import { Scene } from "babylonjs/scene";
  44449. /**
  44450. * Interface used to define scene explorer extensibility option
  44451. */
  44452. export interface IExplorerExtensibilityOption {
  44453. /**
  44454. * Define the option label
  44455. */
  44456. label: string;
  44457. /**
  44458. * Defines the action to execute on click
  44459. */
  44460. action: (entity: any) => void;
  44461. }
  44462. /**
  44463. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44464. */
  44465. export interface IExplorerExtensibilityGroup {
  44466. /**
  44467. * Defines a predicate to test if a given type mut be extended
  44468. */
  44469. predicate: (entity: any) => boolean;
  44470. /**
  44471. * Gets the list of options added to a type
  44472. */
  44473. entries: IExplorerExtensibilityOption[];
  44474. }
  44475. /**
  44476. * Interface used to define the options to use to create the Inspector
  44477. */
  44478. export interface IInspectorOptions {
  44479. /**
  44480. * Display in overlay mode (default: false)
  44481. */
  44482. overlay?: boolean;
  44483. /**
  44484. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44485. */
  44486. globalRoot?: HTMLElement;
  44487. /**
  44488. * Display the Scene explorer
  44489. */
  44490. showExplorer?: boolean;
  44491. /**
  44492. * Display the property inspector
  44493. */
  44494. showInspector?: boolean;
  44495. /**
  44496. * Display in embed mode (both panes on the right)
  44497. */
  44498. embedMode?: boolean;
  44499. /**
  44500. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44501. */
  44502. handleResize?: boolean;
  44503. /**
  44504. * Allow the panes to popup (default: true)
  44505. */
  44506. enablePopup?: boolean;
  44507. /**
  44508. * Allow the panes to be closed by users (default: true)
  44509. */
  44510. enableClose?: boolean;
  44511. /**
  44512. * Optional list of extensibility entries
  44513. */
  44514. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44515. /**
  44516. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44517. */
  44518. inspectorURL?: string;
  44519. }
  44520. module "babylonjs/scene" {
  44521. interface Scene {
  44522. /**
  44523. * @hidden
  44524. * Backing field
  44525. */
  44526. _debugLayer: DebugLayer;
  44527. /**
  44528. * Gets the debug layer (aka Inspector) associated with the scene
  44529. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44530. */
  44531. debugLayer: DebugLayer;
  44532. }
  44533. }
  44534. /**
  44535. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44536. * what is happening in your scene
  44537. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44538. */
  44539. export class DebugLayer {
  44540. /**
  44541. * Define the url to get the inspector script from.
  44542. * By default it uses the babylonjs CDN.
  44543. * @ignoreNaming
  44544. */
  44545. static InspectorURL: string;
  44546. private _scene;
  44547. private BJSINSPECTOR;
  44548. private _onPropertyChangedObservable?;
  44549. /**
  44550. * Observable triggered when a property is changed through the inspector.
  44551. */
  44552. readonly onPropertyChangedObservable: any;
  44553. /**
  44554. * Instantiates a new debug layer.
  44555. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44556. * what is happening in your scene
  44557. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44558. * @param scene Defines the scene to inspect
  44559. */
  44560. constructor(scene: Scene);
  44561. /** Creates the inspector window. */
  44562. private _createInspector;
  44563. /**
  44564. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44565. * @param entity defines the entity to select
  44566. * @param lineContainerTitle defines the specific block to highlight
  44567. */
  44568. select(entity: any, lineContainerTitle?: string): void;
  44569. /** Get the inspector from bundle or global */
  44570. private _getGlobalInspector;
  44571. /**
  44572. * Get if the inspector is visible or not.
  44573. * @returns true if visible otherwise, false
  44574. */
  44575. isVisible(): boolean;
  44576. /**
  44577. * Hide the inspector and close its window.
  44578. */
  44579. hide(): void;
  44580. /**
  44581. * Launch the debugLayer.
  44582. * @param config Define the configuration of the inspector
  44583. * @return a promise fulfilled when the debug layer is visible
  44584. */
  44585. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44586. }
  44587. }
  44588. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44589. import { Nullable } from "babylonjs/types";
  44590. import { Scene } from "babylonjs/scene";
  44591. import { Vector4 } from "babylonjs/Maths/math.vector";
  44592. import { Color4 } from "babylonjs/Maths/math.color";
  44593. import { Mesh } from "babylonjs/Meshes/mesh";
  44594. /**
  44595. * Class containing static functions to help procedurally build meshes
  44596. */
  44597. export class BoxBuilder {
  44598. /**
  44599. * Creates a box mesh
  44600. * * The parameter `size` sets the size (float) of each box side (default 1)
  44601. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44602. * * 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)
  44603. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44607. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44608. * @param name defines the name of the mesh
  44609. * @param options defines the options used to create the mesh
  44610. * @param scene defines the hosting scene
  44611. * @returns the box mesh
  44612. */
  44613. static CreateBox(name: string, options: {
  44614. size?: number;
  44615. width?: number;
  44616. height?: number;
  44617. depth?: number;
  44618. faceUV?: Vector4[];
  44619. faceColors?: Color4[];
  44620. sideOrientation?: number;
  44621. frontUVs?: Vector4;
  44622. backUVs?: Vector4;
  44623. wrap?: boolean;
  44624. topBaseAt?: number;
  44625. bottomBaseAt?: number;
  44626. updatable?: boolean;
  44627. }, scene?: Nullable<Scene>): Mesh;
  44628. }
  44629. }
  44630. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44631. import { Vector4 } from "babylonjs/Maths/math.vector";
  44632. import { Mesh } from "babylonjs/Meshes/mesh";
  44633. /**
  44634. * Class containing static functions to help procedurally build meshes
  44635. */
  44636. export class SphereBuilder {
  44637. /**
  44638. * Creates a sphere mesh
  44639. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44640. * * 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`)
  44641. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44642. * * 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
  44643. * * 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)
  44644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44647. * @param name defines the name of the mesh
  44648. * @param options defines the options used to create the mesh
  44649. * @param scene defines the hosting scene
  44650. * @returns the sphere mesh
  44651. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44652. */
  44653. static CreateSphere(name: string, options: {
  44654. segments?: number;
  44655. diameter?: number;
  44656. diameterX?: number;
  44657. diameterY?: number;
  44658. diameterZ?: number;
  44659. arc?: number;
  44660. slice?: number;
  44661. sideOrientation?: number;
  44662. frontUVs?: Vector4;
  44663. backUVs?: Vector4;
  44664. updatable?: boolean;
  44665. }, scene: any): Mesh;
  44666. }
  44667. }
  44668. declare module "babylonjs/Debug/physicsViewer" {
  44669. import { Nullable } from "babylonjs/types";
  44670. import { Scene } from "babylonjs/scene";
  44671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44672. import { Mesh } from "babylonjs/Meshes/mesh";
  44673. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44674. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44675. /**
  44676. * Used to show the physics impostor around the specific mesh
  44677. */
  44678. export class PhysicsViewer {
  44679. /** @hidden */
  44680. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44681. /** @hidden */
  44682. protected _meshes: Array<Nullable<AbstractMesh>>;
  44683. /** @hidden */
  44684. protected _scene: Nullable<Scene>;
  44685. /** @hidden */
  44686. protected _numMeshes: number;
  44687. /** @hidden */
  44688. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44689. private _renderFunction;
  44690. private _utilityLayer;
  44691. private _debugBoxMesh;
  44692. private _debugSphereMesh;
  44693. private _debugCylinderMesh;
  44694. private _debugMaterial;
  44695. private _debugMeshMeshes;
  44696. /**
  44697. * Creates a new PhysicsViewer
  44698. * @param scene defines the hosting scene
  44699. */
  44700. constructor(scene: Scene);
  44701. /** @hidden */
  44702. protected _updateDebugMeshes(): void;
  44703. /**
  44704. * Renders a specified physic impostor
  44705. * @param impostor defines the impostor to render
  44706. * @param targetMesh defines the mesh represented by the impostor
  44707. * @returns the new debug mesh used to render the impostor
  44708. */
  44709. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44710. /**
  44711. * Hides a specified physic impostor
  44712. * @param impostor defines the impostor to hide
  44713. */
  44714. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44715. private _getDebugMaterial;
  44716. private _getDebugBoxMesh;
  44717. private _getDebugSphereMesh;
  44718. private _getDebugCylinderMesh;
  44719. private _getDebugMeshMesh;
  44720. private _getDebugMesh;
  44721. /** Releases all resources */
  44722. dispose(): void;
  44723. }
  44724. }
  44725. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44726. import { Vector3 } from "babylonjs/Maths/math.vector";
  44727. import { Color4 } from "babylonjs/Maths/math.color";
  44728. import { Nullable } from "babylonjs/types";
  44729. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44730. import { Scene } from "babylonjs/scene";
  44731. /**
  44732. * Class containing static functions to help procedurally build meshes
  44733. */
  44734. export class LinesBuilder {
  44735. /**
  44736. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44737. * * 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
  44738. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44739. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44740. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44741. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44742. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44743. * * 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
  44744. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44747. * @param name defines the name of the new line system
  44748. * @param options defines the options used to create the line system
  44749. * @param scene defines the hosting scene
  44750. * @returns a new line system mesh
  44751. */
  44752. static CreateLineSystem(name: string, options: {
  44753. lines: Vector3[][];
  44754. updatable?: boolean;
  44755. instance?: Nullable<LinesMesh>;
  44756. colors?: Nullable<Color4[][]>;
  44757. useVertexAlpha?: boolean;
  44758. }, scene: Nullable<Scene>): LinesMesh;
  44759. /**
  44760. * Creates a line mesh
  44761. * 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
  44762. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44763. * * The parameter `points` is an array successive Vector3
  44764. * * 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
  44765. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44766. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44767. * * When updating an instance, remember that only point positions can change, not the number of points
  44768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44770. * @param name defines the name of the new line system
  44771. * @param options defines the options used to create the line system
  44772. * @param scene defines the hosting scene
  44773. * @returns a new line mesh
  44774. */
  44775. static CreateLines(name: string, options: {
  44776. points: Vector3[];
  44777. updatable?: boolean;
  44778. instance?: Nullable<LinesMesh>;
  44779. colors?: Color4[];
  44780. useVertexAlpha?: boolean;
  44781. }, scene?: Nullable<Scene>): LinesMesh;
  44782. /**
  44783. * Creates a dashed line mesh
  44784. * * 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
  44785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44786. * * The parameter `points` is an array successive Vector3
  44787. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44788. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44789. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44790. * * 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
  44791. * * When updating an instance, remember that only point positions can change, not the number of points
  44792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44793. * @param name defines the name of the mesh
  44794. * @param options defines the options used to create the mesh
  44795. * @param scene defines the hosting scene
  44796. * @returns the dashed line mesh
  44797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44798. */
  44799. static CreateDashedLines(name: string, options: {
  44800. points: Vector3[];
  44801. dashSize?: number;
  44802. gapSize?: number;
  44803. dashNb?: number;
  44804. updatable?: boolean;
  44805. instance?: LinesMesh;
  44806. }, scene?: Nullable<Scene>): LinesMesh;
  44807. }
  44808. }
  44809. declare module "babylonjs/Debug/rayHelper" {
  44810. import { Nullable } from "babylonjs/types";
  44811. import { Ray } from "babylonjs/Culling/ray";
  44812. import { Vector3 } from "babylonjs/Maths/math.vector";
  44813. import { Color3 } from "babylonjs/Maths/math.color";
  44814. import { Scene } from "babylonjs/scene";
  44815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44816. import "babylonjs/Meshes/Builders/linesBuilder";
  44817. /**
  44818. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44819. * in order to better appreciate the issue one might have.
  44820. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44821. */
  44822. export class RayHelper {
  44823. /**
  44824. * Defines the ray we are currently tryin to visualize.
  44825. */
  44826. ray: Nullable<Ray>;
  44827. private _renderPoints;
  44828. private _renderLine;
  44829. private _renderFunction;
  44830. private _scene;
  44831. private _updateToMeshFunction;
  44832. private _attachedToMesh;
  44833. private _meshSpaceDirection;
  44834. private _meshSpaceOrigin;
  44835. /**
  44836. * Helper function to create a colored helper in a scene in one line.
  44837. * @param ray Defines the ray we are currently tryin to visualize
  44838. * @param scene Defines the scene the ray is used in
  44839. * @param color Defines the color we want to see the ray in
  44840. * @returns The newly created ray helper.
  44841. */
  44842. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44843. /**
  44844. * Instantiate a new ray helper.
  44845. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44846. * in order to better appreciate the issue one might have.
  44847. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44848. * @param ray Defines the ray we are currently tryin to visualize
  44849. */
  44850. constructor(ray: Ray);
  44851. /**
  44852. * Shows the ray we are willing to debug.
  44853. * @param scene Defines the scene the ray needs to be rendered in
  44854. * @param color Defines the color the ray needs to be rendered in
  44855. */
  44856. show(scene: Scene, color?: Color3): void;
  44857. /**
  44858. * Hides the ray we are debugging.
  44859. */
  44860. hide(): void;
  44861. private _render;
  44862. /**
  44863. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44864. * @param mesh Defines the mesh we want the helper attached to
  44865. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44866. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44867. * @param length Defines the length of the ray
  44868. */
  44869. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44870. /**
  44871. * Detach the ray helper from the mesh it has previously been attached to.
  44872. */
  44873. detachFromMesh(): void;
  44874. private _updateToMesh;
  44875. /**
  44876. * Dispose the helper and release its associated resources.
  44877. */
  44878. dispose(): void;
  44879. }
  44880. }
  44881. declare module "babylonjs/Debug/skeletonViewer" {
  44882. import { Color3 } from "babylonjs/Maths/math.color";
  44883. import { Scene } from "babylonjs/scene";
  44884. import { Nullable } from "babylonjs/types";
  44885. import { Skeleton } from "babylonjs/Bones/skeleton";
  44886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44887. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44888. /**
  44889. * Class used to render a debug view of a given skeleton
  44890. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44891. */
  44892. export class SkeletonViewer {
  44893. /** defines the skeleton to render */
  44894. skeleton: Skeleton;
  44895. /** defines the mesh attached to the skeleton */
  44896. mesh: AbstractMesh;
  44897. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44898. autoUpdateBonesMatrices: boolean;
  44899. /** defines the rendering group id to use with the viewer */
  44900. renderingGroupId: number;
  44901. /** Gets or sets the color used to render the skeleton */
  44902. color: Color3;
  44903. private _scene;
  44904. private _debugLines;
  44905. private _debugMesh;
  44906. private _isEnabled;
  44907. private _renderFunction;
  44908. private _utilityLayer;
  44909. /**
  44910. * Returns the mesh used to render the bones
  44911. */
  44912. readonly debugMesh: Nullable<LinesMesh>;
  44913. /**
  44914. * Creates a new SkeletonViewer
  44915. * @param skeleton defines the skeleton to render
  44916. * @param mesh defines the mesh attached to the skeleton
  44917. * @param scene defines the hosting scene
  44918. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44919. * @param renderingGroupId defines the rendering group id to use with the viewer
  44920. */
  44921. constructor(
  44922. /** defines the skeleton to render */
  44923. skeleton: Skeleton,
  44924. /** defines the mesh attached to the skeleton */
  44925. mesh: AbstractMesh, scene: Scene,
  44926. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44927. autoUpdateBonesMatrices?: boolean,
  44928. /** defines the rendering group id to use with the viewer */
  44929. renderingGroupId?: number);
  44930. /** Gets or sets a boolean indicating if the viewer is enabled */
  44931. isEnabled: boolean;
  44932. private _getBonePosition;
  44933. private _getLinesForBonesWithLength;
  44934. private _getLinesForBonesNoLength;
  44935. /** Update the viewer to sync with current skeleton state */
  44936. update(): void;
  44937. /** Release associated resources */
  44938. dispose(): void;
  44939. }
  44940. }
  44941. declare module "babylonjs/Debug/index" {
  44942. export * from "babylonjs/Debug/axesViewer";
  44943. export * from "babylonjs/Debug/boneAxesViewer";
  44944. export * from "babylonjs/Debug/debugLayer";
  44945. export * from "babylonjs/Debug/physicsViewer";
  44946. export * from "babylonjs/Debug/rayHelper";
  44947. export * from "babylonjs/Debug/skeletonViewer";
  44948. }
  44949. declare module "babylonjs/Engines/nullEngine" {
  44950. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44951. import { Scene } from "babylonjs/scene";
  44952. import { Engine } from "babylonjs/Engines/engine";
  44953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44954. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44956. import { Effect } from "babylonjs/Materials/effect";
  44957. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44959. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44960. /**
  44961. * Options to create the null engine
  44962. */
  44963. export class NullEngineOptions {
  44964. /**
  44965. * Render width (Default: 512)
  44966. */
  44967. renderWidth: number;
  44968. /**
  44969. * Render height (Default: 256)
  44970. */
  44971. renderHeight: number;
  44972. /**
  44973. * Texture size (Default: 512)
  44974. */
  44975. textureSize: number;
  44976. /**
  44977. * If delta time between frames should be constant
  44978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44979. */
  44980. deterministicLockstep: boolean;
  44981. /**
  44982. * Maximum about of steps between frames (Default: 4)
  44983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44984. */
  44985. lockstepMaxSteps: number;
  44986. }
  44987. /**
  44988. * The null engine class provides support for headless version of babylon.js.
  44989. * This can be used in server side scenario or for testing purposes
  44990. */
  44991. export class NullEngine extends Engine {
  44992. private _options;
  44993. /**
  44994. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44995. */
  44996. isDeterministicLockStep(): boolean;
  44997. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44998. getLockstepMaxSteps(): number;
  44999. /**
  45000. * Sets hardware scaling, used to save performance if needed
  45001. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45002. */
  45003. getHardwareScalingLevel(): number;
  45004. constructor(options?: NullEngineOptions);
  45005. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45006. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45007. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45008. getRenderWidth(useScreen?: boolean): number;
  45009. getRenderHeight(useScreen?: boolean): number;
  45010. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45011. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45012. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45013. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45014. bindSamplers(effect: Effect): void;
  45015. enableEffect(effect: Effect): void;
  45016. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45017. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45018. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45019. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45020. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45021. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45022. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45023. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45024. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45025. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45026. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45027. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45028. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45029. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45030. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45031. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45032. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45033. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45034. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45035. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45036. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45037. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45038. bindBuffers(vertexBuffers: {
  45039. [key: string]: VertexBuffer;
  45040. }, indexBuffer: DataBuffer, effect: Effect): void;
  45041. wipeCaches(bruteForce?: boolean): void;
  45042. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45043. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45044. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45045. /** @hidden */
  45046. _createTexture(): WebGLTexture;
  45047. /** @hidden */
  45048. _releaseTexture(texture: InternalTexture): void;
  45049. 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;
  45050. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45051. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45052. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45053. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45054. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45055. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45056. areAllEffectsReady(): boolean;
  45057. /**
  45058. * @hidden
  45059. * Get the current error code of the webGL context
  45060. * @returns the error code
  45061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45062. */
  45063. getError(): number;
  45064. /** @hidden */
  45065. _getUnpackAlignement(): number;
  45066. /** @hidden */
  45067. _unpackFlipY(value: boolean): void;
  45068. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45069. /**
  45070. * Updates a dynamic vertex buffer.
  45071. * @param vertexBuffer the vertex buffer to update
  45072. * @param data the data used to update the vertex buffer
  45073. * @param byteOffset the byte offset of the data (optional)
  45074. * @param byteLength the byte length of the data (optional)
  45075. */
  45076. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45077. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45078. /** @hidden */
  45079. _bindTexture(channel: number, texture: InternalTexture): void;
  45080. /** @hidden */
  45081. _releaseBuffer(buffer: DataBuffer): boolean;
  45082. releaseEffects(): void;
  45083. displayLoadingUI(): void;
  45084. hideLoadingUI(): void;
  45085. /** @hidden */
  45086. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45087. /** @hidden */
  45088. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45089. /** @hidden */
  45090. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45091. /** @hidden */
  45092. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45093. }
  45094. }
  45095. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45096. import { Nullable, int } from "babylonjs/types";
  45097. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45098. /** @hidden */
  45099. export class _OcclusionDataStorage {
  45100. /** @hidden */
  45101. occlusionInternalRetryCounter: number;
  45102. /** @hidden */
  45103. isOcclusionQueryInProgress: boolean;
  45104. /** @hidden */
  45105. isOccluded: boolean;
  45106. /** @hidden */
  45107. occlusionRetryCount: number;
  45108. /** @hidden */
  45109. occlusionType: number;
  45110. /** @hidden */
  45111. occlusionQueryAlgorithmType: number;
  45112. }
  45113. module "babylonjs/Engines/engine" {
  45114. interface Engine {
  45115. /**
  45116. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45117. * @return the new query
  45118. */
  45119. createQuery(): WebGLQuery;
  45120. /**
  45121. * Delete and release a webGL query
  45122. * @param query defines the query to delete
  45123. * @return the current engine
  45124. */
  45125. deleteQuery(query: WebGLQuery): Engine;
  45126. /**
  45127. * Check if a given query has resolved and got its value
  45128. * @param query defines the query to check
  45129. * @returns true if the query got its value
  45130. */
  45131. isQueryResultAvailable(query: WebGLQuery): boolean;
  45132. /**
  45133. * Gets the value of a given query
  45134. * @param query defines the query to check
  45135. * @returns the value of the query
  45136. */
  45137. getQueryResult(query: WebGLQuery): number;
  45138. /**
  45139. * Initiates an occlusion query
  45140. * @param algorithmType defines the algorithm to use
  45141. * @param query defines the query to use
  45142. * @returns the current engine
  45143. * @see http://doc.babylonjs.com/features/occlusionquery
  45144. */
  45145. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45146. /**
  45147. * Ends an occlusion query
  45148. * @see http://doc.babylonjs.com/features/occlusionquery
  45149. * @param algorithmType defines the algorithm to use
  45150. * @returns the current engine
  45151. */
  45152. endOcclusionQuery(algorithmType: number): Engine;
  45153. /**
  45154. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45155. * Please note that only one query can be issued at a time
  45156. * @returns a time token used to track the time span
  45157. */
  45158. startTimeQuery(): Nullable<_TimeToken>;
  45159. /**
  45160. * Ends a time query
  45161. * @param token defines the token used to measure the time span
  45162. * @returns the time spent (in ns)
  45163. */
  45164. endTimeQuery(token: _TimeToken): int;
  45165. /** @hidden */
  45166. _currentNonTimestampToken: Nullable<_TimeToken>;
  45167. /** @hidden */
  45168. _createTimeQuery(): WebGLQuery;
  45169. /** @hidden */
  45170. _deleteTimeQuery(query: WebGLQuery): void;
  45171. /** @hidden */
  45172. _getGlAlgorithmType(algorithmType: number): number;
  45173. /** @hidden */
  45174. _getTimeQueryResult(query: WebGLQuery): any;
  45175. /** @hidden */
  45176. _getTimeQueryAvailability(query: WebGLQuery): any;
  45177. }
  45178. }
  45179. module "babylonjs/Meshes/abstractMesh" {
  45180. interface AbstractMesh {
  45181. /**
  45182. * Backing filed
  45183. * @hidden
  45184. */
  45185. __occlusionDataStorage: _OcclusionDataStorage;
  45186. /**
  45187. * Access property
  45188. * @hidden
  45189. */
  45190. _occlusionDataStorage: _OcclusionDataStorage;
  45191. /**
  45192. * 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.
  45193. * The default value is -1 which means don't break the query and wait till the result
  45194. * @see http://doc.babylonjs.com/features/occlusionquery
  45195. */
  45196. occlusionRetryCount: number;
  45197. /**
  45198. * 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:
  45199. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45200. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45201. * * 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.
  45202. * @see http://doc.babylonjs.com/features/occlusionquery
  45203. */
  45204. occlusionType: number;
  45205. /**
  45206. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45207. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45208. * * 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.
  45209. * @see http://doc.babylonjs.com/features/occlusionquery
  45210. */
  45211. occlusionQueryAlgorithmType: number;
  45212. /**
  45213. * 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
  45214. * @see http://doc.babylonjs.com/features/occlusionquery
  45215. */
  45216. isOccluded: boolean;
  45217. /**
  45218. * Flag to check the progress status of the query
  45219. * @see http://doc.babylonjs.com/features/occlusionquery
  45220. */
  45221. isOcclusionQueryInProgress: boolean;
  45222. }
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45226. import { Nullable } from "babylonjs/types";
  45227. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45228. /** @hidden */
  45229. export var _forceTransformFeedbackToBundle: boolean;
  45230. module "babylonjs/Engines/engine" {
  45231. interface Engine {
  45232. /**
  45233. * Creates a webGL transform feedback object
  45234. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45235. * @returns the webGL transform feedback object
  45236. */
  45237. createTransformFeedback(): WebGLTransformFeedback;
  45238. /**
  45239. * Delete a webGL transform feedback object
  45240. * @param value defines the webGL transform feedback object to delete
  45241. */
  45242. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45243. /**
  45244. * Bind a webGL transform feedback object to the webgl context
  45245. * @param value defines the webGL transform feedback object to bind
  45246. */
  45247. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45248. /**
  45249. * Begins a transform feedback operation
  45250. * @param usePoints defines if points or triangles must be used
  45251. */
  45252. beginTransformFeedback(usePoints: boolean): void;
  45253. /**
  45254. * Ends a transform feedback operation
  45255. */
  45256. endTransformFeedback(): void;
  45257. /**
  45258. * Specify the varyings to use with transform feedback
  45259. * @param program defines the associated webGL program
  45260. * @param value defines the list of strings representing the varying names
  45261. */
  45262. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45263. /**
  45264. * Bind a webGL buffer for a transform feedback operation
  45265. * @param value defines the webGL buffer to bind
  45266. */
  45267. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45268. }
  45269. }
  45270. }
  45271. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45272. import { Scene } from "babylonjs/scene";
  45273. import { Engine } from "babylonjs/Engines/engine";
  45274. import { Texture } from "babylonjs/Materials/Textures/texture";
  45275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45276. import "babylonjs/Engines/Extensions/engine.multiRender";
  45277. /**
  45278. * Creation options of the multi render target texture.
  45279. */
  45280. export interface IMultiRenderTargetOptions {
  45281. /**
  45282. * Define if the texture needs to create mip maps after render.
  45283. */
  45284. generateMipMaps?: boolean;
  45285. /**
  45286. * Define the types of all the draw buffers we want to create
  45287. */
  45288. types?: number[];
  45289. /**
  45290. * Define the sampling modes of all the draw buffers we want to create
  45291. */
  45292. samplingModes?: number[];
  45293. /**
  45294. * Define if a depth buffer is required
  45295. */
  45296. generateDepthBuffer?: boolean;
  45297. /**
  45298. * Define if a stencil buffer is required
  45299. */
  45300. generateStencilBuffer?: boolean;
  45301. /**
  45302. * Define if a depth texture is required instead of a depth buffer
  45303. */
  45304. generateDepthTexture?: boolean;
  45305. /**
  45306. * Define the number of desired draw buffers
  45307. */
  45308. textureCount?: number;
  45309. /**
  45310. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45311. */
  45312. doNotChangeAspectRatio?: boolean;
  45313. /**
  45314. * Define the default type of the buffers we are creating
  45315. */
  45316. defaultType?: number;
  45317. }
  45318. /**
  45319. * A multi render target, like a render target provides the ability to render to a texture.
  45320. * Unlike the render target, it can render to several draw buffers in one draw.
  45321. * This is specially interesting in deferred rendering or for any effects requiring more than
  45322. * just one color from a single pass.
  45323. */
  45324. export class MultiRenderTarget extends RenderTargetTexture {
  45325. private _internalTextures;
  45326. private _textures;
  45327. private _multiRenderTargetOptions;
  45328. /**
  45329. * Get if draw buffers are currently supported by the used hardware and browser.
  45330. */
  45331. readonly isSupported: boolean;
  45332. /**
  45333. * Get the list of textures generated by the multi render target.
  45334. */
  45335. readonly textures: Texture[];
  45336. /**
  45337. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45338. */
  45339. readonly depthTexture: Texture;
  45340. /**
  45341. * Set the wrapping mode on U of all the textures we are rendering to.
  45342. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45343. */
  45344. wrapU: number;
  45345. /**
  45346. * Set the wrapping mode on V of all the textures we are rendering to.
  45347. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45348. */
  45349. wrapV: number;
  45350. /**
  45351. * Instantiate a new multi render target texture.
  45352. * A multi render target, like a render target provides the ability to render to a texture.
  45353. * Unlike the render target, it can render to several draw buffers in one draw.
  45354. * This is specially interesting in deferred rendering or for any effects requiring more than
  45355. * just one color from a single pass.
  45356. * @param name Define the name of the texture
  45357. * @param size Define the size of the buffers to render to
  45358. * @param count Define the number of target we are rendering into
  45359. * @param scene Define the scene the texture belongs to
  45360. * @param options Define the options used to create the multi render target
  45361. */
  45362. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45363. /** @hidden */
  45364. _rebuild(): void;
  45365. private _createInternalTextures;
  45366. private _createTextures;
  45367. /**
  45368. * Define the number of samples used if MSAA is enabled.
  45369. */
  45370. samples: number;
  45371. /**
  45372. * Resize all the textures in the multi render target.
  45373. * Be carrefull as it will recreate all the data in the new texture.
  45374. * @param size Define the new size
  45375. */
  45376. resize(size: any): void;
  45377. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45378. /**
  45379. * Dispose the render targets and their associated resources
  45380. */
  45381. dispose(): void;
  45382. /**
  45383. * Release all the underlying texture used as draw buffers.
  45384. */
  45385. releaseInternalTextures(): void;
  45386. }
  45387. }
  45388. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45389. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45390. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45391. import { Nullable } from "babylonjs/types";
  45392. module "babylonjs/Engines/engine" {
  45393. interface Engine {
  45394. /**
  45395. * Unbind a list of render target textures from the webGL context
  45396. * This is used only when drawBuffer extension or webGL2 are active
  45397. * @param textures defines the render target textures to unbind
  45398. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45399. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45400. */
  45401. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45402. /**
  45403. * Create a multi render target texture
  45404. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45405. * @param size defines the size of the texture
  45406. * @param options defines the creation options
  45407. * @returns the cube texture as an InternalTexture
  45408. */
  45409. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45410. /**
  45411. * Update the sample count for a given multiple render target texture
  45412. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45413. * @param textures defines the textures to update
  45414. * @param samples defines the sample count to set
  45415. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45416. */
  45417. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45418. }
  45419. }
  45420. }
  45421. declare module "babylonjs/Engines/Extensions/index" {
  45422. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45423. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45424. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45425. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45426. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45427. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45428. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45429. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45430. }
  45431. declare module "babylonjs/Engines/index" {
  45432. export * from "babylonjs/Engines/constants";
  45433. export * from "babylonjs/Engines/engine";
  45434. export * from "babylonjs/Engines/engineStore";
  45435. export * from "babylonjs/Engines/nullEngine";
  45436. export * from "babylonjs/Engines/Extensions/index";
  45437. export * from "babylonjs/Engines/IPipelineContext";
  45438. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45439. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45440. }
  45441. declare module "babylonjs/Events/clipboardEvents" {
  45442. /**
  45443. * Gather the list of clipboard event types as constants.
  45444. */
  45445. export class ClipboardEventTypes {
  45446. /**
  45447. * The clipboard event is fired when a copy command is active (pressed).
  45448. */
  45449. static readonly COPY: number;
  45450. /**
  45451. * The clipboard event is fired when a cut command is active (pressed).
  45452. */
  45453. static readonly CUT: number;
  45454. /**
  45455. * The clipboard event is fired when a paste command is active (pressed).
  45456. */
  45457. static readonly PASTE: number;
  45458. }
  45459. /**
  45460. * This class is used to store clipboard related info for the onClipboardObservable event.
  45461. */
  45462. export class ClipboardInfo {
  45463. /**
  45464. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45465. */
  45466. type: number;
  45467. /**
  45468. * Defines the related dom event
  45469. */
  45470. event: ClipboardEvent;
  45471. /**
  45472. *Creates an instance of ClipboardInfo.
  45473. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45474. * @param event Defines the related dom event
  45475. */
  45476. constructor(
  45477. /**
  45478. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45479. */
  45480. type: number,
  45481. /**
  45482. * Defines the related dom event
  45483. */
  45484. event: ClipboardEvent);
  45485. /**
  45486. * Get the clipboard event's type from the keycode.
  45487. * @param keyCode Defines the keyCode for the current keyboard event.
  45488. * @return {number}
  45489. */
  45490. static GetTypeFromCharacter(keyCode: number): number;
  45491. }
  45492. }
  45493. declare module "babylonjs/Events/index" {
  45494. export * from "babylonjs/Events/keyboardEvents";
  45495. export * from "babylonjs/Events/pointerEvents";
  45496. export * from "babylonjs/Events/clipboardEvents";
  45497. }
  45498. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45499. import { Scene } from "babylonjs/scene";
  45500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45501. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45502. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45503. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45504. /**
  45505. * Google Daydream controller
  45506. */
  45507. export class DaydreamController extends WebVRController {
  45508. /**
  45509. * Base Url for the controller model.
  45510. */
  45511. static MODEL_BASE_URL: string;
  45512. /**
  45513. * File name for the controller model.
  45514. */
  45515. static MODEL_FILENAME: string;
  45516. /**
  45517. * Gamepad Id prefix used to identify Daydream Controller.
  45518. */
  45519. static readonly GAMEPAD_ID_PREFIX: string;
  45520. /**
  45521. * Creates a new DaydreamController from a gamepad
  45522. * @param vrGamepad the gamepad that the controller should be created from
  45523. */
  45524. constructor(vrGamepad: any);
  45525. /**
  45526. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45527. * @param scene scene in which to add meshes
  45528. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45529. */
  45530. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45531. /**
  45532. * Called once for each button that changed state since the last frame
  45533. * @param buttonIdx Which button index changed
  45534. * @param state New state of the button
  45535. * @param changes Which properties on the state changed since last frame
  45536. */
  45537. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45538. }
  45539. }
  45540. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45541. import { Scene } from "babylonjs/scene";
  45542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45543. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45544. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45545. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45546. /**
  45547. * Gear VR Controller
  45548. */
  45549. export class GearVRController extends WebVRController {
  45550. /**
  45551. * Base Url for the controller model.
  45552. */
  45553. static MODEL_BASE_URL: string;
  45554. /**
  45555. * File name for the controller model.
  45556. */
  45557. static MODEL_FILENAME: string;
  45558. /**
  45559. * Gamepad Id prefix used to identify this controller.
  45560. */
  45561. static readonly GAMEPAD_ID_PREFIX: string;
  45562. private readonly _buttonIndexToObservableNameMap;
  45563. /**
  45564. * Creates a new GearVRController from a gamepad
  45565. * @param vrGamepad the gamepad that the controller should be created from
  45566. */
  45567. constructor(vrGamepad: any);
  45568. /**
  45569. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45570. * @param scene scene in which to add meshes
  45571. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45572. */
  45573. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45574. /**
  45575. * Called once for each button that changed state since the last frame
  45576. * @param buttonIdx Which button index changed
  45577. * @param state New state of the button
  45578. * @param changes Which properties on the state changed since last frame
  45579. */
  45580. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45581. }
  45582. }
  45583. declare module "babylonjs/Gamepads/Controllers/index" {
  45584. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45585. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45586. export * from "babylonjs/Gamepads/Controllers/genericController";
  45587. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45588. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45589. export * from "babylonjs/Gamepads/Controllers/viveController";
  45590. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45591. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45592. }
  45593. declare module "babylonjs/Gamepads/index" {
  45594. export * from "babylonjs/Gamepads/Controllers/index";
  45595. export * from "babylonjs/Gamepads/gamepad";
  45596. export * from "babylonjs/Gamepads/gamepadManager";
  45597. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45598. export * from "babylonjs/Gamepads/xboxGamepad";
  45599. export * from "babylonjs/Gamepads/dualShockGamepad";
  45600. }
  45601. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45602. import { Scene } from "babylonjs/scene";
  45603. import { Vector4 } from "babylonjs/Maths/math.vector";
  45604. import { Color4 } from "babylonjs/Maths/math.color";
  45605. import { Mesh } from "babylonjs/Meshes/mesh";
  45606. import { Nullable } from "babylonjs/types";
  45607. /**
  45608. * Class containing static functions to help procedurally build meshes
  45609. */
  45610. export class PolyhedronBuilder {
  45611. /**
  45612. * Creates a polyhedron mesh
  45613. * * 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
  45614. * * The parameter `size` (positive float, default 1) sets the polygon size
  45615. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45616. * * 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`
  45617. * * 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
  45618. * * 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)`)
  45619. * * 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
  45620. * * 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
  45621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45624. * @param name defines the name of the mesh
  45625. * @param options defines the options used to create the mesh
  45626. * @param scene defines the hosting scene
  45627. * @returns the polyhedron mesh
  45628. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45629. */
  45630. static CreatePolyhedron(name: string, options: {
  45631. type?: number;
  45632. size?: number;
  45633. sizeX?: number;
  45634. sizeY?: number;
  45635. sizeZ?: number;
  45636. custom?: any;
  45637. faceUV?: Vector4[];
  45638. faceColors?: Color4[];
  45639. flat?: boolean;
  45640. updatable?: boolean;
  45641. sideOrientation?: number;
  45642. frontUVs?: Vector4;
  45643. backUVs?: Vector4;
  45644. }, scene?: Nullable<Scene>): Mesh;
  45645. }
  45646. }
  45647. declare module "babylonjs/Gizmos/scaleGizmo" {
  45648. import { Observable } from "babylonjs/Misc/observable";
  45649. import { Nullable } from "babylonjs/types";
  45650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45651. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45652. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45653. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45654. /**
  45655. * Gizmo that enables scaling a mesh along 3 axis
  45656. */
  45657. export class ScaleGizmo extends Gizmo {
  45658. /**
  45659. * Internal gizmo used for interactions on the x axis
  45660. */
  45661. xGizmo: AxisScaleGizmo;
  45662. /**
  45663. * Internal gizmo used for interactions on the y axis
  45664. */
  45665. yGizmo: AxisScaleGizmo;
  45666. /**
  45667. * Internal gizmo used for interactions on the z axis
  45668. */
  45669. zGizmo: AxisScaleGizmo;
  45670. /**
  45671. * Internal gizmo used to scale all axis equally
  45672. */
  45673. uniformScaleGizmo: AxisScaleGizmo;
  45674. private _meshAttached;
  45675. private _updateGizmoRotationToMatchAttachedMesh;
  45676. private _snapDistance;
  45677. private _scaleRatio;
  45678. private _uniformScalingMesh;
  45679. private _octahedron;
  45680. /** Fires an event when any of it's sub gizmos are dragged */
  45681. onDragStartObservable: Observable<unknown>;
  45682. /** Fires an event when any of it's sub gizmos are released from dragging */
  45683. onDragEndObservable: Observable<unknown>;
  45684. attachedMesh: Nullable<AbstractMesh>;
  45685. /**
  45686. * Creates a ScaleGizmo
  45687. * @param gizmoLayer The utility layer the gizmo will be added to
  45688. */
  45689. constructor(gizmoLayer?: UtilityLayerRenderer);
  45690. updateGizmoRotationToMatchAttachedMesh: boolean;
  45691. /**
  45692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45693. */
  45694. snapDistance: number;
  45695. /**
  45696. * Ratio for the scale of the gizmo (Default: 1)
  45697. */
  45698. scaleRatio: number;
  45699. /**
  45700. * Disposes of the gizmo
  45701. */
  45702. dispose(): void;
  45703. }
  45704. }
  45705. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45706. import { Observable } from "babylonjs/Misc/observable";
  45707. import { Nullable } from "babylonjs/types";
  45708. import { Vector3 } from "babylonjs/Maths/math.vector";
  45709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45710. import { Mesh } from "babylonjs/Meshes/mesh";
  45711. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45713. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45714. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45715. import { Color3 } from "babylonjs/Maths/math.color";
  45716. /**
  45717. * Single axis scale gizmo
  45718. */
  45719. export class AxisScaleGizmo extends Gizmo {
  45720. /**
  45721. * Drag behavior responsible for the gizmos dragging interactions
  45722. */
  45723. dragBehavior: PointerDragBehavior;
  45724. private _pointerObserver;
  45725. /**
  45726. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45727. */
  45728. snapDistance: number;
  45729. /**
  45730. * Event that fires each time the gizmo snaps to a new location.
  45731. * * snapDistance is the the change in distance
  45732. */
  45733. onSnapObservable: Observable<{
  45734. snapDistance: number;
  45735. }>;
  45736. /**
  45737. * If the scaling operation should be done on all axis (default: false)
  45738. */
  45739. uniformScaling: boolean;
  45740. private _isEnabled;
  45741. private _parent;
  45742. private _arrow;
  45743. private _coloredMaterial;
  45744. private _hoverMaterial;
  45745. /**
  45746. * Creates an AxisScaleGizmo
  45747. * @param gizmoLayer The utility layer the gizmo will be added to
  45748. * @param dragAxis The axis which the gizmo will be able to scale on
  45749. * @param color The color of the gizmo
  45750. */
  45751. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45752. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45753. /**
  45754. * If the gizmo is enabled
  45755. */
  45756. isEnabled: boolean;
  45757. /**
  45758. * Disposes of the gizmo
  45759. */
  45760. dispose(): void;
  45761. /**
  45762. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45763. * @param mesh The mesh to replace the default mesh of the gizmo
  45764. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45765. */
  45766. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45767. }
  45768. }
  45769. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45770. import { Observable } from "babylonjs/Misc/observable";
  45771. import { Nullable } from "babylonjs/types";
  45772. import { Vector3 } from "babylonjs/Maths/math.vector";
  45773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45774. import { Mesh } from "babylonjs/Meshes/mesh";
  45775. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45776. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45777. import { Color3 } from "babylonjs/Maths/math.color";
  45778. import "babylonjs/Meshes/Builders/boxBuilder";
  45779. /**
  45780. * Bounding box gizmo
  45781. */
  45782. export class BoundingBoxGizmo extends Gizmo {
  45783. private _lineBoundingBox;
  45784. private _rotateSpheresParent;
  45785. private _scaleBoxesParent;
  45786. private _boundingDimensions;
  45787. private _renderObserver;
  45788. private _pointerObserver;
  45789. private _scaleDragSpeed;
  45790. private _tmpQuaternion;
  45791. private _tmpVector;
  45792. private _tmpRotationMatrix;
  45793. /**
  45794. * 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)
  45795. */
  45796. ignoreChildren: boolean;
  45797. /**
  45798. * 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)
  45799. */
  45800. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45801. /**
  45802. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45803. */
  45804. rotationSphereSize: number;
  45805. /**
  45806. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45807. */
  45808. scaleBoxSize: number;
  45809. /**
  45810. * 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)
  45811. */
  45812. fixedDragMeshScreenSize: boolean;
  45813. /**
  45814. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45815. */
  45816. fixedDragMeshScreenSizeDistanceFactor: number;
  45817. /**
  45818. * Fired when a rotation sphere or scale box is dragged
  45819. */
  45820. onDragStartObservable: Observable<{}>;
  45821. /**
  45822. * Fired when a scale box is dragged
  45823. */
  45824. onScaleBoxDragObservable: Observable<{}>;
  45825. /**
  45826. * Fired when a scale box drag is ended
  45827. */
  45828. onScaleBoxDragEndObservable: Observable<{}>;
  45829. /**
  45830. * Fired when a rotation sphere is dragged
  45831. */
  45832. onRotationSphereDragObservable: Observable<{}>;
  45833. /**
  45834. * Fired when a rotation sphere drag is ended
  45835. */
  45836. onRotationSphereDragEndObservable: Observable<{}>;
  45837. /**
  45838. * 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)
  45839. */
  45840. scalePivot: Nullable<Vector3>;
  45841. /**
  45842. * Mesh used as a pivot to rotate the attached mesh
  45843. */
  45844. private _anchorMesh;
  45845. private _existingMeshScale;
  45846. private _dragMesh;
  45847. private pointerDragBehavior;
  45848. private coloredMaterial;
  45849. private hoverColoredMaterial;
  45850. /**
  45851. * Sets the color of the bounding box gizmo
  45852. * @param color the color to set
  45853. */
  45854. setColor(color: Color3): void;
  45855. /**
  45856. * Creates an BoundingBoxGizmo
  45857. * @param gizmoLayer The utility layer the gizmo will be added to
  45858. * @param color The color of the gizmo
  45859. */
  45860. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45862. private _selectNode;
  45863. /**
  45864. * Updates the bounding box information for the Gizmo
  45865. */
  45866. updateBoundingBox(): void;
  45867. private _updateRotationSpheres;
  45868. private _updateScaleBoxes;
  45869. /**
  45870. * Enables rotation on the specified axis and disables rotation on the others
  45871. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45872. */
  45873. setEnabledRotationAxis(axis: string): void;
  45874. /**
  45875. * Enables/disables scaling
  45876. * @param enable if scaling should be enabled
  45877. */
  45878. setEnabledScaling(enable: boolean): void;
  45879. private _updateDummy;
  45880. /**
  45881. * Enables a pointer drag behavior on the bounding box of the gizmo
  45882. */
  45883. enableDragBehavior(): void;
  45884. /**
  45885. * Disposes of the gizmo
  45886. */
  45887. dispose(): void;
  45888. /**
  45889. * 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)
  45890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45891. * @returns the bounding box mesh with the passed in mesh as a child
  45892. */
  45893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45894. /**
  45895. * CustomMeshes are not supported by this gizmo
  45896. * @param mesh The mesh to replace the default mesh of the gizmo
  45897. */
  45898. setCustomMesh(mesh: Mesh): void;
  45899. }
  45900. }
  45901. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45902. import { Observable } from "babylonjs/Misc/observable";
  45903. import { Nullable } from "babylonjs/types";
  45904. import { Vector3 } from "babylonjs/Maths/math.vector";
  45905. import { Color3 } from "babylonjs/Maths/math.color";
  45906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45907. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45908. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45910. import "babylonjs/Meshes/Builders/linesBuilder";
  45911. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45912. /**
  45913. * Single plane rotation gizmo
  45914. */
  45915. export class PlaneRotationGizmo extends Gizmo {
  45916. /**
  45917. * Drag behavior responsible for the gizmos dragging interactions
  45918. */
  45919. dragBehavior: PointerDragBehavior;
  45920. private _pointerObserver;
  45921. /**
  45922. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45923. */
  45924. snapDistance: number;
  45925. /**
  45926. * Event that fires each time the gizmo snaps to a new location.
  45927. * * snapDistance is the the change in distance
  45928. */
  45929. onSnapObservable: Observable<{
  45930. snapDistance: number;
  45931. }>;
  45932. private _isEnabled;
  45933. private _parent;
  45934. /**
  45935. * Creates a PlaneRotationGizmo
  45936. * @param gizmoLayer The utility layer the gizmo will be added to
  45937. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45938. * @param color The color of the gizmo
  45939. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45940. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45941. */
  45942. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45943. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45944. /**
  45945. * If the gizmo is enabled
  45946. */
  45947. isEnabled: boolean;
  45948. /**
  45949. * Disposes of the gizmo
  45950. */
  45951. dispose(): void;
  45952. }
  45953. }
  45954. declare module "babylonjs/Gizmos/rotationGizmo" {
  45955. import { Observable } from "babylonjs/Misc/observable";
  45956. import { Nullable } from "babylonjs/types";
  45957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45958. import { Mesh } from "babylonjs/Meshes/mesh";
  45959. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45960. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45961. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45962. /**
  45963. * Gizmo that enables rotating a mesh along 3 axis
  45964. */
  45965. export class RotationGizmo extends Gizmo {
  45966. /**
  45967. * Internal gizmo used for interactions on the x axis
  45968. */
  45969. xGizmo: PlaneRotationGizmo;
  45970. /**
  45971. * Internal gizmo used for interactions on the y axis
  45972. */
  45973. yGizmo: PlaneRotationGizmo;
  45974. /**
  45975. * Internal gizmo used for interactions on the z axis
  45976. */
  45977. zGizmo: PlaneRotationGizmo;
  45978. /** Fires an event when any of it's sub gizmos are dragged */
  45979. onDragStartObservable: Observable<unknown>;
  45980. /** Fires an event when any of it's sub gizmos are released from dragging */
  45981. onDragEndObservable: Observable<unknown>;
  45982. private _meshAttached;
  45983. attachedMesh: Nullable<AbstractMesh>;
  45984. /**
  45985. * Creates a RotationGizmo
  45986. * @param gizmoLayer The utility layer the gizmo will be added to
  45987. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45988. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45989. */
  45990. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45991. updateGizmoRotationToMatchAttachedMesh: boolean;
  45992. /**
  45993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45994. */
  45995. snapDistance: number;
  45996. /**
  45997. * Ratio for the scale of the gizmo (Default: 1)
  45998. */
  45999. scaleRatio: number;
  46000. /**
  46001. * Disposes of the gizmo
  46002. */
  46003. dispose(): void;
  46004. /**
  46005. * CustomMeshes are not supported by this gizmo
  46006. * @param mesh The mesh to replace the default mesh of the gizmo
  46007. */
  46008. setCustomMesh(mesh: Mesh): void;
  46009. }
  46010. }
  46011. declare module "babylonjs/Gizmos/gizmoManager" {
  46012. import { Observable } from "babylonjs/Misc/observable";
  46013. import { Nullable } from "babylonjs/types";
  46014. import { Scene, IDisposable } from "babylonjs/scene";
  46015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46016. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46017. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46018. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46019. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46020. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46021. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46022. /**
  46023. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46024. */
  46025. export class GizmoManager implements IDisposable {
  46026. private scene;
  46027. /**
  46028. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46029. */
  46030. gizmos: {
  46031. positionGizmo: Nullable<PositionGizmo>;
  46032. rotationGizmo: Nullable<RotationGizmo>;
  46033. scaleGizmo: Nullable<ScaleGizmo>;
  46034. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46035. };
  46036. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46037. clearGizmoOnEmptyPointerEvent: boolean;
  46038. /** Fires an event when the manager is attached to a mesh */
  46039. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46040. private _gizmosEnabled;
  46041. private _pointerObserver;
  46042. private _attachedMesh;
  46043. private _boundingBoxColor;
  46044. private _defaultUtilityLayer;
  46045. private _defaultKeepDepthUtilityLayer;
  46046. /**
  46047. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46048. */
  46049. boundingBoxDragBehavior: SixDofDragBehavior;
  46050. /**
  46051. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46052. */
  46053. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46054. /**
  46055. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46056. */
  46057. usePointerToAttachGizmos: boolean;
  46058. /**
  46059. * Utility layer that the bounding box gizmo belongs to
  46060. */
  46061. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46062. /**
  46063. * Utility layer that all gizmos besides bounding box belong to
  46064. */
  46065. readonly utilityLayer: UtilityLayerRenderer;
  46066. /**
  46067. * Instatiates a gizmo manager
  46068. * @param scene the scene to overlay the gizmos on top of
  46069. */
  46070. constructor(scene: Scene);
  46071. /**
  46072. * Attaches a set of gizmos to the specified mesh
  46073. * @param mesh The mesh the gizmo's should be attached to
  46074. */
  46075. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46076. /**
  46077. * If the position gizmo is enabled
  46078. */
  46079. positionGizmoEnabled: boolean;
  46080. /**
  46081. * If the rotation gizmo is enabled
  46082. */
  46083. rotationGizmoEnabled: boolean;
  46084. /**
  46085. * If the scale gizmo is enabled
  46086. */
  46087. scaleGizmoEnabled: boolean;
  46088. /**
  46089. * If the boundingBox gizmo is enabled
  46090. */
  46091. boundingBoxGizmoEnabled: boolean;
  46092. /**
  46093. * Disposes of the gizmo manager
  46094. */
  46095. dispose(): void;
  46096. }
  46097. }
  46098. declare module "babylonjs/Lights/directionalLight" {
  46099. import { Camera } from "babylonjs/Cameras/camera";
  46100. import { Scene } from "babylonjs/scene";
  46101. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46103. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46104. import { Effect } from "babylonjs/Materials/effect";
  46105. /**
  46106. * A directional light is defined by a direction (what a surprise!).
  46107. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46108. * 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.
  46109. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46110. */
  46111. export class DirectionalLight extends ShadowLight {
  46112. private _shadowFrustumSize;
  46113. /**
  46114. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46115. */
  46116. /**
  46117. * Specifies a fix frustum size for the shadow generation.
  46118. */
  46119. shadowFrustumSize: number;
  46120. private _shadowOrthoScale;
  46121. /**
  46122. * Gets the shadow projection scale against the optimal computed one.
  46123. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46124. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46125. */
  46126. /**
  46127. * Sets the shadow projection scale against the optimal computed one.
  46128. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46129. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46130. */
  46131. shadowOrthoScale: number;
  46132. /**
  46133. * Automatically compute the projection matrix to best fit (including all the casters)
  46134. * on each frame.
  46135. */
  46136. autoUpdateExtends: boolean;
  46137. private _orthoLeft;
  46138. private _orthoRight;
  46139. private _orthoTop;
  46140. private _orthoBottom;
  46141. /**
  46142. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46143. * The directional light is emitted from everywhere in the given direction.
  46144. * It can cast shadows.
  46145. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46146. * @param name The friendly name of the light
  46147. * @param direction The direction of the light
  46148. * @param scene The scene the light belongs to
  46149. */
  46150. constructor(name: string, direction: Vector3, scene: Scene);
  46151. /**
  46152. * Returns the string "DirectionalLight".
  46153. * @return The class name
  46154. */
  46155. getClassName(): string;
  46156. /**
  46157. * Returns the integer 1.
  46158. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46159. */
  46160. getTypeID(): number;
  46161. /**
  46162. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46163. * Returns the DirectionalLight Shadow projection matrix.
  46164. */
  46165. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46166. /**
  46167. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46168. * Returns the DirectionalLight Shadow projection matrix.
  46169. */
  46170. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46171. /**
  46172. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46173. * Returns the DirectionalLight Shadow projection matrix.
  46174. */
  46175. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46176. protected _buildUniformLayout(): void;
  46177. /**
  46178. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46179. * @param effect The effect to update
  46180. * @param lightIndex The index of the light in the effect to update
  46181. * @returns The directional light
  46182. */
  46183. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46184. /**
  46185. * Gets the minZ used for shadow according to both the scene and the light.
  46186. *
  46187. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46188. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46189. * @param activeCamera The camera we are returning the min for
  46190. * @returns the depth min z
  46191. */
  46192. getDepthMinZ(activeCamera: Camera): number;
  46193. /**
  46194. * Gets the maxZ used for shadow according to both the scene and the light.
  46195. *
  46196. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46197. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46198. * @param activeCamera The camera we are returning the max for
  46199. * @returns the depth max z
  46200. */
  46201. getDepthMaxZ(activeCamera: Camera): number;
  46202. /**
  46203. * Prepares the list of defines specific to the light type.
  46204. * @param defines the list of defines
  46205. * @param lightIndex defines the index of the light for the effect
  46206. */
  46207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46208. }
  46209. }
  46210. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46211. import { Mesh } from "babylonjs/Meshes/mesh";
  46212. /**
  46213. * Class containing static functions to help procedurally build meshes
  46214. */
  46215. export class HemisphereBuilder {
  46216. /**
  46217. * Creates a hemisphere mesh
  46218. * @param name defines the name of the mesh
  46219. * @param options defines the options used to create the mesh
  46220. * @param scene defines the hosting scene
  46221. * @returns the hemisphere mesh
  46222. */
  46223. static CreateHemisphere(name: string, options: {
  46224. segments?: number;
  46225. diameter?: number;
  46226. sideOrientation?: number;
  46227. }, scene: any): Mesh;
  46228. }
  46229. }
  46230. declare module "babylonjs/Lights/spotLight" {
  46231. import { Nullable } from "babylonjs/types";
  46232. import { Scene } from "babylonjs/scene";
  46233. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46235. import { Effect } from "babylonjs/Materials/effect";
  46236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46237. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46238. /**
  46239. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46240. * These values define a cone of light starting from the position, emitting toward the direction.
  46241. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46242. * and the exponent defines the speed of the decay of the light with distance (reach).
  46243. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46244. */
  46245. export class SpotLight extends ShadowLight {
  46246. private _angle;
  46247. private _innerAngle;
  46248. private _cosHalfAngle;
  46249. private _lightAngleScale;
  46250. private _lightAngleOffset;
  46251. /**
  46252. * Gets the cone angle of the spot light in Radians.
  46253. */
  46254. /**
  46255. * Sets the cone angle of the spot light in Radians.
  46256. */
  46257. angle: number;
  46258. /**
  46259. * Only used in gltf falloff mode, this defines the angle where
  46260. * the directional falloff will start before cutting at angle which could be seen
  46261. * as outer angle.
  46262. */
  46263. /**
  46264. * Only used in gltf falloff mode, this defines the angle where
  46265. * the directional falloff will start before cutting at angle which could be seen
  46266. * as outer angle.
  46267. */
  46268. innerAngle: number;
  46269. private _shadowAngleScale;
  46270. /**
  46271. * Allows scaling the angle of the light for shadow generation only.
  46272. */
  46273. /**
  46274. * Allows scaling the angle of the light for shadow generation only.
  46275. */
  46276. shadowAngleScale: number;
  46277. /**
  46278. * The light decay speed with the distance from the emission spot.
  46279. */
  46280. exponent: number;
  46281. private _projectionTextureMatrix;
  46282. /**
  46283. * Allows reading the projecton texture
  46284. */
  46285. readonly projectionTextureMatrix: Matrix;
  46286. protected _projectionTextureLightNear: number;
  46287. /**
  46288. * Gets the near clip of the Spotlight for texture projection.
  46289. */
  46290. /**
  46291. * Sets the near clip of the Spotlight for texture projection.
  46292. */
  46293. projectionTextureLightNear: number;
  46294. protected _projectionTextureLightFar: number;
  46295. /**
  46296. * Gets the far clip of the Spotlight for texture projection.
  46297. */
  46298. /**
  46299. * Sets the far clip of the Spotlight for texture projection.
  46300. */
  46301. projectionTextureLightFar: number;
  46302. protected _projectionTextureUpDirection: Vector3;
  46303. /**
  46304. * Gets the Up vector of the Spotlight for texture projection.
  46305. */
  46306. /**
  46307. * Sets the Up vector of the Spotlight for texture projection.
  46308. */
  46309. projectionTextureUpDirection: Vector3;
  46310. private _projectionTexture;
  46311. /**
  46312. * Gets the projection texture of the light.
  46313. */
  46314. /**
  46315. * Sets the projection texture of the light.
  46316. */
  46317. projectionTexture: Nullable<BaseTexture>;
  46318. private _projectionTextureViewLightDirty;
  46319. private _projectionTextureProjectionLightDirty;
  46320. private _projectionTextureDirty;
  46321. private _projectionTextureViewTargetVector;
  46322. private _projectionTextureViewLightMatrix;
  46323. private _projectionTextureProjectionLightMatrix;
  46324. private _projectionTextureScalingMatrix;
  46325. /**
  46326. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46327. * It can cast shadows.
  46328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46329. * @param name The light friendly name
  46330. * @param position The position of the spot light in the scene
  46331. * @param direction The direction of the light in the scene
  46332. * @param angle The cone angle of the light in Radians
  46333. * @param exponent The light decay speed with the distance from the emission spot
  46334. * @param scene The scene the lights belongs to
  46335. */
  46336. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46337. /**
  46338. * Returns the string "SpotLight".
  46339. * @returns the class name
  46340. */
  46341. getClassName(): string;
  46342. /**
  46343. * Returns the integer 2.
  46344. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46345. */
  46346. getTypeID(): number;
  46347. /**
  46348. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46349. */
  46350. protected _setDirection(value: Vector3): void;
  46351. /**
  46352. * Overrides the position setter to recompute the projection texture view light Matrix.
  46353. */
  46354. protected _setPosition(value: Vector3): void;
  46355. /**
  46356. * 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.
  46357. * Returns the SpotLight.
  46358. */
  46359. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46360. protected _computeProjectionTextureViewLightMatrix(): void;
  46361. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46362. /**
  46363. * Main function for light texture projection matrix computing.
  46364. */
  46365. protected _computeProjectionTextureMatrix(): void;
  46366. protected _buildUniformLayout(): void;
  46367. private _computeAngleValues;
  46368. /**
  46369. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46370. * @param effect The effect to update
  46371. * @param lightIndex The index of the light in the effect to update
  46372. * @returns The spot light
  46373. */
  46374. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46375. /**
  46376. * Disposes the light and the associated resources.
  46377. */
  46378. dispose(): void;
  46379. /**
  46380. * Prepares the list of defines specific to the light type.
  46381. * @param defines the list of defines
  46382. * @param lightIndex defines the index of the light for the effect
  46383. */
  46384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46385. }
  46386. }
  46387. declare module "babylonjs/Gizmos/lightGizmo" {
  46388. import { Nullable } from "babylonjs/types";
  46389. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46390. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46391. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46392. import { Light } from "babylonjs/Lights/light";
  46393. /**
  46394. * Gizmo that enables viewing a light
  46395. */
  46396. export class LightGizmo extends Gizmo {
  46397. private _lightMesh;
  46398. private _material;
  46399. private cachedPosition;
  46400. private cachedForward;
  46401. /**
  46402. * Creates a LightGizmo
  46403. * @param gizmoLayer The utility layer the gizmo will be added to
  46404. */
  46405. constructor(gizmoLayer?: UtilityLayerRenderer);
  46406. private _light;
  46407. /**
  46408. * The light that the gizmo is attached to
  46409. */
  46410. light: Nullable<Light>;
  46411. /**
  46412. * Gets the material used to render the light gizmo
  46413. */
  46414. readonly material: StandardMaterial;
  46415. /**
  46416. * @hidden
  46417. * Updates the gizmo to match the attached mesh's position/rotation
  46418. */
  46419. protected _update(): void;
  46420. private static _Scale;
  46421. /**
  46422. * Creates the lines for a light mesh
  46423. */
  46424. private static _createLightLines;
  46425. /**
  46426. * Disposes of the light gizmo
  46427. */
  46428. dispose(): void;
  46429. private static _CreateHemisphericLightMesh;
  46430. private static _CreatePointLightMesh;
  46431. private static _CreateSpotLightMesh;
  46432. private static _CreateDirectionalLightMesh;
  46433. }
  46434. }
  46435. declare module "babylonjs/Gizmos/index" {
  46436. export * from "babylonjs/Gizmos/axisDragGizmo";
  46437. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46438. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46439. export * from "babylonjs/Gizmos/gizmo";
  46440. export * from "babylonjs/Gizmos/gizmoManager";
  46441. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46442. export * from "babylonjs/Gizmos/positionGizmo";
  46443. export * from "babylonjs/Gizmos/rotationGizmo";
  46444. export * from "babylonjs/Gizmos/scaleGizmo";
  46445. export * from "babylonjs/Gizmos/lightGizmo";
  46446. export * from "babylonjs/Gizmos/planeDragGizmo";
  46447. }
  46448. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46449. /** @hidden */
  46450. export var backgroundFragmentDeclaration: {
  46451. name: string;
  46452. shader: string;
  46453. };
  46454. }
  46455. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46456. /** @hidden */
  46457. export var backgroundUboDeclaration: {
  46458. name: string;
  46459. shader: string;
  46460. };
  46461. }
  46462. declare module "babylonjs/Shaders/background.fragment" {
  46463. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46464. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46465. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46466. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46467. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46468. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46469. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46470. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46471. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46472. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46474. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46476. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46477. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46478. /** @hidden */
  46479. export var backgroundPixelShader: {
  46480. name: string;
  46481. shader: string;
  46482. };
  46483. }
  46484. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46485. /** @hidden */
  46486. export var backgroundVertexDeclaration: {
  46487. name: string;
  46488. shader: string;
  46489. };
  46490. }
  46491. declare module "babylonjs/Shaders/background.vertex" {
  46492. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46493. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46495. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46496. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46497. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46498. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46499. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46500. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46501. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46502. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46504. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46505. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46506. /** @hidden */
  46507. export var backgroundVertexShader: {
  46508. name: string;
  46509. shader: string;
  46510. };
  46511. }
  46512. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46513. import { Nullable, int, float } from "babylonjs/types";
  46514. import { Scene } from "babylonjs/scene";
  46515. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46518. import { Mesh } from "babylonjs/Meshes/mesh";
  46519. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46520. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46521. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46523. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46524. import { Color3 } from "babylonjs/Maths/math.color";
  46525. import "babylonjs/Shaders/background.fragment";
  46526. import "babylonjs/Shaders/background.vertex";
  46527. /**
  46528. * Background material used to create an efficient environement around your scene.
  46529. */
  46530. export class BackgroundMaterial extends PushMaterial {
  46531. /**
  46532. * Standard reflectance value at parallel view angle.
  46533. */
  46534. static StandardReflectance0: number;
  46535. /**
  46536. * Standard reflectance value at grazing angle.
  46537. */
  46538. static StandardReflectance90: number;
  46539. protected _primaryColor: Color3;
  46540. /**
  46541. * Key light Color (multiply against the environement texture)
  46542. */
  46543. primaryColor: Color3;
  46544. protected __perceptualColor: Nullable<Color3>;
  46545. /**
  46546. * Experimental Internal Use Only.
  46547. *
  46548. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46549. * This acts as a helper to set the primary color to a more "human friendly" value.
  46550. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46551. * output color as close as possible from the chosen value.
  46552. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46553. * part of lighting setup.)
  46554. */
  46555. _perceptualColor: Nullable<Color3>;
  46556. protected _primaryColorShadowLevel: float;
  46557. /**
  46558. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46559. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46560. */
  46561. primaryColorShadowLevel: float;
  46562. protected _primaryColorHighlightLevel: float;
  46563. /**
  46564. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46565. * The primary color is used at the level chosen to define what the white area would look.
  46566. */
  46567. primaryColorHighlightLevel: float;
  46568. protected _reflectionTexture: Nullable<BaseTexture>;
  46569. /**
  46570. * Reflection Texture used in the material.
  46571. * Should be author in a specific way for the best result (refer to the documentation).
  46572. */
  46573. reflectionTexture: Nullable<BaseTexture>;
  46574. protected _reflectionBlur: float;
  46575. /**
  46576. * Reflection Texture level of blur.
  46577. *
  46578. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46579. * texture twice.
  46580. */
  46581. reflectionBlur: float;
  46582. protected _diffuseTexture: Nullable<BaseTexture>;
  46583. /**
  46584. * Diffuse Texture used in the material.
  46585. * Should be author in a specific way for the best result (refer to the documentation).
  46586. */
  46587. diffuseTexture: Nullable<BaseTexture>;
  46588. protected _shadowLights: Nullable<IShadowLight[]>;
  46589. /**
  46590. * Specify the list of lights casting shadow on the material.
  46591. * All scene shadow lights will be included if null.
  46592. */
  46593. shadowLights: Nullable<IShadowLight[]>;
  46594. protected _shadowLevel: float;
  46595. /**
  46596. * Helps adjusting the shadow to a softer level if required.
  46597. * 0 means black shadows and 1 means no shadows.
  46598. */
  46599. shadowLevel: float;
  46600. protected _sceneCenter: Vector3;
  46601. /**
  46602. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46603. * It is usually zero but might be interesting to modify according to your setup.
  46604. */
  46605. sceneCenter: Vector3;
  46606. protected _opacityFresnel: boolean;
  46607. /**
  46608. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46609. * This helps ensuring a nice transition when the camera goes under the ground.
  46610. */
  46611. opacityFresnel: boolean;
  46612. protected _reflectionFresnel: boolean;
  46613. /**
  46614. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46615. * This helps adding a mirror texture on the ground.
  46616. */
  46617. reflectionFresnel: boolean;
  46618. protected _reflectionFalloffDistance: number;
  46619. /**
  46620. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46621. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46622. */
  46623. reflectionFalloffDistance: number;
  46624. protected _reflectionAmount: number;
  46625. /**
  46626. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46627. */
  46628. reflectionAmount: number;
  46629. protected _reflectionReflectance0: number;
  46630. /**
  46631. * This specifies the weight of the reflection at grazing angle.
  46632. */
  46633. reflectionReflectance0: number;
  46634. protected _reflectionReflectance90: number;
  46635. /**
  46636. * This specifies the weight of the reflection at a perpendicular point of view.
  46637. */
  46638. reflectionReflectance90: number;
  46639. /**
  46640. * Sets the reflection reflectance fresnel values according to the default standard
  46641. * empirically know to work well :-)
  46642. */
  46643. reflectionStandardFresnelWeight: number;
  46644. protected _useRGBColor: boolean;
  46645. /**
  46646. * Helps to directly use the maps channels instead of their level.
  46647. */
  46648. useRGBColor: boolean;
  46649. protected _enableNoise: boolean;
  46650. /**
  46651. * This helps reducing the banding effect that could occur on the background.
  46652. */
  46653. enableNoise: boolean;
  46654. /**
  46655. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46656. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46657. * Recommended to be keep at 1.0 except for special cases.
  46658. */
  46659. fovMultiplier: number;
  46660. private _fovMultiplier;
  46661. /**
  46662. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46663. */
  46664. useEquirectangularFOV: boolean;
  46665. private _maxSimultaneousLights;
  46666. /**
  46667. * Number of Simultaneous lights allowed on the material.
  46668. */
  46669. maxSimultaneousLights: int;
  46670. /**
  46671. * Default configuration related to image processing available in the Background Material.
  46672. */
  46673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46674. /**
  46675. * Keep track of the image processing observer to allow dispose and replace.
  46676. */
  46677. private _imageProcessingObserver;
  46678. /**
  46679. * Attaches a new image processing configuration to the PBR Material.
  46680. * @param configuration (if null the scene configuration will be use)
  46681. */
  46682. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46683. /**
  46684. * Gets the image processing configuration used either in this material.
  46685. */
  46686. /**
  46687. * Sets the Default image processing configuration used either in the this material.
  46688. *
  46689. * If sets to null, the scene one is in use.
  46690. */
  46691. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46692. /**
  46693. * Gets wether the color curves effect is enabled.
  46694. */
  46695. /**
  46696. * Sets wether the color curves effect is enabled.
  46697. */
  46698. cameraColorCurvesEnabled: boolean;
  46699. /**
  46700. * Gets wether the color grading effect is enabled.
  46701. */
  46702. /**
  46703. * Gets wether the color grading effect is enabled.
  46704. */
  46705. cameraColorGradingEnabled: boolean;
  46706. /**
  46707. * Gets wether tonemapping is enabled or not.
  46708. */
  46709. /**
  46710. * Sets wether tonemapping is enabled or not
  46711. */
  46712. cameraToneMappingEnabled: boolean;
  46713. /**
  46714. * The camera exposure used on this material.
  46715. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46716. * This corresponds to a photographic exposure.
  46717. */
  46718. /**
  46719. * The camera exposure used on this material.
  46720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46721. * This corresponds to a photographic exposure.
  46722. */
  46723. cameraExposure: float;
  46724. /**
  46725. * Gets The camera contrast used on this material.
  46726. */
  46727. /**
  46728. * Sets The camera contrast used on this material.
  46729. */
  46730. cameraContrast: float;
  46731. /**
  46732. * Gets the Color Grading 2D Lookup Texture.
  46733. */
  46734. /**
  46735. * Sets the Color Grading 2D Lookup Texture.
  46736. */
  46737. cameraColorGradingTexture: Nullable<BaseTexture>;
  46738. /**
  46739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46741. * 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;
  46742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46743. */
  46744. /**
  46745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46747. * 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;
  46748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46749. */
  46750. cameraColorCurves: Nullable<ColorCurves>;
  46751. /**
  46752. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46753. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46754. */
  46755. switchToBGR: boolean;
  46756. private _renderTargets;
  46757. private _reflectionControls;
  46758. private _white;
  46759. private _primaryShadowColor;
  46760. private _primaryHighlightColor;
  46761. /**
  46762. * Instantiates a Background Material in the given scene
  46763. * @param name The friendly name of the material
  46764. * @param scene The scene to add the material to
  46765. */
  46766. constructor(name: string, scene: Scene);
  46767. /**
  46768. * Gets a boolean indicating that current material needs to register RTT
  46769. */
  46770. readonly hasRenderTargetTextures: boolean;
  46771. /**
  46772. * The entire material has been created in order to prevent overdraw.
  46773. * @returns false
  46774. */
  46775. needAlphaTesting(): boolean;
  46776. /**
  46777. * The entire material has been created in order to prevent overdraw.
  46778. * @returns true if blending is enable
  46779. */
  46780. needAlphaBlending(): boolean;
  46781. /**
  46782. * Checks wether the material is ready to be rendered for a given mesh.
  46783. * @param mesh The mesh to render
  46784. * @param subMesh The submesh to check against
  46785. * @param useInstances Specify wether or not the material is used with instances
  46786. * @returns true if all the dependencies are ready (Textures, Effects...)
  46787. */
  46788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46789. /**
  46790. * Compute the primary color according to the chosen perceptual color.
  46791. */
  46792. private _computePrimaryColorFromPerceptualColor;
  46793. /**
  46794. * Compute the highlights and shadow colors according to their chosen levels.
  46795. */
  46796. private _computePrimaryColors;
  46797. /**
  46798. * Build the uniform buffer used in the material.
  46799. */
  46800. buildUniformLayout(): void;
  46801. /**
  46802. * Unbind the material.
  46803. */
  46804. unbind(): void;
  46805. /**
  46806. * Bind only the world matrix to the material.
  46807. * @param world The world matrix to bind.
  46808. */
  46809. bindOnlyWorldMatrix(world: Matrix): void;
  46810. /**
  46811. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46812. * @param world The world matrix to bind.
  46813. * @param subMesh The submesh to bind for.
  46814. */
  46815. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46816. /**
  46817. * Dispose the material.
  46818. * @param forceDisposeEffect Force disposal of the associated effect.
  46819. * @param forceDisposeTextures Force disposal of the associated textures.
  46820. */
  46821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46822. /**
  46823. * Clones the material.
  46824. * @param name The cloned name.
  46825. * @returns The cloned material.
  46826. */
  46827. clone(name: string): BackgroundMaterial;
  46828. /**
  46829. * Serializes the current material to its JSON representation.
  46830. * @returns The JSON representation.
  46831. */
  46832. serialize(): any;
  46833. /**
  46834. * Gets the class name of the material
  46835. * @returns "BackgroundMaterial"
  46836. */
  46837. getClassName(): string;
  46838. /**
  46839. * Parse a JSON input to create back a background material.
  46840. * @param source The JSON data to parse
  46841. * @param scene The scene to create the parsed material in
  46842. * @param rootUrl The root url of the assets the material depends upon
  46843. * @returns the instantiated BackgroundMaterial.
  46844. */
  46845. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46846. }
  46847. }
  46848. declare module "babylonjs/Helpers/environmentHelper" {
  46849. import { Observable } from "babylonjs/Misc/observable";
  46850. import { Nullable } from "babylonjs/types";
  46851. import { Scene } from "babylonjs/scene";
  46852. import { Vector3 } from "babylonjs/Maths/math.vector";
  46853. import { Color3 } from "babylonjs/Maths/math.color";
  46854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46855. import { Mesh } from "babylonjs/Meshes/mesh";
  46856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46857. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46858. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46859. import "babylonjs/Meshes/Builders/planeBuilder";
  46860. import "babylonjs/Meshes/Builders/boxBuilder";
  46861. /**
  46862. * Represents the different options available during the creation of
  46863. * a Environment helper.
  46864. *
  46865. * This can control the default ground, skybox and image processing setup of your scene.
  46866. */
  46867. export interface IEnvironmentHelperOptions {
  46868. /**
  46869. * Specifies wether or not to create a ground.
  46870. * True by default.
  46871. */
  46872. createGround: boolean;
  46873. /**
  46874. * Specifies the ground size.
  46875. * 15 by default.
  46876. */
  46877. groundSize: number;
  46878. /**
  46879. * The texture used on the ground for the main color.
  46880. * Comes from the BabylonJS CDN by default.
  46881. *
  46882. * Remarks: Can be either a texture or a url.
  46883. */
  46884. groundTexture: string | BaseTexture;
  46885. /**
  46886. * The color mixed in the ground texture by default.
  46887. * BabylonJS clearColor by default.
  46888. */
  46889. groundColor: Color3;
  46890. /**
  46891. * Specifies the ground opacity.
  46892. * 1 by default.
  46893. */
  46894. groundOpacity: number;
  46895. /**
  46896. * Enables the ground to receive shadows.
  46897. * True by default.
  46898. */
  46899. enableGroundShadow: boolean;
  46900. /**
  46901. * Helps preventing the shadow to be fully black on the ground.
  46902. * 0.5 by default.
  46903. */
  46904. groundShadowLevel: number;
  46905. /**
  46906. * Creates a mirror texture attach to the ground.
  46907. * false by default.
  46908. */
  46909. enableGroundMirror: boolean;
  46910. /**
  46911. * Specifies the ground mirror size ratio.
  46912. * 0.3 by default as the default kernel is 64.
  46913. */
  46914. groundMirrorSizeRatio: number;
  46915. /**
  46916. * Specifies the ground mirror blur kernel size.
  46917. * 64 by default.
  46918. */
  46919. groundMirrorBlurKernel: number;
  46920. /**
  46921. * Specifies the ground mirror visibility amount.
  46922. * 1 by default
  46923. */
  46924. groundMirrorAmount: number;
  46925. /**
  46926. * Specifies the ground mirror reflectance weight.
  46927. * This uses the standard weight of the background material to setup the fresnel effect
  46928. * of the mirror.
  46929. * 1 by default.
  46930. */
  46931. groundMirrorFresnelWeight: number;
  46932. /**
  46933. * Specifies the ground mirror Falloff distance.
  46934. * This can helps reducing the size of the reflection.
  46935. * 0 by Default.
  46936. */
  46937. groundMirrorFallOffDistance: number;
  46938. /**
  46939. * Specifies the ground mirror texture type.
  46940. * Unsigned Int by Default.
  46941. */
  46942. groundMirrorTextureType: number;
  46943. /**
  46944. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46945. * the shown objects.
  46946. */
  46947. groundYBias: number;
  46948. /**
  46949. * Specifies wether or not to create a skybox.
  46950. * True by default.
  46951. */
  46952. createSkybox: boolean;
  46953. /**
  46954. * Specifies the skybox size.
  46955. * 20 by default.
  46956. */
  46957. skyboxSize: number;
  46958. /**
  46959. * The texture used on the skybox for the main color.
  46960. * Comes from the BabylonJS CDN by default.
  46961. *
  46962. * Remarks: Can be either a texture or a url.
  46963. */
  46964. skyboxTexture: string | BaseTexture;
  46965. /**
  46966. * The color mixed in the skybox texture by default.
  46967. * BabylonJS clearColor by default.
  46968. */
  46969. skyboxColor: Color3;
  46970. /**
  46971. * The background rotation around the Y axis of the scene.
  46972. * This helps aligning the key lights of your scene with the background.
  46973. * 0 by default.
  46974. */
  46975. backgroundYRotation: number;
  46976. /**
  46977. * Compute automatically the size of the elements to best fit with the scene.
  46978. */
  46979. sizeAuto: boolean;
  46980. /**
  46981. * Default position of the rootMesh if autoSize is not true.
  46982. */
  46983. rootPosition: Vector3;
  46984. /**
  46985. * Sets up the image processing in the scene.
  46986. * true by default.
  46987. */
  46988. setupImageProcessing: boolean;
  46989. /**
  46990. * The texture used as your environment texture in the scene.
  46991. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46992. *
  46993. * Remarks: Can be either a texture or a url.
  46994. */
  46995. environmentTexture: string | BaseTexture;
  46996. /**
  46997. * The value of the exposure to apply to the scene.
  46998. * 0.6 by default if setupImageProcessing is true.
  46999. */
  47000. cameraExposure: number;
  47001. /**
  47002. * The value of the contrast to apply to the scene.
  47003. * 1.6 by default if setupImageProcessing is true.
  47004. */
  47005. cameraContrast: number;
  47006. /**
  47007. * Specifies wether or not tonemapping should be enabled in the scene.
  47008. * true by default if setupImageProcessing is true.
  47009. */
  47010. toneMappingEnabled: boolean;
  47011. }
  47012. /**
  47013. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47014. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47015. * It also helps with the default setup of your imageProcessing configuration.
  47016. */
  47017. export class EnvironmentHelper {
  47018. /**
  47019. * Default ground texture URL.
  47020. */
  47021. private static _groundTextureCDNUrl;
  47022. /**
  47023. * Default skybox texture URL.
  47024. */
  47025. private static _skyboxTextureCDNUrl;
  47026. /**
  47027. * Default environment texture URL.
  47028. */
  47029. private static _environmentTextureCDNUrl;
  47030. /**
  47031. * Creates the default options for the helper.
  47032. */
  47033. private static _getDefaultOptions;
  47034. private _rootMesh;
  47035. /**
  47036. * Gets the root mesh created by the helper.
  47037. */
  47038. readonly rootMesh: Mesh;
  47039. private _skybox;
  47040. /**
  47041. * Gets the skybox created by the helper.
  47042. */
  47043. readonly skybox: Nullable<Mesh>;
  47044. private _skyboxTexture;
  47045. /**
  47046. * Gets the skybox texture created by the helper.
  47047. */
  47048. readonly skyboxTexture: Nullable<BaseTexture>;
  47049. private _skyboxMaterial;
  47050. /**
  47051. * Gets the skybox material created by the helper.
  47052. */
  47053. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47054. private _ground;
  47055. /**
  47056. * Gets the ground mesh created by the helper.
  47057. */
  47058. readonly ground: Nullable<Mesh>;
  47059. private _groundTexture;
  47060. /**
  47061. * Gets the ground texture created by the helper.
  47062. */
  47063. readonly groundTexture: Nullable<BaseTexture>;
  47064. private _groundMirror;
  47065. /**
  47066. * Gets the ground mirror created by the helper.
  47067. */
  47068. readonly groundMirror: Nullable<MirrorTexture>;
  47069. /**
  47070. * Gets the ground mirror render list to helps pushing the meshes
  47071. * you wish in the ground reflection.
  47072. */
  47073. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47074. private _groundMaterial;
  47075. /**
  47076. * Gets the ground material created by the helper.
  47077. */
  47078. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47079. /**
  47080. * Stores the creation options.
  47081. */
  47082. private readonly _scene;
  47083. private _options;
  47084. /**
  47085. * This observable will be notified with any error during the creation of the environment,
  47086. * mainly texture creation errors.
  47087. */
  47088. onErrorObservable: Observable<{
  47089. message?: string;
  47090. exception?: any;
  47091. }>;
  47092. /**
  47093. * constructor
  47094. * @param options Defines the options we want to customize the helper
  47095. * @param scene The scene to add the material to
  47096. */
  47097. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47098. /**
  47099. * Updates the background according to the new options
  47100. * @param options
  47101. */
  47102. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47103. /**
  47104. * Sets the primary color of all the available elements.
  47105. * @param color the main color to affect to the ground and the background
  47106. */
  47107. setMainColor(color: Color3): void;
  47108. /**
  47109. * Setup the image processing according to the specified options.
  47110. */
  47111. private _setupImageProcessing;
  47112. /**
  47113. * Setup the environment texture according to the specified options.
  47114. */
  47115. private _setupEnvironmentTexture;
  47116. /**
  47117. * Setup the background according to the specified options.
  47118. */
  47119. private _setupBackground;
  47120. /**
  47121. * Get the scene sizes according to the setup.
  47122. */
  47123. private _getSceneSize;
  47124. /**
  47125. * Setup the ground according to the specified options.
  47126. */
  47127. private _setupGround;
  47128. /**
  47129. * Setup the ground material according to the specified options.
  47130. */
  47131. private _setupGroundMaterial;
  47132. /**
  47133. * Setup the ground diffuse texture according to the specified options.
  47134. */
  47135. private _setupGroundDiffuseTexture;
  47136. /**
  47137. * Setup the ground mirror texture according to the specified options.
  47138. */
  47139. private _setupGroundMirrorTexture;
  47140. /**
  47141. * Setup the ground to receive the mirror texture.
  47142. */
  47143. private _setupMirrorInGroundMaterial;
  47144. /**
  47145. * Setup the skybox according to the specified options.
  47146. */
  47147. private _setupSkybox;
  47148. /**
  47149. * Setup the skybox material according to the specified options.
  47150. */
  47151. private _setupSkyboxMaterial;
  47152. /**
  47153. * Setup the skybox reflection texture according to the specified options.
  47154. */
  47155. private _setupSkyboxReflectionTexture;
  47156. private _errorHandler;
  47157. /**
  47158. * Dispose all the elements created by the Helper.
  47159. */
  47160. dispose(): void;
  47161. }
  47162. }
  47163. declare module "babylonjs/Helpers/photoDome" {
  47164. import { Observable } from "babylonjs/Misc/observable";
  47165. import { Nullable } from "babylonjs/types";
  47166. import { Scene } from "babylonjs/scene";
  47167. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47168. import { Mesh } from "babylonjs/Meshes/mesh";
  47169. import { Texture } from "babylonjs/Materials/Textures/texture";
  47170. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47171. import "babylonjs/Meshes/Builders/sphereBuilder";
  47172. /**
  47173. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47174. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47175. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47176. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47177. */
  47178. export class PhotoDome extends TransformNode {
  47179. /**
  47180. * Define the image as a Monoscopic panoramic 360 image.
  47181. */
  47182. static readonly MODE_MONOSCOPIC: number;
  47183. /**
  47184. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47185. */
  47186. static readonly MODE_TOPBOTTOM: number;
  47187. /**
  47188. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47189. */
  47190. static readonly MODE_SIDEBYSIDE: number;
  47191. private _useDirectMapping;
  47192. /**
  47193. * The texture being displayed on the sphere
  47194. */
  47195. protected _photoTexture: Texture;
  47196. /**
  47197. * Gets or sets the texture being displayed on the sphere
  47198. */
  47199. photoTexture: Texture;
  47200. /**
  47201. * Observable raised when an error occured while loading the 360 image
  47202. */
  47203. onLoadErrorObservable: Observable<string>;
  47204. /**
  47205. * The skybox material
  47206. */
  47207. protected _material: BackgroundMaterial;
  47208. /**
  47209. * The surface used for the skybox
  47210. */
  47211. protected _mesh: Mesh;
  47212. /**
  47213. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47214. * Also see the options.resolution property.
  47215. */
  47216. fovMultiplier: number;
  47217. private _imageMode;
  47218. /**
  47219. * Gets or set the current video mode for the video. It can be:
  47220. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47221. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47222. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47223. */
  47224. imageMode: number;
  47225. /**
  47226. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47227. * @param name Element's name, child elements will append suffixes for their own names.
  47228. * @param urlsOfPhoto defines the url of the photo to display
  47229. * @param options defines an object containing optional or exposed sub element properties
  47230. * @param onError defines a callback called when an error occured while loading the texture
  47231. */
  47232. constructor(name: string, urlOfPhoto: string, options: {
  47233. resolution?: number;
  47234. size?: number;
  47235. useDirectMapping?: boolean;
  47236. faceForward?: boolean;
  47237. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47238. private _onBeforeCameraRenderObserver;
  47239. private _changeImageMode;
  47240. /**
  47241. * Releases resources associated with this node.
  47242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47244. */
  47245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47246. }
  47247. }
  47248. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47249. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47250. /** @hidden */
  47251. export var rgbdDecodePixelShader: {
  47252. name: string;
  47253. shader: string;
  47254. };
  47255. }
  47256. declare module "babylonjs/Misc/brdfTextureTools" {
  47257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47258. import { Scene } from "babylonjs/scene";
  47259. import "babylonjs/Shaders/rgbdDecode.fragment";
  47260. /**
  47261. * Class used to host texture specific utilities
  47262. */
  47263. export class BRDFTextureTools {
  47264. /**
  47265. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47266. * @param texture the texture to expand.
  47267. */
  47268. private static _ExpandDefaultBRDFTexture;
  47269. /**
  47270. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47271. * @param scene defines the hosting scene
  47272. * @returns the environment BRDF texture
  47273. */
  47274. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47275. private static _environmentBRDFBase64Texture;
  47276. }
  47277. }
  47278. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47279. import { Nullable } from "babylonjs/types";
  47280. import { Color3 } from "babylonjs/Maths/math.color";
  47281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47282. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47283. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47284. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47285. import { Engine } from "babylonjs/Engines/engine";
  47286. import { Scene } from "babylonjs/scene";
  47287. /**
  47288. * @hidden
  47289. */
  47290. export interface IMaterialClearCoatDefines {
  47291. CLEARCOAT: boolean;
  47292. CLEARCOAT_DEFAULTIOR: boolean;
  47293. CLEARCOAT_TEXTURE: boolean;
  47294. CLEARCOAT_TEXTUREDIRECTUV: number;
  47295. CLEARCOAT_BUMP: boolean;
  47296. CLEARCOAT_BUMPDIRECTUV: number;
  47297. CLEARCOAT_TINT: boolean;
  47298. CLEARCOAT_TINT_TEXTURE: boolean;
  47299. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47300. /** @hidden */
  47301. _areTexturesDirty: boolean;
  47302. }
  47303. /**
  47304. * Define the code related to the clear coat parameters of the pbr material.
  47305. */
  47306. export class PBRClearCoatConfiguration {
  47307. /**
  47308. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47309. * The default fits with a polyurethane material.
  47310. */
  47311. private static readonly _DefaultIndexOfRefraction;
  47312. private _isEnabled;
  47313. /**
  47314. * Defines if the clear coat is enabled in the material.
  47315. */
  47316. isEnabled: boolean;
  47317. /**
  47318. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47319. */
  47320. intensity: number;
  47321. /**
  47322. * Defines the clear coat layer roughness.
  47323. */
  47324. roughness: number;
  47325. private _indexOfRefraction;
  47326. /**
  47327. * Defines the index of refraction of the clear coat.
  47328. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47329. * The default fits with a polyurethane material.
  47330. * Changing the default value is more performance intensive.
  47331. */
  47332. indexOfRefraction: number;
  47333. private _texture;
  47334. /**
  47335. * Stores the clear coat values in a texture.
  47336. */
  47337. texture: Nullable<BaseTexture>;
  47338. private _bumpTexture;
  47339. /**
  47340. * Define the clear coat specific bump texture.
  47341. */
  47342. bumpTexture: Nullable<BaseTexture>;
  47343. private _isTintEnabled;
  47344. /**
  47345. * Defines if the clear coat tint is enabled in the material.
  47346. */
  47347. isTintEnabled: boolean;
  47348. /**
  47349. * Defines the clear coat tint of the material.
  47350. * This is only use if tint is enabled
  47351. */
  47352. tintColor: Color3;
  47353. /**
  47354. * Defines the distance at which the tint color should be found in the
  47355. * clear coat media.
  47356. * This is only use if tint is enabled
  47357. */
  47358. tintColorAtDistance: number;
  47359. /**
  47360. * Defines the clear coat layer thickness.
  47361. * This is only use if tint is enabled
  47362. */
  47363. tintThickness: number;
  47364. private _tintTexture;
  47365. /**
  47366. * Stores the clear tint values in a texture.
  47367. * rgb is tint
  47368. * a is a thickness factor
  47369. */
  47370. tintTexture: Nullable<BaseTexture>;
  47371. /** @hidden */
  47372. private _internalMarkAllSubMeshesAsTexturesDirty;
  47373. /** @hidden */
  47374. _markAllSubMeshesAsTexturesDirty(): void;
  47375. /**
  47376. * Instantiate a new istance of clear coat configuration.
  47377. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47378. */
  47379. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47380. /**
  47381. * Gets wehter the submesh is ready to be used or not.
  47382. * @param defines the list of "defines" to update.
  47383. * @param scene defines the scene the material belongs to.
  47384. * @param engine defines the engine the material belongs to.
  47385. * @param disableBumpMap defines wether the material disables bump or not.
  47386. * @returns - boolean indicating that the submesh is ready or not.
  47387. */
  47388. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47389. /**
  47390. * Checks to see if a texture is used in the material.
  47391. * @param defines the list of "defines" to update.
  47392. * @param scene defines the scene to the material belongs to.
  47393. */
  47394. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47395. /**
  47396. * Binds the material data.
  47397. * @param uniformBuffer defines the Uniform buffer to fill in.
  47398. * @param scene defines the scene the material belongs to.
  47399. * @param engine defines the engine the material belongs to.
  47400. * @param disableBumpMap defines wether the material disables bump or not.
  47401. * @param isFrozen defines wether the material is frozen or not.
  47402. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47403. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47404. */
  47405. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Returns an array of the actively used textures.
  47414. * @param activeTextures Array of BaseTextures
  47415. */
  47416. getActiveTextures(activeTextures: BaseTexture[]): void;
  47417. /**
  47418. * Returns the animatable textures.
  47419. * @param animatables Array of animatable textures.
  47420. */
  47421. getAnimatables(animatables: IAnimatable[]): void;
  47422. /**
  47423. * Disposes the resources of the material.
  47424. * @param forceDisposeTextures - Forces the disposal of all textures.
  47425. */
  47426. dispose(forceDisposeTextures?: boolean): void;
  47427. /**
  47428. * Get the current class name of the texture useful for serialization or dynamic coding.
  47429. * @returns "PBRClearCoatConfiguration"
  47430. */
  47431. getClassName(): string;
  47432. /**
  47433. * Add fallbacks to the effect fallbacks list.
  47434. * @param defines defines the Base texture to use.
  47435. * @param fallbacks defines the current fallback list.
  47436. * @param currentRank defines the current fallback rank.
  47437. * @returns the new fallback rank.
  47438. */
  47439. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47440. /**
  47441. * Add the required uniforms to the current list.
  47442. * @param uniforms defines the current uniform list.
  47443. */
  47444. static AddUniforms(uniforms: string[]): void;
  47445. /**
  47446. * Add the required samplers to the current list.
  47447. * @param samplers defines the current sampler list.
  47448. */
  47449. static AddSamplers(samplers: string[]): void;
  47450. /**
  47451. * Add the required uniforms to the current buffer.
  47452. * @param uniformBuffer defines the current uniform buffer.
  47453. */
  47454. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47455. /**
  47456. * Makes a duplicate of the current configuration into another one.
  47457. * @param clearCoatConfiguration define the config where to copy the info
  47458. */
  47459. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47460. /**
  47461. * Serializes this clear coat configuration.
  47462. * @returns - An object with the serialized config.
  47463. */
  47464. serialize(): any;
  47465. /**
  47466. * Parses a anisotropy Configuration from a serialized object.
  47467. * @param source - Serialized object.
  47468. * @param scene Defines the scene we are parsing for
  47469. * @param rootUrl Defines the rootUrl to load from
  47470. */
  47471. parse(source: any, scene: Scene, rootUrl: string): void;
  47472. }
  47473. }
  47474. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47475. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47478. import { Vector2 } from "babylonjs/Maths/math.vector";
  47479. import { Scene } from "babylonjs/scene";
  47480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47481. import { Nullable } from "babylonjs/types";
  47482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47483. /**
  47484. * @hidden
  47485. */
  47486. export interface IMaterialAnisotropicDefines {
  47487. ANISOTROPIC: boolean;
  47488. ANISOTROPIC_TEXTURE: boolean;
  47489. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47490. MAINUV1: boolean;
  47491. _areTexturesDirty: boolean;
  47492. _needUVs: boolean;
  47493. }
  47494. /**
  47495. * Define the code related to the anisotropic parameters of the pbr material.
  47496. */
  47497. export class PBRAnisotropicConfiguration {
  47498. private _isEnabled;
  47499. /**
  47500. * Defines if the anisotropy is enabled in the material.
  47501. */
  47502. isEnabled: boolean;
  47503. /**
  47504. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47505. */
  47506. intensity: number;
  47507. /**
  47508. * Defines if the effect is along the tangents, bitangents or in between.
  47509. * By default, the effect is "strectching" the highlights along the tangents.
  47510. */
  47511. direction: Vector2;
  47512. private _texture;
  47513. /**
  47514. * Stores the anisotropy values in a texture.
  47515. * rg is direction (like normal from -1 to 1)
  47516. * b is a intensity
  47517. */
  47518. texture: Nullable<BaseTexture>;
  47519. /** @hidden */
  47520. private _internalMarkAllSubMeshesAsTexturesDirty;
  47521. /** @hidden */
  47522. _markAllSubMeshesAsTexturesDirty(): void;
  47523. /**
  47524. * Instantiate a new istance of anisotropy configuration.
  47525. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47526. */
  47527. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47528. /**
  47529. * Specifies that the submesh is ready to be used.
  47530. * @param defines the list of "defines" to update.
  47531. * @param scene defines the scene the material belongs to.
  47532. * @returns - boolean indicating that the submesh is ready or not.
  47533. */
  47534. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47535. /**
  47536. * Checks to see if a texture is used in the material.
  47537. * @param defines the list of "defines" to update.
  47538. * @param mesh the mesh we are preparing the defines for.
  47539. * @param scene defines the scene the material belongs to.
  47540. */
  47541. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47542. /**
  47543. * Binds the material data.
  47544. * @param uniformBuffer defines the Uniform buffer to fill in.
  47545. * @param scene defines the scene the material belongs to.
  47546. * @param isFrozen defines wether the material is frozen or not.
  47547. */
  47548. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47549. /**
  47550. * Checks to see if a texture is used in the material.
  47551. * @param texture - Base texture to use.
  47552. * @returns - Boolean specifying if a texture is used in the material.
  47553. */
  47554. hasTexture(texture: BaseTexture): boolean;
  47555. /**
  47556. * Returns an array of the actively used textures.
  47557. * @param activeTextures Array of BaseTextures
  47558. */
  47559. getActiveTextures(activeTextures: BaseTexture[]): void;
  47560. /**
  47561. * Returns the animatable textures.
  47562. * @param animatables Array of animatable textures.
  47563. */
  47564. getAnimatables(animatables: IAnimatable[]): void;
  47565. /**
  47566. * Disposes the resources of the material.
  47567. * @param forceDisposeTextures - Forces the disposal of all textures.
  47568. */
  47569. dispose(forceDisposeTextures?: boolean): void;
  47570. /**
  47571. * Get the current class name of the texture useful for serialization or dynamic coding.
  47572. * @returns "PBRAnisotropicConfiguration"
  47573. */
  47574. getClassName(): string;
  47575. /**
  47576. * Add fallbacks to the effect fallbacks list.
  47577. * @param defines defines the Base texture to use.
  47578. * @param fallbacks defines the current fallback list.
  47579. * @param currentRank defines the current fallback rank.
  47580. * @returns the new fallback rank.
  47581. */
  47582. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47583. /**
  47584. * Add the required uniforms to the current list.
  47585. * @param uniforms defines the current uniform list.
  47586. */
  47587. static AddUniforms(uniforms: string[]): void;
  47588. /**
  47589. * Add the required uniforms to the current buffer.
  47590. * @param uniformBuffer defines the current uniform buffer.
  47591. */
  47592. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47593. /**
  47594. * Add the required samplers to the current list.
  47595. * @param samplers defines the current sampler list.
  47596. */
  47597. static AddSamplers(samplers: string[]): void;
  47598. /**
  47599. * Makes a duplicate of the current configuration into another one.
  47600. * @param anisotropicConfiguration define the config where to copy the info
  47601. */
  47602. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47603. /**
  47604. * Serializes this anisotropy configuration.
  47605. * @returns - An object with the serialized config.
  47606. */
  47607. serialize(): any;
  47608. /**
  47609. * Parses a anisotropy Configuration from a serialized object.
  47610. * @param source - Serialized object.
  47611. * @param scene Defines the scene we are parsing for
  47612. * @param rootUrl Defines the rootUrl to load from
  47613. */
  47614. parse(source: any, scene: Scene, rootUrl: string): void;
  47615. }
  47616. }
  47617. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47618. import { Scene } from "babylonjs/scene";
  47619. /**
  47620. * @hidden
  47621. */
  47622. export interface IMaterialBRDFDefines {
  47623. BRDF_V_HEIGHT_CORRELATED: boolean;
  47624. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47625. SPHERICAL_HARMONICS: boolean;
  47626. /** @hidden */
  47627. _areMiscDirty: boolean;
  47628. }
  47629. /**
  47630. * Define the code related to the BRDF parameters of the pbr material.
  47631. */
  47632. export class PBRBRDFConfiguration {
  47633. /**
  47634. * Default value used for the energy conservation.
  47635. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47636. */
  47637. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47638. /**
  47639. * Default value used for the Smith Visibility Height Correlated mode.
  47640. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47641. */
  47642. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47643. /**
  47644. * Default value used for the IBL diffuse part.
  47645. * This can help switching back to the polynomials mode globally which is a tiny bit
  47646. * less GPU intensive at the drawback of a lower quality.
  47647. */
  47648. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47649. private _useEnergyConservation;
  47650. /**
  47651. * Defines if the material uses energy conservation.
  47652. */
  47653. useEnergyConservation: boolean;
  47654. private _useSmithVisibilityHeightCorrelated;
  47655. /**
  47656. * LEGACY Mode set to false
  47657. * Defines if the material uses height smith correlated visibility term.
  47658. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47659. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47660. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47661. * Not relying on height correlated will also disable energy conservation.
  47662. */
  47663. useSmithVisibilityHeightCorrelated: boolean;
  47664. private _useSphericalHarmonics;
  47665. /**
  47666. * LEGACY Mode set to false
  47667. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47668. * diffuse part of the IBL.
  47669. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47670. * to the ground truth.
  47671. */
  47672. useSphericalHarmonics: boolean;
  47673. /** @hidden */
  47674. private _internalMarkAllSubMeshesAsMiscDirty;
  47675. /** @hidden */
  47676. _markAllSubMeshesAsMiscDirty(): void;
  47677. /**
  47678. * Instantiate a new istance of clear coat configuration.
  47679. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47680. */
  47681. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47682. /**
  47683. * Checks to see if a texture is used in the material.
  47684. * @param defines the list of "defines" to update.
  47685. */
  47686. prepareDefines(defines: IMaterialBRDFDefines): void;
  47687. /**
  47688. * Get the current class name of the texture useful for serialization or dynamic coding.
  47689. * @returns "PBRClearCoatConfiguration"
  47690. */
  47691. getClassName(): string;
  47692. /**
  47693. * Makes a duplicate of the current configuration into another one.
  47694. * @param brdfConfiguration define the config where to copy the info
  47695. */
  47696. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47697. /**
  47698. * Serializes this BRDF configuration.
  47699. * @returns - An object with the serialized config.
  47700. */
  47701. serialize(): any;
  47702. /**
  47703. * Parses a anisotropy Configuration from a serialized object.
  47704. * @param source - Serialized object.
  47705. * @param scene Defines the scene we are parsing for
  47706. * @param rootUrl Defines the rootUrl to load from
  47707. */
  47708. parse(source: any, scene: Scene, rootUrl: string): void;
  47709. }
  47710. }
  47711. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47712. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47714. import { Color3 } from "babylonjs/Maths/math.color";
  47715. import { Scene } from "babylonjs/scene";
  47716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47717. import { Nullable } from "babylonjs/types";
  47718. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47719. /**
  47720. * @hidden
  47721. */
  47722. export interface IMaterialSheenDefines {
  47723. SHEEN: boolean;
  47724. SHEEN_TEXTURE: boolean;
  47725. SHEEN_TEXTUREDIRECTUV: number;
  47726. SHEEN_LINKWITHALBEDO: boolean;
  47727. /** @hidden */
  47728. _areTexturesDirty: boolean;
  47729. }
  47730. /**
  47731. * Define the code related to the Sheen parameters of the pbr material.
  47732. */
  47733. export class PBRSheenConfiguration {
  47734. private _isEnabled;
  47735. /**
  47736. * Defines if the material uses sheen.
  47737. */
  47738. isEnabled: boolean;
  47739. private _linkSheenWithAlbedo;
  47740. /**
  47741. * Defines if the sheen is linked to the sheen color.
  47742. */
  47743. linkSheenWithAlbedo: boolean;
  47744. /**
  47745. * Defines the sheen intensity.
  47746. */
  47747. intensity: number;
  47748. /**
  47749. * Defines the sheen color.
  47750. */
  47751. color: Color3;
  47752. private _texture;
  47753. /**
  47754. * Stores the sheen tint values in a texture.
  47755. * rgb is tint
  47756. * a is a intensity
  47757. */
  47758. texture: Nullable<BaseTexture>;
  47759. /** @hidden */
  47760. private _internalMarkAllSubMeshesAsTexturesDirty;
  47761. /** @hidden */
  47762. _markAllSubMeshesAsTexturesDirty(): void;
  47763. /**
  47764. * Instantiate a new istance of clear coat configuration.
  47765. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47766. */
  47767. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47768. /**
  47769. * Specifies that the submesh is ready to be used.
  47770. * @param defines the list of "defines" to update.
  47771. * @param scene defines the scene the material belongs to.
  47772. * @returns - boolean indicating that the submesh is ready or not.
  47773. */
  47774. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47775. /**
  47776. * Checks to see if a texture is used in the material.
  47777. * @param defines the list of "defines" to update.
  47778. * @param scene defines the scene the material belongs to.
  47779. */
  47780. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47781. /**
  47782. * Binds the material data.
  47783. * @param uniformBuffer defines the Uniform buffer to fill in.
  47784. * @param scene defines the scene the material belongs to.
  47785. * @param isFrozen defines wether the material is frozen or not.
  47786. */
  47787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47788. /**
  47789. * Checks to see if a texture is used in the material.
  47790. * @param texture - Base texture to use.
  47791. * @returns - Boolean specifying if a texture is used in the material.
  47792. */
  47793. hasTexture(texture: BaseTexture): boolean;
  47794. /**
  47795. * Returns an array of the actively used textures.
  47796. * @param activeTextures Array of BaseTextures
  47797. */
  47798. getActiveTextures(activeTextures: BaseTexture[]): void;
  47799. /**
  47800. * Returns the animatable textures.
  47801. * @param animatables Array of animatable textures.
  47802. */
  47803. getAnimatables(animatables: IAnimatable[]): void;
  47804. /**
  47805. * Disposes the resources of the material.
  47806. * @param forceDisposeTextures - Forces the disposal of all textures.
  47807. */
  47808. dispose(forceDisposeTextures?: boolean): void;
  47809. /**
  47810. * Get the current class name of the texture useful for serialization or dynamic coding.
  47811. * @returns "PBRSheenConfiguration"
  47812. */
  47813. getClassName(): string;
  47814. /**
  47815. * Add fallbacks to the effect fallbacks list.
  47816. * @param defines defines the Base texture to use.
  47817. * @param fallbacks defines the current fallback list.
  47818. * @param currentRank defines the current fallback rank.
  47819. * @returns the new fallback rank.
  47820. */
  47821. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47822. /**
  47823. * Add the required uniforms to the current list.
  47824. * @param uniforms defines the current uniform list.
  47825. */
  47826. static AddUniforms(uniforms: string[]): void;
  47827. /**
  47828. * Add the required uniforms to the current buffer.
  47829. * @param uniformBuffer defines the current uniform buffer.
  47830. */
  47831. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47832. /**
  47833. * Add the required samplers to the current list.
  47834. * @param samplers defines the current sampler list.
  47835. */
  47836. static AddSamplers(samplers: string[]): void;
  47837. /**
  47838. * Makes a duplicate of the current configuration into another one.
  47839. * @param sheenConfiguration define the config where to copy the info
  47840. */
  47841. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47842. /**
  47843. * Serializes this BRDF configuration.
  47844. * @returns - An object with the serialized config.
  47845. */
  47846. serialize(): any;
  47847. /**
  47848. * Parses a anisotropy Configuration from a serialized object.
  47849. * @param source - Serialized object.
  47850. * @param scene Defines the scene we are parsing for
  47851. * @param rootUrl Defines the rootUrl to load from
  47852. */
  47853. parse(source: any, scene: Scene, rootUrl: string): void;
  47854. }
  47855. }
  47856. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47857. import { Nullable } from "babylonjs/types";
  47858. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47859. import { Color3 } from "babylonjs/Maths/math.color";
  47860. import { SmartArray } from "babylonjs/Misc/smartArray";
  47861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47862. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47863. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47864. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47865. import { Engine } from "babylonjs/Engines/engine";
  47866. import { Scene } from "babylonjs/scene";
  47867. /**
  47868. * @hidden
  47869. */
  47870. export interface IMaterialSubSurfaceDefines {
  47871. SUBSURFACE: boolean;
  47872. SS_REFRACTION: boolean;
  47873. SS_TRANSLUCENCY: boolean;
  47874. SS_SCATERRING: boolean;
  47875. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47876. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47877. SS_REFRACTIONMAP_3D: boolean;
  47878. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47879. SS_LODINREFRACTIONALPHA: boolean;
  47880. SS_GAMMAREFRACTION: boolean;
  47881. SS_RGBDREFRACTION: boolean;
  47882. SS_LINEARSPECULARREFRACTION: boolean;
  47883. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47884. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47885. /** @hidden */
  47886. _areTexturesDirty: boolean;
  47887. }
  47888. /**
  47889. * Define the code related to the sub surface parameters of the pbr material.
  47890. */
  47891. export class PBRSubSurfaceConfiguration {
  47892. private _isRefractionEnabled;
  47893. /**
  47894. * Defines if the refraction is enabled in the material.
  47895. */
  47896. isRefractionEnabled: boolean;
  47897. private _isTranslucencyEnabled;
  47898. /**
  47899. * Defines if the translucency is enabled in the material.
  47900. */
  47901. isTranslucencyEnabled: boolean;
  47902. private _isScatteringEnabled;
  47903. /**
  47904. * Defines the refraction intensity of the material.
  47905. * The refraction when enabled replaces the Diffuse part of the material.
  47906. * The intensity helps transitionning between diffuse and refraction.
  47907. */
  47908. refractionIntensity: number;
  47909. /**
  47910. * Defines the translucency intensity of the material.
  47911. * When translucency has been enabled, this defines how much of the "translucency"
  47912. * is addded to the diffuse part of the material.
  47913. */
  47914. translucencyIntensity: number;
  47915. /**
  47916. * Defines the scattering intensity of the material.
  47917. * When scattering has been enabled, this defines how much of the "scattered light"
  47918. * is addded to the diffuse part of the material.
  47919. */
  47920. scatteringIntensity: number;
  47921. private _thicknessTexture;
  47922. /**
  47923. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47924. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47925. * 0 would mean minimumThickness
  47926. * 1 would mean maximumThickness
  47927. * The other channels might be use as a mask to vary the different effects intensity.
  47928. */
  47929. thicknessTexture: Nullable<BaseTexture>;
  47930. private _refractionTexture;
  47931. /**
  47932. * Defines the texture to use for refraction.
  47933. */
  47934. refractionTexture: Nullable<BaseTexture>;
  47935. private _indexOfRefraction;
  47936. /**
  47937. * Defines the index of refraction used in the material.
  47938. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47939. */
  47940. indexOfRefraction: number;
  47941. private _invertRefractionY;
  47942. /**
  47943. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47944. */
  47945. invertRefractionY: boolean;
  47946. private _linkRefractionWithTransparency;
  47947. /**
  47948. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47949. * Materials half opaque for instance using refraction could benefit from this control.
  47950. */
  47951. linkRefractionWithTransparency: boolean;
  47952. /**
  47953. * Defines the minimum thickness stored in the thickness map.
  47954. * If no thickness map is defined, this value will be used to simulate thickness.
  47955. */
  47956. minimumThickness: number;
  47957. /**
  47958. * Defines the maximum thickness stored in the thickness map.
  47959. */
  47960. maximumThickness: number;
  47961. /**
  47962. * Defines the volume tint of the material.
  47963. * This is used for both translucency and scattering.
  47964. */
  47965. tintColor: Color3;
  47966. /**
  47967. * Defines the distance at which the tint color should be found in the media.
  47968. * This is used for refraction only.
  47969. */
  47970. tintColorAtDistance: number;
  47971. /**
  47972. * Defines how far each channel transmit through the media.
  47973. * It is defined as a color to simplify it selection.
  47974. */
  47975. diffusionDistance: Color3;
  47976. private _useMaskFromThicknessTexture;
  47977. /**
  47978. * Stores the intensity of the different subsurface effects in the thickness texture.
  47979. * * the green channel is the translucency intensity.
  47980. * * the blue channel is the scattering intensity.
  47981. * * the alpha channel is the refraction intensity.
  47982. */
  47983. useMaskFromThicknessTexture: boolean;
  47984. /** @hidden */
  47985. private _internalMarkAllSubMeshesAsTexturesDirty;
  47986. /** @hidden */
  47987. _markAllSubMeshesAsTexturesDirty(): void;
  47988. /**
  47989. * Instantiate a new istance of sub surface configuration.
  47990. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47991. */
  47992. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47993. /**
  47994. * Gets wehter the submesh is ready to be used or not.
  47995. * @param defines the list of "defines" to update.
  47996. * @param scene defines the scene the material belongs to.
  47997. * @returns - boolean indicating that the submesh is ready or not.
  47998. */
  47999. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48000. /**
  48001. * Checks to see if a texture is used in the material.
  48002. * @param defines the list of "defines" to update.
  48003. * @param scene defines the scene to the material belongs to.
  48004. */
  48005. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48006. /**
  48007. * Binds the material data.
  48008. * @param uniformBuffer defines the Uniform buffer to fill in.
  48009. * @param scene defines the scene the material belongs to.
  48010. * @param engine defines the engine the material belongs to.
  48011. * @param isFrozen defines wether the material is frozen or not.
  48012. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48013. */
  48014. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48015. /**
  48016. * Unbinds the material from the mesh.
  48017. * @param activeEffect defines the effect that should be unbound from.
  48018. * @returns true if unbound, otherwise false
  48019. */
  48020. unbind(activeEffect: Effect): boolean;
  48021. /**
  48022. * Returns the texture used for refraction or null if none is used.
  48023. * @param scene defines the scene the material belongs to.
  48024. * @returns - Refraction texture if present. If no refraction texture and refraction
  48025. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48026. */
  48027. private _getRefractionTexture;
  48028. /**
  48029. * Returns true if alpha blending should be disabled.
  48030. */
  48031. readonly disableAlphaBlending: boolean;
  48032. /**
  48033. * Fills the list of render target textures.
  48034. * @param renderTargets the list of render targets to update
  48035. */
  48036. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48037. /**
  48038. * Checks to see if a texture is used in the material.
  48039. * @param texture - Base texture to use.
  48040. * @returns - Boolean specifying if a texture is used in the material.
  48041. */
  48042. hasTexture(texture: BaseTexture): boolean;
  48043. /**
  48044. * Gets a boolean indicating that current material needs to register RTT
  48045. * @returns true if this uses a render target otherwise false.
  48046. */
  48047. hasRenderTargetTextures(): boolean;
  48048. /**
  48049. * Returns an array of the actively used textures.
  48050. * @param activeTextures Array of BaseTextures
  48051. */
  48052. getActiveTextures(activeTextures: BaseTexture[]): void;
  48053. /**
  48054. * Returns the animatable textures.
  48055. * @param animatables Array of animatable textures.
  48056. */
  48057. getAnimatables(animatables: IAnimatable[]): void;
  48058. /**
  48059. * Disposes the resources of the material.
  48060. * @param forceDisposeTextures - Forces the disposal of all textures.
  48061. */
  48062. dispose(forceDisposeTextures?: boolean): void;
  48063. /**
  48064. * Get the current class name of the texture useful for serialization or dynamic coding.
  48065. * @returns "PBRSubSurfaceConfiguration"
  48066. */
  48067. getClassName(): string;
  48068. /**
  48069. * Add fallbacks to the effect fallbacks list.
  48070. * @param defines defines the Base texture to use.
  48071. * @param fallbacks defines the current fallback list.
  48072. * @param currentRank defines the current fallback rank.
  48073. * @returns the new fallback rank.
  48074. */
  48075. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48076. /**
  48077. * Add the required uniforms to the current list.
  48078. * @param uniforms defines the current uniform list.
  48079. */
  48080. static AddUniforms(uniforms: string[]): void;
  48081. /**
  48082. * Add the required samplers to the current list.
  48083. * @param samplers defines the current sampler list.
  48084. */
  48085. static AddSamplers(samplers: string[]): void;
  48086. /**
  48087. * Add the required uniforms to the current buffer.
  48088. * @param uniformBuffer defines the current uniform buffer.
  48089. */
  48090. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48091. /**
  48092. * Makes a duplicate of the current configuration into another one.
  48093. * @param configuration define the config where to copy the info
  48094. */
  48095. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48096. /**
  48097. * Serializes this Sub Surface configuration.
  48098. * @returns - An object with the serialized config.
  48099. */
  48100. serialize(): any;
  48101. /**
  48102. * Parses a anisotropy Configuration from a serialized object.
  48103. * @param source - Serialized object.
  48104. * @param scene Defines the scene we are parsing for
  48105. * @param rootUrl Defines the rootUrl to load from
  48106. */
  48107. parse(source: any, scene: Scene, rootUrl: string): void;
  48108. }
  48109. }
  48110. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48111. /** @hidden */
  48112. export var pbrFragmentDeclaration: {
  48113. name: string;
  48114. shader: string;
  48115. };
  48116. }
  48117. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48118. /** @hidden */
  48119. export var pbrUboDeclaration: {
  48120. name: string;
  48121. shader: string;
  48122. };
  48123. }
  48124. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48125. /** @hidden */
  48126. export var pbrFragmentExtraDeclaration: {
  48127. name: string;
  48128. shader: string;
  48129. };
  48130. }
  48131. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48132. /** @hidden */
  48133. export var pbrFragmentSamplersDeclaration: {
  48134. name: string;
  48135. shader: string;
  48136. };
  48137. }
  48138. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48139. /** @hidden */
  48140. export var pbrHelperFunctions: {
  48141. name: string;
  48142. shader: string;
  48143. };
  48144. }
  48145. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48146. /** @hidden */
  48147. export var harmonicsFunctions: {
  48148. name: string;
  48149. shader: string;
  48150. };
  48151. }
  48152. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48153. /** @hidden */
  48154. export var pbrDirectLightingSetupFunctions: {
  48155. name: string;
  48156. shader: string;
  48157. };
  48158. }
  48159. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48160. /** @hidden */
  48161. export var pbrDirectLightingFalloffFunctions: {
  48162. name: string;
  48163. shader: string;
  48164. };
  48165. }
  48166. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48167. /** @hidden */
  48168. export var pbrBRDFFunctions: {
  48169. name: string;
  48170. shader: string;
  48171. };
  48172. }
  48173. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48174. /** @hidden */
  48175. export var pbrDirectLightingFunctions: {
  48176. name: string;
  48177. shader: string;
  48178. };
  48179. }
  48180. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48181. /** @hidden */
  48182. export var pbrIBLFunctions: {
  48183. name: string;
  48184. shader: string;
  48185. };
  48186. }
  48187. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48188. /** @hidden */
  48189. export var pbrDebug: {
  48190. name: string;
  48191. shader: string;
  48192. };
  48193. }
  48194. declare module "babylonjs/Shaders/pbr.fragment" {
  48195. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48196. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48197. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48198. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48199. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48200. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48201. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48202. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48203. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48204. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48206. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48207. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48208. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48209. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48210. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48211. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48212. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48213. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48214. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48215. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48216. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48218. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48219. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48220. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48221. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48222. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48223. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48224. /** @hidden */
  48225. export var pbrPixelShader: {
  48226. name: string;
  48227. shader: string;
  48228. };
  48229. }
  48230. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48231. /** @hidden */
  48232. export var pbrVertexDeclaration: {
  48233. name: string;
  48234. shader: string;
  48235. };
  48236. }
  48237. declare module "babylonjs/Shaders/pbr.vertex" {
  48238. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48239. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48240. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48241. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48242. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48243. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48244. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48245. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48246. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48247. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48248. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48250. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48251. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48253. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48254. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48255. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48256. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48257. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48258. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48259. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48260. /** @hidden */
  48261. export var pbrVertexShader: {
  48262. name: string;
  48263. shader: string;
  48264. };
  48265. }
  48266. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48267. import { Nullable } from "babylonjs/types";
  48268. import { Scene } from "babylonjs/scene";
  48269. import { Matrix } from "babylonjs/Maths/math.vector";
  48270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48272. import { Mesh } from "babylonjs/Meshes/mesh";
  48273. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48274. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48275. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48276. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48277. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48278. import { Color3 } from "babylonjs/Maths/math.color";
  48279. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48280. import { Material } from "babylonjs/Materials/material";
  48281. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48282. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48284. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48285. import "babylonjs/Shaders/pbr.fragment";
  48286. import "babylonjs/Shaders/pbr.vertex";
  48287. /**
  48288. * Manages the defines for the PBR Material.
  48289. * @hidden
  48290. */
  48291. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48292. PBR: boolean;
  48293. MAINUV1: boolean;
  48294. MAINUV2: boolean;
  48295. UV1: boolean;
  48296. UV2: boolean;
  48297. ALBEDO: boolean;
  48298. ALBEDODIRECTUV: number;
  48299. VERTEXCOLOR: boolean;
  48300. AMBIENT: boolean;
  48301. AMBIENTDIRECTUV: number;
  48302. AMBIENTINGRAYSCALE: boolean;
  48303. OPACITY: boolean;
  48304. VERTEXALPHA: boolean;
  48305. OPACITYDIRECTUV: number;
  48306. OPACITYRGB: boolean;
  48307. ALPHATEST: boolean;
  48308. DEPTHPREPASS: boolean;
  48309. ALPHABLEND: boolean;
  48310. ALPHAFROMALBEDO: boolean;
  48311. ALPHATESTVALUE: string;
  48312. SPECULAROVERALPHA: boolean;
  48313. RADIANCEOVERALPHA: boolean;
  48314. ALPHAFRESNEL: boolean;
  48315. LINEARALPHAFRESNEL: boolean;
  48316. PREMULTIPLYALPHA: boolean;
  48317. EMISSIVE: boolean;
  48318. EMISSIVEDIRECTUV: number;
  48319. REFLECTIVITY: boolean;
  48320. REFLECTIVITYDIRECTUV: number;
  48321. SPECULARTERM: boolean;
  48322. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48323. MICROSURFACEAUTOMATIC: boolean;
  48324. LODBASEDMICROSFURACE: boolean;
  48325. MICROSURFACEMAP: boolean;
  48326. MICROSURFACEMAPDIRECTUV: number;
  48327. METALLICWORKFLOW: boolean;
  48328. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48329. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48330. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48331. AOSTOREINMETALMAPRED: boolean;
  48332. ENVIRONMENTBRDF: boolean;
  48333. ENVIRONMENTBRDF_RGBD: boolean;
  48334. NORMAL: boolean;
  48335. TANGENT: boolean;
  48336. BUMP: boolean;
  48337. BUMPDIRECTUV: number;
  48338. OBJECTSPACE_NORMALMAP: boolean;
  48339. PARALLAX: boolean;
  48340. PARALLAXOCCLUSION: boolean;
  48341. NORMALXYSCALE: boolean;
  48342. LIGHTMAP: boolean;
  48343. LIGHTMAPDIRECTUV: number;
  48344. USELIGHTMAPASSHADOWMAP: boolean;
  48345. GAMMALIGHTMAP: boolean;
  48346. REFLECTION: boolean;
  48347. REFLECTIONMAP_3D: boolean;
  48348. REFLECTIONMAP_SPHERICAL: boolean;
  48349. REFLECTIONMAP_PLANAR: boolean;
  48350. REFLECTIONMAP_CUBIC: boolean;
  48351. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48352. REFLECTIONMAP_PROJECTION: boolean;
  48353. REFLECTIONMAP_SKYBOX: boolean;
  48354. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48355. REFLECTIONMAP_EXPLICIT: boolean;
  48356. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48357. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48358. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48359. INVERTCUBICMAP: boolean;
  48360. USESPHERICALFROMREFLECTIONMAP: boolean;
  48361. USEIRRADIANCEMAP: boolean;
  48362. SPHERICAL_HARMONICS: boolean;
  48363. USESPHERICALINVERTEX: boolean;
  48364. REFLECTIONMAP_OPPOSITEZ: boolean;
  48365. LODINREFLECTIONALPHA: boolean;
  48366. GAMMAREFLECTION: boolean;
  48367. RGBDREFLECTION: boolean;
  48368. LINEARSPECULARREFLECTION: boolean;
  48369. RADIANCEOCCLUSION: boolean;
  48370. HORIZONOCCLUSION: boolean;
  48371. INSTANCES: boolean;
  48372. NUM_BONE_INFLUENCERS: number;
  48373. BonesPerMesh: number;
  48374. BONETEXTURE: boolean;
  48375. NONUNIFORMSCALING: boolean;
  48376. MORPHTARGETS: boolean;
  48377. MORPHTARGETS_NORMAL: boolean;
  48378. MORPHTARGETS_TANGENT: boolean;
  48379. MORPHTARGETS_UV: boolean;
  48380. NUM_MORPH_INFLUENCERS: number;
  48381. IMAGEPROCESSING: boolean;
  48382. VIGNETTE: boolean;
  48383. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48384. VIGNETTEBLENDMODEOPAQUE: boolean;
  48385. TONEMAPPING: boolean;
  48386. TONEMAPPING_ACES: boolean;
  48387. CONTRAST: boolean;
  48388. COLORCURVES: boolean;
  48389. COLORGRADING: boolean;
  48390. COLORGRADING3D: boolean;
  48391. SAMPLER3DGREENDEPTH: boolean;
  48392. SAMPLER3DBGRMAP: boolean;
  48393. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48394. EXPOSURE: boolean;
  48395. MULTIVIEW: boolean;
  48396. USEPHYSICALLIGHTFALLOFF: boolean;
  48397. USEGLTFLIGHTFALLOFF: boolean;
  48398. TWOSIDEDLIGHTING: boolean;
  48399. SHADOWFLOAT: boolean;
  48400. CLIPPLANE: boolean;
  48401. CLIPPLANE2: boolean;
  48402. CLIPPLANE3: boolean;
  48403. CLIPPLANE4: boolean;
  48404. POINTSIZE: boolean;
  48405. FOG: boolean;
  48406. LOGARITHMICDEPTH: boolean;
  48407. FORCENORMALFORWARD: boolean;
  48408. SPECULARAA: boolean;
  48409. CLEARCOAT: boolean;
  48410. CLEARCOAT_DEFAULTIOR: boolean;
  48411. CLEARCOAT_TEXTURE: boolean;
  48412. CLEARCOAT_TEXTUREDIRECTUV: number;
  48413. CLEARCOAT_BUMP: boolean;
  48414. CLEARCOAT_BUMPDIRECTUV: number;
  48415. CLEARCOAT_TINT: boolean;
  48416. CLEARCOAT_TINT_TEXTURE: boolean;
  48417. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48418. ANISOTROPIC: boolean;
  48419. ANISOTROPIC_TEXTURE: boolean;
  48420. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48421. BRDF_V_HEIGHT_CORRELATED: boolean;
  48422. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48423. SHEEN: boolean;
  48424. SHEEN_TEXTURE: boolean;
  48425. SHEEN_TEXTUREDIRECTUV: number;
  48426. SHEEN_LINKWITHALBEDO: boolean;
  48427. SUBSURFACE: boolean;
  48428. SS_REFRACTION: boolean;
  48429. SS_TRANSLUCENCY: boolean;
  48430. SS_SCATERRING: boolean;
  48431. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48432. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48433. SS_REFRACTIONMAP_3D: boolean;
  48434. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48435. SS_LODINREFRACTIONALPHA: boolean;
  48436. SS_GAMMAREFRACTION: boolean;
  48437. SS_RGBDREFRACTION: boolean;
  48438. SS_LINEARSPECULARREFRACTION: boolean;
  48439. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48440. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48441. UNLIT: boolean;
  48442. DEBUGMODE: number;
  48443. /**
  48444. * Initializes the PBR Material defines.
  48445. */
  48446. constructor();
  48447. /**
  48448. * Resets the PBR Material defines.
  48449. */
  48450. reset(): void;
  48451. }
  48452. /**
  48453. * The Physically based material base class of BJS.
  48454. *
  48455. * This offers the main features of a standard PBR material.
  48456. * For more information, please refer to the documentation :
  48457. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48458. */
  48459. export abstract class PBRBaseMaterial extends PushMaterial {
  48460. /**
  48461. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48462. */
  48463. static readonly PBRMATERIAL_OPAQUE: number;
  48464. /**
  48465. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48466. */
  48467. static readonly PBRMATERIAL_ALPHATEST: number;
  48468. /**
  48469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48470. */
  48471. static readonly PBRMATERIAL_ALPHABLEND: number;
  48472. /**
  48473. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48474. * They are also discarded below the alpha cutoff threshold to improve performances.
  48475. */
  48476. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48477. /**
  48478. * Defines the default value of how much AO map is occluding the analytical lights
  48479. * (point spot...).
  48480. */
  48481. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48482. /**
  48483. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48484. */
  48485. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48486. /**
  48487. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48488. * to enhance interoperability with other engines.
  48489. */
  48490. static readonly LIGHTFALLOFF_GLTF: number;
  48491. /**
  48492. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48493. * to enhance interoperability with other materials.
  48494. */
  48495. static readonly LIGHTFALLOFF_STANDARD: number;
  48496. /**
  48497. * Intensity of the direct lights e.g. the four lights available in your scene.
  48498. * This impacts both the direct diffuse and specular highlights.
  48499. */
  48500. protected _directIntensity: number;
  48501. /**
  48502. * Intensity of the emissive part of the material.
  48503. * This helps controlling the emissive effect without modifying the emissive color.
  48504. */
  48505. protected _emissiveIntensity: number;
  48506. /**
  48507. * Intensity of the environment e.g. how much the environment will light the object
  48508. * either through harmonics for rough material or through the refelction for shiny ones.
  48509. */
  48510. protected _environmentIntensity: number;
  48511. /**
  48512. * This is a special control allowing the reduction of the specular highlights coming from the
  48513. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48514. */
  48515. protected _specularIntensity: number;
  48516. /**
  48517. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48518. */
  48519. private _lightingInfos;
  48520. /**
  48521. * Debug Control allowing disabling the bump map on this material.
  48522. */
  48523. protected _disableBumpMap: boolean;
  48524. /**
  48525. * AKA Diffuse Texture in standard nomenclature.
  48526. */
  48527. protected _albedoTexture: Nullable<BaseTexture>;
  48528. /**
  48529. * AKA Occlusion Texture in other nomenclature.
  48530. */
  48531. protected _ambientTexture: Nullable<BaseTexture>;
  48532. /**
  48533. * AKA Occlusion Texture Intensity in other nomenclature.
  48534. */
  48535. protected _ambientTextureStrength: number;
  48536. /**
  48537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48538. * 1 means it completely occludes it
  48539. * 0 mean it has no impact
  48540. */
  48541. protected _ambientTextureImpactOnAnalyticalLights: number;
  48542. /**
  48543. * Stores the alpha values in a texture.
  48544. */
  48545. protected _opacityTexture: Nullable<BaseTexture>;
  48546. /**
  48547. * Stores the reflection values in a texture.
  48548. */
  48549. protected _reflectionTexture: Nullable<BaseTexture>;
  48550. /**
  48551. * Stores the emissive values in a texture.
  48552. */
  48553. protected _emissiveTexture: Nullable<BaseTexture>;
  48554. /**
  48555. * AKA Specular texture in other nomenclature.
  48556. */
  48557. protected _reflectivityTexture: Nullable<BaseTexture>;
  48558. /**
  48559. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48560. */
  48561. protected _metallicTexture: Nullable<BaseTexture>;
  48562. /**
  48563. * Specifies the metallic scalar of the metallic/roughness workflow.
  48564. * Can also be used to scale the metalness values of the metallic texture.
  48565. */
  48566. protected _metallic: Nullable<number>;
  48567. /**
  48568. * Specifies the roughness scalar of the metallic/roughness workflow.
  48569. * Can also be used to scale the roughness values of the metallic texture.
  48570. */
  48571. protected _roughness: Nullable<number>;
  48572. /**
  48573. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48574. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48575. */
  48576. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48577. /**
  48578. * Stores surface normal data used to displace a mesh in a texture.
  48579. */
  48580. protected _bumpTexture: Nullable<BaseTexture>;
  48581. /**
  48582. * Stores the pre-calculated light information of a mesh in a texture.
  48583. */
  48584. protected _lightmapTexture: Nullable<BaseTexture>;
  48585. /**
  48586. * The color of a material in ambient lighting.
  48587. */
  48588. protected _ambientColor: Color3;
  48589. /**
  48590. * AKA Diffuse Color in other nomenclature.
  48591. */
  48592. protected _albedoColor: Color3;
  48593. /**
  48594. * AKA Specular Color in other nomenclature.
  48595. */
  48596. protected _reflectivityColor: Color3;
  48597. /**
  48598. * The color applied when light is reflected from a material.
  48599. */
  48600. protected _reflectionColor: Color3;
  48601. /**
  48602. * The color applied when light is emitted from a material.
  48603. */
  48604. protected _emissiveColor: Color3;
  48605. /**
  48606. * AKA Glossiness in other nomenclature.
  48607. */
  48608. protected _microSurface: number;
  48609. /**
  48610. * Specifies that the material will use the light map as a show map.
  48611. */
  48612. protected _useLightmapAsShadowmap: boolean;
  48613. /**
  48614. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48615. * makes the reflect vector face the model (under horizon).
  48616. */
  48617. protected _useHorizonOcclusion: boolean;
  48618. /**
  48619. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48620. * too much the area relying on ambient texture to define their ambient occlusion.
  48621. */
  48622. protected _useRadianceOcclusion: boolean;
  48623. /**
  48624. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48625. */
  48626. protected _useAlphaFromAlbedoTexture: boolean;
  48627. /**
  48628. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48629. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48630. */
  48631. protected _useSpecularOverAlpha: boolean;
  48632. /**
  48633. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48634. */
  48635. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48636. /**
  48637. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48638. */
  48639. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48640. /**
  48641. * Specifies if the metallic texture contains the roughness information in its green channel.
  48642. */
  48643. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48644. /**
  48645. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48646. */
  48647. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48648. /**
  48649. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48650. */
  48651. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48652. /**
  48653. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48654. */
  48655. protected _useAmbientInGrayScale: boolean;
  48656. /**
  48657. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48658. * The material will try to infer what glossiness each pixel should be.
  48659. */
  48660. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48661. /**
  48662. * Defines the falloff type used in this material.
  48663. * It by default is Physical.
  48664. */
  48665. protected _lightFalloff: number;
  48666. /**
  48667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48669. */
  48670. protected _useRadianceOverAlpha: boolean;
  48671. /**
  48672. * Allows using an object space normal map (instead of tangent space).
  48673. */
  48674. protected _useObjectSpaceNormalMap: boolean;
  48675. /**
  48676. * Allows using the bump map in parallax mode.
  48677. */
  48678. protected _useParallax: boolean;
  48679. /**
  48680. * Allows using the bump map in parallax occlusion mode.
  48681. */
  48682. protected _useParallaxOcclusion: boolean;
  48683. /**
  48684. * Controls the scale bias of the parallax mode.
  48685. */
  48686. protected _parallaxScaleBias: number;
  48687. /**
  48688. * If sets to true, disables all the lights affecting the material.
  48689. */
  48690. protected _disableLighting: boolean;
  48691. /**
  48692. * Number of Simultaneous lights allowed on the material.
  48693. */
  48694. protected _maxSimultaneousLights: number;
  48695. /**
  48696. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48697. */
  48698. protected _invertNormalMapX: boolean;
  48699. /**
  48700. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48701. */
  48702. protected _invertNormalMapY: boolean;
  48703. /**
  48704. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48705. */
  48706. protected _twoSidedLighting: boolean;
  48707. /**
  48708. * Defines the alpha limits in alpha test mode.
  48709. */
  48710. protected _alphaCutOff: number;
  48711. /**
  48712. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48713. */
  48714. protected _forceAlphaTest: boolean;
  48715. /**
  48716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48717. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48718. */
  48719. protected _useAlphaFresnel: boolean;
  48720. /**
  48721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48722. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48723. */
  48724. protected _useLinearAlphaFresnel: boolean;
  48725. /**
  48726. * The transparency mode of the material.
  48727. */
  48728. protected _transparencyMode: Nullable<number>;
  48729. /**
  48730. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48731. * from cos thetav and roughness:
  48732. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48733. */
  48734. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48735. /**
  48736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48737. */
  48738. protected _forceIrradianceInFragment: boolean;
  48739. /**
  48740. * Force normal to face away from face.
  48741. */
  48742. protected _forceNormalForward: boolean;
  48743. /**
  48744. * Enables specular anti aliasing in the PBR shader.
  48745. * It will both interacts on the Geometry for analytical and IBL lighting.
  48746. * It also prefilter the roughness map based on the bump values.
  48747. */
  48748. protected _enableSpecularAntiAliasing: boolean;
  48749. /**
  48750. * Default configuration related to image processing available in the PBR Material.
  48751. */
  48752. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48753. /**
  48754. * Keep track of the image processing observer to allow dispose and replace.
  48755. */
  48756. private _imageProcessingObserver;
  48757. /**
  48758. * Attaches a new image processing configuration to the PBR Material.
  48759. * @param configuration
  48760. */
  48761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48762. /**
  48763. * Stores the available render targets.
  48764. */
  48765. private _renderTargets;
  48766. /**
  48767. * Sets the global ambient color for the material used in lighting calculations.
  48768. */
  48769. private _globalAmbientColor;
  48770. /**
  48771. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48772. */
  48773. private _useLogarithmicDepth;
  48774. /**
  48775. * If set to true, no lighting calculations will be applied.
  48776. */
  48777. private _unlit;
  48778. private _debugMode;
  48779. /**
  48780. * @hidden
  48781. * This is reserved for the inspector.
  48782. * Defines the material debug mode.
  48783. * It helps seeing only some components of the material while troubleshooting.
  48784. */
  48785. debugMode: number;
  48786. /**
  48787. * @hidden
  48788. * This is reserved for the inspector.
  48789. * Specify from where on screen the debug mode should start.
  48790. * The value goes from -1 (full screen) to 1 (not visible)
  48791. * It helps with side by side comparison against the final render
  48792. * This defaults to -1
  48793. */
  48794. private debugLimit;
  48795. /**
  48796. * @hidden
  48797. * This is reserved for the inspector.
  48798. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48799. * You can use the factor to better multiply the final value.
  48800. */
  48801. private debugFactor;
  48802. /**
  48803. * Defines the clear coat layer parameters for the material.
  48804. */
  48805. readonly clearCoat: PBRClearCoatConfiguration;
  48806. /**
  48807. * Defines the anisotropic parameters for the material.
  48808. */
  48809. readonly anisotropy: PBRAnisotropicConfiguration;
  48810. /**
  48811. * Defines the BRDF parameters for the material.
  48812. */
  48813. readonly brdf: PBRBRDFConfiguration;
  48814. /**
  48815. * Defines the Sheen parameters for the material.
  48816. */
  48817. readonly sheen: PBRSheenConfiguration;
  48818. /**
  48819. * Defines the SubSurface parameters for the material.
  48820. */
  48821. readonly subSurface: PBRSubSurfaceConfiguration;
  48822. /**
  48823. * Custom callback helping to override the default shader used in the material.
  48824. */
  48825. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48826. /**
  48827. * Instantiates a new PBRMaterial instance.
  48828. *
  48829. * @param name The material name
  48830. * @param scene The scene the material will be use in.
  48831. */
  48832. constructor(name: string, scene: Scene);
  48833. /**
  48834. * Gets a boolean indicating that current material needs to register RTT
  48835. */
  48836. readonly hasRenderTargetTextures: boolean;
  48837. /**
  48838. * Gets the name of the material class.
  48839. */
  48840. getClassName(): string;
  48841. /**
  48842. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48843. */
  48844. /**
  48845. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48846. */
  48847. useLogarithmicDepth: boolean;
  48848. /**
  48849. * Gets the current transparency mode.
  48850. */
  48851. /**
  48852. * Sets the transparency mode of the material.
  48853. *
  48854. * | Value | Type | Description |
  48855. * | ----- | ----------------------------------- | ----------- |
  48856. * | 0 | OPAQUE | |
  48857. * | 1 | ALPHATEST | |
  48858. * | 2 | ALPHABLEND | |
  48859. * | 3 | ALPHATESTANDBLEND | |
  48860. *
  48861. */
  48862. transparencyMode: Nullable<number>;
  48863. /**
  48864. * Returns true if alpha blending should be disabled.
  48865. */
  48866. private readonly _disableAlphaBlending;
  48867. /**
  48868. * Specifies whether or not this material should be rendered in alpha blend mode.
  48869. */
  48870. needAlphaBlending(): boolean;
  48871. /**
  48872. * Specifies if the mesh will require alpha blending.
  48873. * @param mesh - BJS mesh.
  48874. */
  48875. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48876. /**
  48877. * Specifies whether or not this material should be rendered in alpha test mode.
  48878. */
  48879. needAlphaTesting(): boolean;
  48880. /**
  48881. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48882. */
  48883. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48884. /**
  48885. * Gets the texture used for the alpha test.
  48886. */
  48887. getAlphaTestTexture(): Nullable<BaseTexture>;
  48888. /**
  48889. * Specifies that the submesh is ready to be used.
  48890. * @param mesh - BJS mesh.
  48891. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48892. * @param useInstances - Specifies that instances should be used.
  48893. * @returns - boolean indicating that the submesh is ready or not.
  48894. */
  48895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48896. /**
  48897. * Specifies if the material uses metallic roughness workflow.
  48898. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48899. */
  48900. isMetallicWorkflow(): boolean;
  48901. private _prepareEffect;
  48902. private _prepareDefines;
  48903. /**
  48904. * Force shader compilation
  48905. */
  48906. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48907. clipPlane: boolean;
  48908. }>): void;
  48909. /**
  48910. * Initializes the uniform buffer layout for the shader.
  48911. */
  48912. buildUniformLayout(): void;
  48913. /**
  48914. * Unbinds the material from the mesh
  48915. */
  48916. unbind(): void;
  48917. /**
  48918. * Binds the submesh data.
  48919. * @param world - The world matrix.
  48920. * @param mesh - The BJS mesh.
  48921. * @param subMesh - A submesh of the BJS mesh.
  48922. */
  48923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48924. /**
  48925. * Returns the animatable textures.
  48926. * @returns - Array of animatable textures.
  48927. */
  48928. getAnimatables(): IAnimatable[];
  48929. /**
  48930. * Returns the texture used for reflections.
  48931. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48932. */
  48933. private _getReflectionTexture;
  48934. /**
  48935. * Returns an array of the actively used textures.
  48936. * @returns - Array of BaseTextures
  48937. */
  48938. getActiveTextures(): BaseTexture[];
  48939. /**
  48940. * Checks to see if a texture is used in the material.
  48941. * @param texture - Base texture to use.
  48942. * @returns - Boolean specifying if a texture is used in the material.
  48943. */
  48944. hasTexture(texture: BaseTexture): boolean;
  48945. /**
  48946. * Disposes the resources of the material.
  48947. * @param forceDisposeEffect - Forces the disposal of effects.
  48948. * @param forceDisposeTextures - Forces the disposal of all textures.
  48949. */
  48950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48951. }
  48952. }
  48953. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48954. import { Nullable } from "babylonjs/types";
  48955. import { Scene } from "babylonjs/scene";
  48956. import { Color3 } from "babylonjs/Maths/math.color";
  48957. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48958. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48960. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48961. /**
  48962. * The Physically based material of BJS.
  48963. *
  48964. * This offers the main features of a standard PBR material.
  48965. * For more information, please refer to the documentation :
  48966. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48967. */
  48968. export class PBRMaterial extends PBRBaseMaterial {
  48969. /**
  48970. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48971. */
  48972. static readonly PBRMATERIAL_OPAQUE: number;
  48973. /**
  48974. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48975. */
  48976. static readonly PBRMATERIAL_ALPHATEST: number;
  48977. /**
  48978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48979. */
  48980. static readonly PBRMATERIAL_ALPHABLEND: number;
  48981. /**
  48982. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48983. * They are also discarded below the alpha cutoff threshold to improve performances.
  48984. */
  48985. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48986. /**
  48987. * Defines the default value of how much AO map is occluding the analytical lights
  48988. * (point spot...).
  48989. */
  48990. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48991. /**
  48992. * Intensity of the direct lights e.g. the four lights available in your scene.
  48993. * This impacts both the direct diffuse and specular highlights.
  48994. */
  48995. directIntensity: number;
  48996. /**
  48997. * Intensity of the emissive part of the material.
  48998. * This helps controlling the emissive effect without modifying the emissive color.
  48999. */
  49000. emissiveIntensity: number;
  49001. /**
  49002. * Intensity of the environment e.g. how much the environment will light the object
  49003. * either through harmonics for rough material or through the refelction for shiny ones.
  49004. */
  49005. environmentIntensity: number;
  49006. /**
  49007. * This is a special control allowing the reduction of the specular highlights coming from the
  49008. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49009. */
  49010. specularIntensity: number;
  49011. /**
  49012. * Debug Control allowing disabling the bump map on this material.
  49013. */
  49014. disableBumpMap: boolean;
  49015. /**
  49016. * AKA Diffuse Texture in standard nomenclature.
  49017. */
  49018. albedoTexture: BaseTexture;
  49019. /**
  49020. * AKA Occlusion Texture in other nomenclature.
  49021. */
  49022. ambientTexture: BaseTexture;
  49023. /**
  49024. * AKA Occlusion Texture Intensity in other nomenclature.
  49025. */
  49026. ambientTextureStrength: number;
  49027. /**
  49028. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49029. * 1 means it completely occludes it
  49030. * 0 mean it has no impact
  49031. */
  49032. ambientTextureImpactOnAnalyticalLights: number;
  49033. /**
  49034. * Stores the alpha values in a texture.
  49035. */
  49036. opacityTexture: BaseTexture;
  49037. /**
  49038. * Stores the reflection values in a texture.
  49039. */
  49040. reflectionTexture: Nullable<BaseTexture>;
  49041. /**
  49042. * Stores the emissive values in a texture.
  49043. */
  49044. emissiveTexture: BaseTexture;
  49045. /**
  49046. * AKA Specular texture in other nomenclature.
  49047. */
  49048. reflectivityTexture: BaseTexture;
  49049. /**
  49050. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49051. */
  49052. metallicTexture: BaseTexture;
  49053. /**
  49054. * Specifies the metallic scalar of the metallic/roughness workflow.
  49055. * Can also be used to scale the metalness values of the metallic texture.
  49056. */
  49057. metallic: Nullable<number>;
  49058. /**
  49059. * Specifies the roughness scalar of the metallic/roughness workflow.
  49060. * Can also be used to scale the roughness values of the metallic texture.
  49061. */
  49062. roughness: Nullable<number>;
  49063. /**
  49064. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49065. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49066. */
  49067. microSurfaceTexture: BaseTexture;
  49068. /**
  49069. * Stores surface normal data used to displace a mesh in a texture.
  49070. */
  49071. bumpTexture: BaseTexture;
  49072. /**
  49073. * Stores the pre-calculated light information of a mesh in a texture.
  49074. */
  49075. lightmapTexture: BaseTexture;
  49076. /**
  49077. * Stores the refracted light information in a texture.
  49078. */
  49079. refractionTexture: Nullable<BaseTexture>;
  49080. /**
  49081. * The color of a material in ambient lighting.
  49082. */
  49083. ambientColor: Color3;
  49084. /**
  49085. * AKA Diffuse Color in other nomenclature.
  49086. */
  49087. albedoColor: Color3;
  49088. /**
  49089. * AKA Specular Color in other nomenclature.
  49090. */
  49091. reflectivityColor: Color3;
  49092. /**
  49093. * The color reflected from the material.
  49094. */
  49095. reflectionColor: Color3;
  49096. /**
  49097. * The color emitted from the material.
  49098. */
  49099. emissiveColor: Color3;
  49100. /**
  49101. * AKA Glossiness in other nomenclature.
  49102. */
  49103. microSurface: number;
  49104. /**
  49105. * source material index of refraction (IOR)' / 'destination material IOR.
  49106. */
  49107. indexOfRefraction: number;
  49108. /**
  49109. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49110. */
  49111. invertRefractionY: boolean;
  49112. /**
  49113. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49114. * Materials half opaque for instance using refraction could benefit from this control.
  49115. */
  49116. linkRefractionWithTransparency: boolean;
  49117. /**
  49118. * If true, the light map contains occlusion information instead of lighting info.
  49119. */
  49120. useLightmapAsShadowmap: boolean;
  49121. /**
  49122. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49123. */
  49124. useAlphaFromAlbedoTexture: boolean;
  49125. /**
  49126. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49127. */
  49128. forceAlphaTest: boolean;
  49129. /**
  49130. * Defines the alpha limits in alpha test mode.
  49131. */
  49132. alphaCutOff: number;
  49133. /**
  49134. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49135. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49136. */
  49137. useSpecularOverAlpha: boolean;
  49138. /**
  49139. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49140. */
  49141. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49142. /**
  49143. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49144. */
  49145. useRoughnessFromMetallicTextureAlpha: boolean;
  49146. /**
  49147. * Specifies if the metallic texture contains the roughness information in its green channel.
  49148. */
  49149. useRoughnessFromMetallicTextureGreen: boolean;
  49150. /**
  49151. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49152. */
  49153. useMetallnessFromMetallicTextureBlue: boolean;
  49154. /**
  49155. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49156. */
  49157. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49158. /**
  49159. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49160. */
  49161. useAmbientInGrayScale: boolean;
  49162. /**
  49163. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49164. * The material will try to infer what glossiness each pixel should be.
  49165. */
  49166. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49167. /**
  49168. * BJS is using an harcoded light falloff based on a manually sets up range.
  49169. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49170. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49171. */
  49172. /**
  49173. * BJS is using an harcoded light falloff based on a manually sets up range.
  49174. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49175. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49176. */
  49177. usePhysicalLightFalloff: boolean;
  49178. /**
  49179. * In order to support the falloff compatibility with gltf, a special mode has been added
  49180. * to reproduce the gltf light falloff.
  49181. */
  49182. /**
  49183. * In order to support the falloff compatibility with gltf, a special mode has been added
  49184. * to reproduce the gltf light falloff.
  49185. */
  49186. useGLTFLightFalloff: boolean;
  49187. /**
  49188. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49189. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49190. */
  49191. useRadianceOverAlpha: boolean;
  49192. /**
  49193. * Allows using an object space normal map (instead of tangent space).
  49194. */
  49195. useObjectSpaceNormalMap: boolean;
  49196. /**
  49197. * Allows using the bump map in parallax mode.
  49198. */
  49199. useParallax: boolean;
  49200. /**
  49201. * Allows using the bump map in parallax occlusion mode.
  49202. */
  49203. useParallaxOcclusion: boolean;
  49204. /**
  49205. * Controls the scale bias of the parallax mode.
  49206. */
  49207. parallaxScaleBias: number;
  49208. /**
  49209. * If sets to true, disables all the lights affecting the material.
  49210. */
  49211. disableLighting: boolean;
  49212. /**
  49213. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49214. */
  49215. forceIrradianceInFragment: boolean;
  49216. /**
  49217. * Number of Simultaneous lights allowed on the material.
  49218. */
  49219. maxSimultaneousLights: number;
  49220. /**
  49221. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49222. */
  49223. invertNormalMapX: boolean;
  49224. /**
  49225. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49226. */
  49227. invertNormalMapY: boolean;
  49228. /**
  49229. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49230. */
  49231. twoSidedLighting: boolean;
  49232. /**
  49233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49234. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49235. */
  49236. useAlphaFresnel: boolean;
  49237. /**
  49238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49239. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49240. */
  49241. useLinearAlphaFresnel: boolean;
  49242. /**
  49243. * Let user defines the brdf lookup texture used for IBL.
  49244. * A default 8bit version is embedded but you could point at :
  49245. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49246. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49247. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49248. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49249. */
  49250. environmentBRDFTexture: Nullable<BaseTexture>;
  49251. /**
  49252. * Force normal to face away from face.
  49253. */
  49254. forceNormalForward: boolean;
  49255. /**
  49256. * Enables specular anti aliasing in the PBR shader.
  49257. * It will both interacts on the Geometry for analytical and IBL lighting.
  49258. * It also prefilter the roughness map based on the bump values.
  49259. */
  49260. enableSpecularAntiAliasing: boolean;
  49261. /**
  49262. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49263. * makes the reflect vector face the model (under horizon).
  49264. */
  49265. useHorizonOcclusion: boolean;
  49266. /**
  49267. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49268. * too much the area relying on ambient texture to define their ambient occlusion.
  49269. */
  49270. useRadianceOcclusion: boolean;
  49271. /**
  49272. * If set to true, no lighting calculations will be applied.
  49273. */
  49274. unlit: boolean;
  49275. /**
  49276. * Gets the image processing configuration used either in this material.
  49277. */
  49278. /**
  49279. * Sets the Default image processing configuration used either in the this material.
  49280. *
  49281. * If sets to null, the scene one is in use.
  49282. */
  49283. imageProcessingConfiguration: ImageProcessingConfiguration;
  49284. /**
  49285. * Gets wether the color curves effect is enabled.
  49286. */
  49287. /**
  49288. * Sets wether the color curves effect is enabled.
  49289. */
  49290. cameraColorCurvesEnabled: boolean;
  49291. /**
  49292. * Gets wether the color grading effect is enabled.
  49293. */
  49294. /**
  49295. * Gets wether the color grading effect is enabled.
  49296. */
  49297. cameraColorGradingEnabled: boolean;
  49298. /**
  49299. * Gets wether tonemapping is enabled or not.
  49300. */
  49301. /**
  49302. * Sets wether tonemapping is enabled or not
  49303. */
  49304. cameraToneMappingEnabled: boolean;
  49305. /**
  49306. * The camera exposure used on this material.
  49307. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49308. * This corresponds to a photographic exposure.
  49309. */
  49310. /**
  49311. * The camera exposure used on this material.
  49312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49313. * This corresponds to a photographic exposure.
  49314. */
  49315. cameraExposure: number;
  49316. /**
  49317. * Gets The camera contrast used on this material.
  49318. */
  49319. /**
  49320. * Sets The camera contrast used on this material.
  49321. */
  49322. cameraContrast: number;
  49323. /**
  49324. * Gets the Color Grading 2D Lookup Texture.
  49325. */
  49326. /**
  49327. * Sets the Color Grading 2D Lookup Texture.
  49328. */
  49329. cameraColorGradingTexture: Nullable<BaseTexture>;
  49330. /**
  49331. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49332. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49333. * 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;
  49334. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49335. */
  49336. /**
  49337. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49338. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49339. * 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;
  49340. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49341. */
  49342. cameraColorCurves: Nullable<ColorCurves>;
  49343. /**
  49344. * Instantiates a new PBRMaterial instance.
  49345. *
  49346. * @param name The material name
  49347. * @param scene The scene the material will be use in.
  49348. */
  49349. constructor(name: string, scene: Scene);
  49350. /**
  49351. * Returns the name of this material class.
  49352. */
  49353. getClassName(): string;
  49354. /**
  49355. * Makes a duplicate of the current material.
  49356. * @param name - name to use for the new material.
  49357. */
  49358. clone(name: string): PBRMaterial;
  49359. /**
  49360. * Serializes this PBR Material.
  49361. * @returns - An object with the serialized material.
  49362. */
  49363. serialize(): any;
  49364. /**
  49365. * Parses a PBR Material from a serialized object.
  49366. * @param source - Serialized object.
  49367. * @param scene - BJS scene instance.
  49368. * @param rootUrl - url for the scene object
  49369. * @returns - PBRMaterial
  49370. */
  49371. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49372. }
  49373. }
  49374. declare module "babylonjs/Misc/dds" {
  49375. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49376. import { Engine } from "babylonjs/Engines/engine";
  49377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49378. import { Nullable } from "babylonjs/types";
  49379. import { Scene } from "babylonjs/scene";
  49380. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49381. /**
  49382. * Direct draw surface info
  49383. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49384. */
  49385. export interface DDSInfo {
  49386. /**
  49387. * Width of the texture
  49388. */
  49389. width: number;
  49390. /**
  49391. * Width of the texture
  49392. */
  49393. height: number;
  49394. /**
  49395. * Number of Mipmaps for the texture
  49396. * @see https://en.wikipedia.org/wiki/Mipmap
  49397. */
  49398. mipmapCount: number;
  49399. /**
  49400. * If the textures format is a known fourCC format
  49401. * @see https://www.fourcc.org/
  49402. */
  49403. isFourCC: boolean;
  49404. /**
  49405. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49406. */
  49407. isRGB: boolean;
  49408. /**
  49409. * If the texture is a lumincance format
  49410. */
  49411. isLuminance: boolean;
  49412. /**
  49413. * If this is a cube texture
  49414. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49415. */
  49416. isCube: boolean;
  49417. /**
  49418. * If the texture is a compressed format eg. FOURCC_DXT1
  49419. */
  49420. isCompressed: boolean;
  49421. /**
  49422. * The dxgiFormat of the texture
  49423. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49424. */
  49425. dxgiFormat: number;
  49426. /**
  49427. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49428. */
  49429. textureType: number;
  49430. /**
  49431. * Sphericle polynomial created for the dds texture
  49432. */
  49433. sphericalPolynomial?: SphericalPolynomial;
  49434. }
  49435. /**
  49436. * Class used to provide DDS decompression tools
  49437. */
  49438. export class DDSTools {
  49439. /**
  49440. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49441. */
  49442. static StoreLODInAlphaChannel: boolean;
  49443. /**
  49444. * Gets DDS information from an array buffer
  49445. * @param arrayBuffer defines the array buffer to read data from
  49446. * @returns the DDS information
  49447. */
  49448. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49449. private static _FloatView;
  49450. private static _Int32View;
  49451. private static _ToHalfFloat;
  49452. private static _FromHalfFloat;
  49453. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49454. private static _GetHalfFloatRGBAArrayBuffer;
  49455. private static _GetFloatRGBAArrayBuffer;
  49456. private static _GetFloatAsUIntRGBAArrayBuffer;
  49457. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49458. private static _GetRGBAArrayBuffer;
  49459. private static _ExtractLongWordOrder;
  49460. private static _GetRGBArrayBuffer;
  49461. private static _GetLuminanceArrayBuffer;
  49462. /**
  49463. * Uploads DDS Levels to a Babylon Texture
  49464. * @hidden
  49465. */
  49466. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49467. }
  49468. module "babylonjs/Engines/engine" {
  49469. interface Engine {
  49470. /**
  49471. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49472. * @param rootUrl defines the url where the file to load is located
  49473. * @param scene defines the current scene
  49474. * @param lodScale defines scale to apply to the mip map selection
  49475. * @param lodOffset defines offset to apply to the mip map selection
  49476. * @param onLoad defines an optional callback raised when the texture is loaded
  49477. * @param onError defines an optional callback raised if there is an issue to load the texture
  49478. * @param format defines the format of the data
  49479. * @param forcedExtension defines the extension to use to pick the right loader
  49480. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49481. * @returns the cube texture as an InternalTexture
  49482. */
  49483. 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;
  49484. }
  49485. }
  49486. }
  49487. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49488. import { Nullable } from "babylonjs/types";
  49489. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49490. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49491. /**
  49492. * Implementation of the DDS Texture Loader.
  49493. * @hidden
  49494. */
  49495. export class _DDSTextureLoader implements IInternalTextureLoader {
  49496. /**
  49497. * Defines wether the loader supports cascade loading the different faces.
  49498. */
  49499. readonly supportCascades: boolean;
  49500. /**
  49501. * This returns if the loader support the current file information.
  49502. * @param extension defines the file extension of the file being loaded
  49503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49504. * @param fallback defines the fallback internal texture if any
  49505. * @param isBase64 defines whether the texture is encoded as a base64
  49506. * @param isBuffer defines whether the texture data are stored as a buffer
  49507. * @returns true if the loader can load the specified file
  49508. */
  49509. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49510. /**
  49511. * Transform the url before loading if required.
  49512. * @param rootUrl the url of the texture
  49513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49514. * @returns the transformed texture
  49515. */
  49516. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49517. /**
  49518. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49519. * @param rootUrl the url of the texture
  49520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49521. * @returns the fallback texture
  49522. */
  49523. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49524. /**
  49525. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49526. * @param data contains the texture data
  49527. * @param texture defines the BabylonJS internal texture
  49528. * @param createPolynomials will be true if polynomials have been requested
  49529. * @param onLoad defines the callback to trigger once the texture is ready
  49530. * @param onError defines the callback to trigger in case of error
  49531. */
  49532. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49533. /**
  49534. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49535. * @param data contains the texture data
  49536. * @param texture defines the BabylonJS internal texture
  49537. * @param callback defines the method to call once ready to upload
  49538. */
  49539. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49540. }
  49541. }
  49542. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49544. /** @hidden */
  49545. export var rgbdEncodePixelShader: {
  49546. name: string;
  49547. shader: string;
  49548. };
  49549. }
  49550. declare module "babylonjs/Misc/environmentTextureTools" {
  49551. import { Nullable } from "babylonjs/types";
  49552. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49554. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49555. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49556. import "babylonjs/Shaders/rgbdEncode.fragment";
  49557. import "babylonjs/Shaders/rgbdDecode.fragment";
  49558. /**
  49559. * Raw texture data and descriptor sufficient for WebGL texture upload
  49560. */
  49561. export interface EnvironmentTextureInfo {
  49562. /**
  49563. * Version of the environment map
  49564. */
  49565. version: number;
  49566. /**
  49567. * Width of image
  49568. */
  49569. width: number;
  49570. /**
  49571. * Irradiance information stored in the file.
  49572. */
  49573. irradiance: any;
  49574. /**
  49575. * Specular information stored in the file.
  49576. */
  49577. specular: any;
  49578. }
  49579. /**
  49580. * Sets of helpers addressing the serialization and deserialization of environment texture
  49581. * stored in a BabylonJS env file.
  49582. * Those files are usually stored as .env files.
  49583. */
  49584. export class EnvironmentTextureTools {
  49585. /**
  49586. * Magic number identifying the env file.
  49587. */
  49588. private static _MagicBytes;
  49589. /**
  49590. * Gets the environment info from an env file.
  49591. * @param data The array buffer containing the .env bytes.
  49592. * @returns the environment file info (the json header) if successfully parsed.
  49593. */
  49594. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49595. /**
  49596. * Creates an environment texture from a loaded cube texture.
  49597. * @param texture defines the cube texture to convert in env file
  49598. * @return a promise containing the environment data if succesfull.
  49599. */
  49600. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49601. /**
  49602. * Creates a JSON representation of the spherical data.
  49603. * @param texture defines the texture containing the polynomials
  49604. * @return the JSON representation of the spherical info
  49605. */
  49606. private static _CreateEnvTextureIrradiance;
  49607. /**
  49608. * Uploads the texture info contained in the env file to the GPU.
  49609. * @param texture defines the internal texture to upload to
  49610. * @param arrayBuffer defines the buffer cotaining the data to load
  49611. * @param info defines the texture info retrieved through the GetEnvInfo method
  49612. * @returns a promise
  49613. */
  49614. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49615. /**
  49616. * Uploads the levels of image data to the GPU.
  49617. * @param texture defines the internal texture to upload to
  49618. * @param imageData defines the array buffer views of image data [mipmap][face]
  49619. * @returns a promise
  49620. */
  49621. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49622. /**
  49623. * Uploads spherical polynomials information to the texture.
  49624. * @param texture defines the texture we are trying to upload the information to
  49625. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49626. */
  49627. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49628. /** @hidden */
  49629. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49630. }
  49631. }
  49632. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49633. import { Nullable } from "babylonjs/types";
  49634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49635. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49636. /**
  49637. * Implementation of the ENV Texture Loader.
  49638. * @hidden
  49639. */
  49640. export class _ENVTextureLoader implements IInternalTextureLoader {
  49641. /**
  49642. * Defines wether the loader supports cascade loading the different faces.
  49643. */
  49644. readonly supportCascades: boolean;
  49645. /**
  49646. * This returns if the loader support the current file information.
  49647. * @param extension defines the file extension of the file being loaded
  49648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49649. * @param fallback defines the fallback internal texture if any
  49650. * @param isBase64 defines whether the texture is encoded as a base64
  49651. * @param isBuffer defines whether the texture data are stored as a buffer
  49652. * @returns true if the loader can load the specified file
  49653. */
  49654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49655. /**
  49656. * Transform the url before loading if required.
  49657. * @param rootUrl the url of the texture
  49658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49659. * @returns the transformed texture
  49660. */
  49661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49662. /**
  49663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49664. * @param rootUrl the url of the texture
  49665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49666. * @returns the fallback texture
  49667. */
  49668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49669. /**
  49670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49671. * @param data contains the texture data
  49672. * @param texture defines the BabylonJS internal texture
  49673. * @param createPolynomials will be true if polynomials have been requested
  49674. * @param onLoad defines the callback to trigger once the texture is ready
  49675. * @param onError defines the callback to trigger in case of error
  49676. */
  49677. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49678. /**
  49679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49680. * @param data contains the texture data
  49681. * @param texture defines the BabylonJS internal texture
  49682. * @param callback defines the method to call once ready to upload
  49683. */
  49684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49685. }
  49686. }
  49687. declare module "babylonjs/Misc/khronosTextureContainer" {
  49688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49689. /**
  49690. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49691. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49692. */
  49693. export class KhronosTextureContainer {
  49694. /** contents of the KTX container file */
  49695. arrayBuffer: any;
  49696. private static HEADER_LEN;
  49697. private static COMPRESSED_2D;
  49698. private static COMPRESSED_3D;
  49699. private static TEX_2D;
  49700. private static TEX_3D;
  49701. /**
  49702. * Gets the openGL type
  49703. */
  49704. glType: number;
  49705. /**
  49706. * Gets the openGL type size
  49707. */
  49708. glTypeSize: number;
  49709. /**
  49710. * Gets the openGL format
  49711. */
  49712. glFormat: number;
  49713. /**
  49714. * Gets the openGL internal format
  49715. */
  49716. glInternalFormat: number;
  49717. /**
  49718. * Gets the base internal format
  49719. */
  49720. glBaseInternalFormat: number;
  49721. /**
  49722. * Gets image width in pixel
  49723. */
  49724. pixelWidth: number;
  49725. /**
  49726. * Gets image height in pixel
  49727. */
  49728. pixelHeight: number;
  49729. /**
  49730. * Gets image depth in pixels
  49731. */
  49732. pixelDepth: number;
  49733. /**
  49734. * Gets the number of array elements
  49735. */
  49736. numberOfArrayElements: number;
  49737. /**
  49738. * Gets the number of faces
  49739. */
  49740. numberOfFaces: number;
  49741. /**
  49742. * Gets the number of mipmap levels
  49743. */
  49744. numberOfMipmapLevels: number;
  49745. /**
  49746. * Gets the bytes of key value data
  49747. */
  49748. bytesOfKeyValueData: number;
  49749. /**
  49750. * Gets the load type
  49751. */
  49752. loadType: number;
  49753. /**
  49754. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49755. */
  49756. isInvalid: boolean;
  49757. /**
  49758. * Creates a new KhronosTextureContainer
  49759. * @param arrayBuffer contents of the KTX container file
  49760. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49761. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49762. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49763. */
  49764. constructor(
  49765. /** contents of the KTX container file */
  49766. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49767. /**
  49768. * Uploads KTX content to a Babylon Texture.
  49769. * It is assumed that the texture has already been created & is currently bound
  49770. * @hidden
  49771. */
  49772. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49773. private _upload2DCompressedLevels;
  49774. }
  49775. }
  49776. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49777. import { Nullable } from "babylonjs/types";
  49778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49779. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49780. /**
  49781. * Implementation of the KTX Texture Loader.
  49782. * @hidden
  49783. */
  49784. export class _KTXTextureLoader implements IInternalTextureLoader {
  49785. /**
  49786. * Defines wether the loader supports cascade loading the different faces.
  49787. */
  49788. readonly supportCascades: boolean;
  49789. /**
  49790. * This returns if the loader support the current file information.
  49791. * @param extension defines the file extension of the file being loaded
  49792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49793. * @param fallback defines the fallback internal texture if any
  49794. * @param isBase64 defines whether the texture is encoded as a base64
  49795. * @param isBuffer defines whether the texture data are stored as a buffer
  49796. * @returns true if the loader can load the specified file
  49797. */
  49798. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49799. /**
  49800. * Transform the url before loading if required.
  49801. * @param rootUrl the url of the texture
  49802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49803. * @returns the transformed texture
  49804. */
  49805. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49806. /**
  49807. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49808. * @param rootUrl the url of the texture
  49809. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49810. * @returns the fallback texture
  49811. */
  49812. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49813. /**
  49814. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49815. * @param data contains the texture data
  49816. * @param texture defines the BabylonJS internal texture
  49817. * @param createPolynomials will be true if polynomials have been requested
  49818. * @param onLoad defines the callback to trigger once the texture is ready
  49819. * @param onError defines the callback to trigger in case of error
  49820. */
  49821. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49822. /**
  49823. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49824. * @param data contains the texture data
  49825. * @param texture defines the BabylonJS internal texture
  49826. * @param callback defines the method to call once ready to upload
  49827. */
  49828. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49829. }
  49830. }
  49831. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49832. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49833. import { Scene } from "babylonjs/scene";
  49834. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49835. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49836. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49837. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49838. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49839. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49841. /**
  49842. * Options for the default xr helper
  49843. */
  49844. export class WebXRDefaultExperienceOptions {
  49845. /**
  49846. * Floor meshes that should be used for teleporting
  49847. */
  49848. floorMeshes: Array<AbstractMesh>;
  49849. }
  49850. /**
  49851. * Default experience which provides a similar setup to the previous webVRExperience
  49852. */
  49853. export class WebXRDefaultExperience {
  49854. /**
  49855. * Base experience
  49856. */
  49857. baseExperience: WebXRExperienceHelper;
  49858. /**
  49859. * Input experience extension
  49860. */
  49861. input: WebXRInput;
  49862. /**
  49863. * Loads the controller models
  49864. */
  49865. controllerModelLoader: WebXRControllerModelLoader;
  49866. /**
  49867. * Enables laser pointer and selection
  49868. */
  49869. pointerSelection: WebXRControllerPointerSelection;
  49870. /**
  49871. * Enables teleportation
  49872. */
  49873. teleportation: WebXRControllerTeleportation;
  49874. /**
  49875. * Enables ui for enetering/exiting xr
  49876. */
  49877. enterExitUI: WebXREnterExitUI;
  49878. /**
  49879. * Default output canvas xr should render to
  49880. */
  49881. outputCanvas: WebXRManagedOutputCanvas;
  49882. /**
  49883. * Creates the default xr experience
  49884. * @param scene scene
  49885. * @param options options for basic configuration
  49886. * @returns resulting WebXRDefaultExperience
  49887. */
  49888. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49889. private constructor();
  49890. /**
  49891. * DIsposes of the experience helper
  49892. */
  49893. dispose(): void;
  49894. }
  49895. }
  49896. declare module "babylonjs/Helpers/sceneHelpers" {
  49897. import { Nullable } from "babylonjs/types";
  49898. import { Mesh } from "babylonjs/Meshes/mesh";
  49899. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49900. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49901. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49902. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49903. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49904. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49905. import "babylonjs/Meshes/Builders/boxBuilder";
  49906. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49907. /** @hidden */
  49908. export var _forceSceneHelpersToBundle: boolean;
  49909. module "babylonjs/scene" {
  49910. interface Scene {
  49911. /**
  49912. * Creates a default light for the scene.
  49913. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49914. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49915. */
  49916. createDefaultLight(replace?: boolean): void;
  49917. /**
  49918. * Creates a default camera for the scene.
  49919. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49920. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49921. * @param replace has default false, when true replaces the active camera in the scene
  49922. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49923. */
  49924. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49925. /**
  49926. * Creates a default camera and a default light.
  49927. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49928. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49929. * @param replace has the default false, when true replaces the active camera/light in the scene
  49930. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49931. */
  49932. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49933. /**
  49934. * Creates a new sky box
  49935. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49936. * @param environmentTexture defines the texture to use as environment texture
  49937. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49938. * @param scale defines the overall scale of the skybox
  49939. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49940. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49941. * @returns a new mesh holding the sky box
  49942. */
  49943. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49944. /**
  49945. * Creates a new environment
  49946. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49947. * @param options defines the options you can use to configure the environment
  49948. * @returns the new EnvironmentHelper
  49949. */
  49950. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49951. /**
  49952. * Creates a new VREXperienceHelper
  49953. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49954. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49955. * @returns a new VREXperienceHelper
  49956. */
  49957. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49958. /**
  49959. * Creates a new WebXRDefaultExperience
  49960. * @see http://doc.babylonjs.com/how_to/webxr
  49961. * @param options experience options
  49962. * @returns a promise for a new WebXRDefaultExperience
  49963. */
  49964. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49965. }
  49966. }
  49967. }
  49968. declare module "babylonjs/Maths/math.vertexFormat" {
  49969. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49970. /**
  49971. * Contains position and normal vectors for a vertex
  49972. */
  49973. export class PositionNormalVertex {
  49974. /** the position of the vertex (defaut: 0,0,0) */
  49975. position: Vector3;
  49976. /** the normal of the vertex (defaut: 0,1,0) */
  49977. normal: Vector3;
  49978. /**
  49979. * Creates a PositionNormalVertex
  49980. * @param position the position of the vertex (defaut: 0,0,0)
  49981. * @param normal the normal of the vertex (defaut: 0,1,0)
  49982. */
  49983. constructor(
  49984. /** the position of the vertex (defaut: 0,0,0) */
  49985. position?: Vector3,
  49986. /** the normal of the vertex (defaut: 0,1,0) */
  49987. normal?: Vector3);
  49988. /**
  49989. * Clones the PositionNormalVertex
  49990. * @returns the cloned PositionNormalVertex
  49991. */
  49992. clone(): PositionNormalVertex;
  49993. }
  49994. /**
  49995. * Contains position, normal and uv vectors for a vertex
  49996. */
  49997. export class PositionNormalTextureVertex {
  49998. /** the position of the vertex (defaut: 0,0,0) */
  49999. position: Vector3;
  50000. /** the normal of the vertex (defaut: 0,1,0) */
  50001. normal: Vector3;
  50002. /** the uv of the vertex (default: 0,0) */
  50003. uv: Vector2;
  50004. /**
  50005. * Creates a PositionNormalTextureVertex
  50006. * @param position the position of the vertex (defaut: 0,0,0)
  50007. * @param normal the normal of the vertex (defaut: 0,1,0)
  50008. * @param uv the uv of the vertex (default: 0,0)
  50009. */
  50010. constructor(
  50011. /** the position of the vertex (defaut: 0,0,0) */
  50012. position?: Vector3,
  50013. /** the normal of the vertex (defaut: 0,1,0) */
  50014. normal?: Vector3,
  50015. /** the uv of the vertex (default: 0,0) */
  50016. uv?: Vector2);
  50017. /**
  50018. * Clones the PositionNormalTextureVertex
  50019. * @returns the cloned PositionNormalTextureVertex
  50020. */
  50021. clone(): PositionNormalTextureVertex;
  50022. }
  50023. }
  50024. declare module "babylonjs/Maths/math" {
  50025. export * from "babylonjs/Maths/math.axis";
  50026. export * from "babylonjs/Maths/math.color";
  50027. export * from "babylonjs/Maths/math.constants";
  50028. export * from "babylonjs/Maths/math.frustum";
  50029. export * from "babylonjs/Maths/math.path";
  50030. export * from "babylonjs/Maths/math.plane";
  50031. export * from "babylonjs/Maths/math.size";
  50032. export * from "babylonjs/Maths/math.vector";
  50033. export * from "babylonjs/Maths/math.vertexFormat";
  50034. export * from "babylonjs/Maths/math.viewport";
  50035. }
  50036. declare module "babylonjs/Helpers/videoDome" {
  50037. import { Scene } from "babylonjs/scene";
  50038. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50039. import { Mesh } from "babylonjs/Meshes/mesh";
  50040. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50041. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50042. import "babylonjs/Meshes/Builders/sphereBuilder";
  50043. /**
  50044. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50045. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50046. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50047. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50048. */
  50049. export class VideoDome extends TransformNode {
  50050. /**
  50051. * Define the video source as a Monoscopic panoramic 360 video.
  50052. */
  50053. static readonly MODE_MONOSCOPIC: number;
  50054. /**
  50055. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50056. */
  50057. static readonly MODE_TOPBOTTOM: number;
  50058. /**
  50059. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50060. */
  50061. static readonly MODE_SIDEBYSIDE: number;
  50062. private _halfDome;
  50063. private _useDirectMapping;
  50064. /**
  50065. * The video texture being displayed on the sphere
  50066. */
  50067. protected _videoTexture: VideoTexture;
  50068. /**
  50069. * Gets the video texture being displayed on the sphere
  50070. */
  50071. readonly videoTexture: VideoTexture;
  50072. /**
  50073. * The skybox material
  50074. */
  50075. protected _material: BackgroundMaterial;
  50076. /**
  50077. * The surface used for the skybox
  50078. */
  50079. protected _mesh: Mesh;
  50080. /**
  50081. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50082. */
  50083. private _halfDomeMask;
  50084. /**
  50085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50086. * Also see the options.resolution property.
  50087. */
  50088. fovMultiplier: number;
  50089. private _videoMode;
  50090. /**
  50091. * Gets or set the current video mode for the video. It can be:
  50092. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50093. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50094. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50095. */
  50096. videoMode: number;
  50097. /**
  50098. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50099. *
  50100. */
  50101. /**
  50102. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50103. */
  50104. halfDome: boolean;
  50105. /**
  50106. * Oberserver used in Stereoscopic VR Mode.
  50107. */
  50108. private _onBeforeCameraRenderObserver;
  50109. /**
  50110. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50111. * @param name Element's name, child elements will append suffixes for their own names.
  50112. * @param urlsOrVideo defines the url(s) or the video element to use
  50113. * @param options An object containing optional or exposed sub element properties
  50114. */
  50115. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50116. resolution?: number;
  50117. clickToPlay?: boolean;
  50118. autoPlay?: boolean;
  50119. loop?: boolean;
  50120. size?: number;
  50121. poster?: string;
  50122. faceForward?: boolean;
  50123. useDirectMapping?: boolean;
  50124. halfDomeMode?: boolean;
  50125. }, scene: Scene);
  50126. private _changeVideoMode;
  50127. /**
  50128. * Releases resources associated with this node.
  50129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50131. */
  50132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50133. }
  50134. }
  50135. declare module "babylonjs/Helpers/index" {
  50136. export * from "babylonjs/Helpers/environmentHelper";
  50137. export * from "babylonjs/Helpers/photoDome";
  50138. export * from "babylonjs/Helpers/sceneHelpers";
  50139. export * from "babylonjs/Helpers/videoDome";
  50140. }
  50141. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50142. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50143. import { IDisposable } from "babylonjs/scene";
  50144. import { Engine } from "babylonjs/Engines/engine";
  50145. /**
  50146. * This class can be used to get instrumentation data from a Babylon engine
  50147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50148. */
  50149. export class EngineInstrumentation implements IDisposable {
  50150. /**
  50151. * Define the instrumented engine.
  50152. */
  50153. engine: Engine;
  50154. private _captureGPUFrameTime;
  50155. private _gpuFrameTimeToken;
  50156. private _gpuFrameTime;
  50157. private _captureShaderCompilationTime;
  50158. private _shaderCompilationTime;
  50159. private _onBeginFrameObserver;
  50160. private _onEndFrameObserver;
  50161. private _onBeforeShaderCompilationObserver;
  50162. private _onAfterShaderCompilationObserver;
  50163. /**
  50164. * Gets the perf counter used for GPU frame time
  50165. */
  50166. readonly gpuFrameTimeCounter: PerfCounter;
  50167. /**
  50168. * Gets the GPU frame time capture status
  50169. */
  50170. /**
  50171. * Enable or disable the GPU frame time capture
  50172. */
  50173. captureGPUFrameTime: boolean;
  50174. /**
  50175. * Gets the perf counter used for shader compilation time
  50176. */
  50177. readonly shaderCompilationTimeCounter: PerfCounter;
  50178. /**
  50179. * Gets the shader compilation time capture status
  50180. */
  50181. /**
  50182. * Enable or disable the shader compilation time capture
  50183. */
  50184. captureShaderCompilationTime: boolean;
  50185. /**
  50186. * Instantiates a new engine instrumentation.
  50187. * This class can be used to get instrumentation data from a Babylon engine
  50188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50189. * @param engine Defines the engine to instrument
  50190. */
  50191. constructor(
  50192. /**
  50193. * Define the instrumented engine.
  50194. */
  50195. engine: Engine);
  50196. /**
  50197. * Dispose and release associated resources.
  50198. */
  50199. dispose(): void;
  50200. }
  50201. }
  50202. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50203. import { Scene, IDisposable } from "babylonjs/scene";
  50204. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50205. /**
  50206. * This class can be used to get instrumentation data from a Babylon engine
  50207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50208. */
  50209. export class SceneInstrumentation implements IDisposable {
  50210. /**
  50211. * Defines the scene to instrument
  50212. */
  50213. scene: Scene;
  50214. private _captureActiveMeshesEvaluationTime;
  50215. private _activeMeshesEvaluationTime;
  50216. private _captureRenderTargetsRenderTime;
  50217. private _renderTargetsRenderTime;
  50218. private _captureFrameTime;
  50219. private _frameTime;
  50220. private _captureRenderTime;
  50221. private _renderTime;
  50222. private _captureInterFrameTime;
  50223. private _interFrameTime;
  50224. private _captureParticlesRenderTime;
  50225. private _particlesRenderTime;
  50226. private _captureSpritesRenderTime;
  50227. private _spritesRenderTime;
  50228. private _capturePhysicsTime;
  50229. private _physicsTime;
  50230. private _captureAnimationsTime;
  50231. private _animationsTime;
  50232. private _captureCameraRenderTime;
  50233. private _cameraRenderTime;
  50234. private _onBeforeActiveMeshesEvaluationObserver;
  50235. private _onAfterActiveMeshesEvaluationObserver;
  50236. private _onBeforeRenderTargetsRenderObserver;
  50237. private _onAfterRenderTargetsRenderObserver;
  50238. private _onAfterRenderObserver;
  50239. private _onBeforeDrawPhaseObserver;
  50240. private _onAfterDrawPhaseObserver;
  50241. private _onBeforeAnimationsObserver;
  50242. private _onBeforeParticlesRenderingObserver;
  50243. private _onAfterParticlesRenderingObserver;
  50244. private _onBeforeSpritesRenderingObserver;
  50245. private _onAfterSpritesRenderingObserver;
  50246. private _onBeforePhysicsObserver;
  50247. private _onAfterPhysicsObserver;
  50248. private _onAfterAnimationsObserver;
  50249. private _onBeforeCameraRenderObserver;
  50250. private _onAfterCameraRenderObserver;
  50251. /**
  50252. * Gets the perf counter used for active meshes evaluation time
  50253. */
  50254. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50255. /**
  50256. * Gets the active meshes evaluation time capture status
  50257. */
  50258. /**
  50259. * Enable or disable the active meshes evaluation time capture
  50260. */
  50261. captureActiveMeshesEvaluationTime: boolean;
  50262. /**
  50263. * Gets the perf counter used for render targets render time
  50264. */
  50265. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50266. /**
  50267. * Gets the render targets render time capture status
  50268. */
  50269. /**
  50270. * Enable or disable the render targets render time capture
  50271. */
  50272. captureRenderTargetsRenderTime: boolean;
  50273. /**
  50274. * Gets the perf counter used for particles render time
  50275. */
  50276. readonly particlesRenderTimeCounter: PerfCounter;
  50277. /**
  50278. * Gets the particles render time capture status
  50279. */
  50280. /**
  50281. * Enable or disable the particles render time capture
  50282. */
  50283. captureParticlesRenderTime: boolean;
  50284. /**
  50285. * Gets the perf counter used for sprites render time
  50286. */
  50287. readonly spritesRenderTimeCounter: PerfCounter;
  50288. /**
  50289. * Gets the sprites render time capture status
  50290. */
  50291. /**
  50292. * Enable or disable the sprites render time capture
  50293. */
  50294. captureSpritesRenderTime: boolean;
  50295. /**
  50296. * Gets the perf counter used for physics time
  50297. */
  50298. readonly physicsTimeCounter: PerfCounter;
  50299. /**
  50300. * Gets the physics time capture status
  50301. */
  50302. /**
  50303. * Enable or disable the physics time capture
  50304. */
  50305. capturePhysicsTime: boolean;
  50306. /**
  50307. * Gets the perf counter used for animations time
  50308. */
  50309. readonly animationsTimeCounter: PerfCounter;
  50310. /**
  50311. * Gets the animations time capture status
  50312. */
  50313. /**
  50314. * Enable or disable the animations time capture
  50315. */
  50316. captureAnimationsTime: boolean;
  50317. /**
  50318. * Gets the perf counter used for frame time capture
  50319. */
  50320. readonly frameTimeCounter: PerfCounter;
  50321. /**
  50322. * Gets the frame time capture status
  50323. */
  50324. /**
  50325. * Enable or disable the frame time capture
  50326. */
  50327. captureFrameTime: boolean;
  50328. /**
  50329. * Gets the perf counter used for inter-frames time capture
  50330. */
  50331. readonly interFrameTimeCounter: PerfCounter;
  50332. /**
  50333. * Gets the inter-frames time capture status
  50334. */
  50335. /**
  50336. * Enable or disable the inter-frames time capture
  50337. */
  50338. captureInterFrameTime: boolean;
  50339. /**
  50340. * Gets the perf counter used for render time capture
  50341. */
  50342. readonly renderTimeCounter: PerfCounter;
  50343. /**
  50344. * Gets the render time capture status
  50345. */
  50346. /**
  50347. * Enable or disable the render time capture
  50348. */
  50349. captureRenderTime: boolean;
  50350. /**
  50351. * Gets the perf counter used for camera render time capture
  50352. */
  50353. readonly cameraRenderTimeCounter: PerfCounter;
  50354. /**
  50355. * Gets the camera render time capture status
  50356. */
  50357. /**
  50358. * Enable or disable the camera render time capture
  50359. */
  50360. captureCameraRenderTime: boolean;
  50361. /**
  50362. * Gets the perf counter used for draw calls
  50363. */
  50364. readonly drawCallsCounter: PerfCounter;
  50365. /**
  50366. * Instantiates a new scene instrumentation.
  50367. * This class can be used to get instrumentation data from a Babylon engine
  50368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50369. * @param scene Defines the scene to instrument
  50370. */
  50371. constructor(
  50372. /**
  50373. * Defines the scene to instrument
  50374. */
  50375. scene: Scene);
  50376. /**
  50377. * Dispose and release associated resources.
  50378. */
  50379. dispose(): void;
  50380. }
  50381. }
  50382. declare module "babylonjs/Instrumentation/index" {
  50383. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50384. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50385. export * from "babylonjs/Instrumentation/timeToken";
  50386. }
  50387. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50388. /** @hidden */
  50389. export var glowMapGenerationPixelShader: {
  50390. name: string;
  50391. shader: string;
  50392. };
  50393. }
  50394. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50399. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50400. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50401. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50402. /** @hidden */
  50403. export var glowMapGenerationVertexShader: {
  50404. name: string;
  50405. shader: string;
  50406. };
  50407. }
  50408. declare module "babylonjs/Layers/effectLayer" {
  50409. import { Observable } from "babylonjs/Misc/observable";
  50410. import { Nullable } from "babylonjs/types";
  50411. import { Camera } from "babylonjs/Cameras/camera";
  50412. import { Scene } from "babylonjs/scene";
  50413. import { ISize } from "babylonjs/Maths/math.size";
  50414. import { Color4 } from "babylonjs/Maths/math.color";
  50415. import { Engine } from "babylonjs/Engines/engine";
  50416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50418. import { Mesh } from "babylonjs/Meshes/mesh";
  50419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50421. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50422. import { Effect } from "babylonjs/Materials/effect";
  50423. import { Material } from "babylonjs/Materials/material";
  50424. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50425. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50426. /**
  50427. * Effect layer options. This helps customizing the behaviour
  50428. * of the effect layer.
  50429. */
  50430. export interface IEffectLayerOptions {
  50431. /**
  50432. * Multiplication factor apply to the canvas size to compute the render target size
  50433. * used to generated the objects (the smaller the faster).
  50434. */
  50435. mainTextureRatio: number;
  50436. /**
  50437. * Enforces a fixed size texture to ensure effect stability across devices.
  50438. */
  50439. mainTextureFixedSize?: number;
  50440. /**
  50441. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50442. */
  50443. alphaBlendingMode: number;
  50444. /**
  50445. * The camera attached to the layer.
  50446. */
  50447. camera: Nullable<Camera>;
  50448. /**
  50449. * The rendering group to draw the layer in.
  50450. */
  50451. renderingGroupId: number;
  50452. }
  50453. /**
  50454. * The effect layer Helps adding post process effect blended with the main pass.
  50455. *
  50456. * This can be for instance use to generate glow or higlight effects on the scene.
  50457. *
  50458. * The effect layer class can not be used directly and is intented to inherited from to be
  50459. * customized per effects.
  50460. */
  50461. export abstract class EffectLayer {
  50462. private _vertexBuffers;
  50463. private _indexBuffer;
  50464. private _cachedDefines;
  50465. private _effectLayerMapGenerationEffect;
  50466. private _effectLayerOptions;
  50467. private _mergeEffect;
  50468. protected _scene: Scene;
  50469. protected _engine: Engine;
  50470. protected _maxSize: number;
  50471. protected _mainTextureDesiredSize: ISize;
  50472. protected _mainTexture: RenderTargetTexture;
  50473. protected _shouldRender: boolean;
  50474. protected _postProcesses: PostProcess[];
  50475. protected _textures: BaseTexture[];
  50476. protected _emissiveTextureAndColor: {
  50477. texture: Nullable<BaseTexture>;
  50478. color: Color4;
  50479. };
  50480. /**
  50481. * The name of the layer
  50482. */
  50483. name: string;
  50484. /**
  50485. * The clear color of the texture used to generate the glow map.
  50486. */
  50487. neutralColor: Color4;
  50488. /**
  50489. * Specifies wether the highlight layer is enabled or not.
  50490. */
  50491. isEnabled: boolean;
  50492. /**
  50493. * Gets the camera attached to the layer.
  50494. */
  50495. readonly camera: Nullable<Camera>;
  50496. /**
  50497. * Gets the rendering group id the layer should render in.
  50498. */
  50499. renderingGroupId: number;
  50500. /**
  50501. * An event triggered when the effect layer has been disposed.
  50502. */
  50503. onDisposeObservable: Observable<EffectLayer>;
  50504. /**
  50505. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50506. */
  50507. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50508. /**
  50509. * An event triggered when the generated texture is being merged in the scene.
  50510. */
  50511. onBeforeComposeObservable: Observable<EffectLayer>;
  50512. /**
  50513. * An event triggered when the generated texture has been merged in the scene.
  50514. */
  50515. onAfterComposeObservable: Observable<EffectLayer>;
  50516. /**
  50517. * An event triggered when the efffect layer changes its size.
  50518. */
  50519. onSizeChangedObservable: Observable<EffectLayer>;
  50520. /** @hidden */
  50521. static _SceneComponentInitialization: (scene: Scene) => void;
  50522. /**
  50523. * Instantiates a new effect Layer and references it in the scene.
  50524. * @param name The name of the layer
  50525. * @param scene The scene to use the layer in
  50526. */
  50527. constructor(
  50528. /** The Friendly of the effect in the scene */
  50529. name: string, scene: Scene);
  50530. /**
  50531. * Get the effect name of the layer.
  50532. * @return The effect name
  50533. */
  50534. abstract getEffectName(): string;
  50535. /**
  50536. * Checks for the readiness of the element composing the layer.
  50537. * @param subMesh the mesh to check for
  50538. * @param useInstances specify wether or not to use instances to render the mesh
  50539. * @return true if ready otherwise, false
  50540. */
  50541. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50542. /**
  50543. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50544. * @returns true if the effect requires stencil during the main canvas render pass.
  50545. */
  50546. abstract needStencil(): boolean;
  50547. /**
  50548. * Create the merge effect. This is the shader use to blit the information back
  50549. * to the main canvas at the end of the scene rendering.
  50550. * @returns The effect containing the shader used to merge the effect on the main canvas
  50551. */
  50552. protected abstract _createMergeEffect(): Effect;
  50553. /**
  50554. * Creates the render target textures and post processes used in the effect layer.
  50555. */
  50556. protected abstract _createTextureAndPostProcesses(): void;
  50557. /**
  50558. * Implementation specific of rendering the generating effect on the main canvas.
  50559. * @param effect The effect used to render through
  50560. */
  50561. protected abstract _internalRender(effect: Effect): void;
  50562. /**
  50563. * Sets the required values for both the emissive texture and and the main color.
  50564. */
  50565. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50566. /**
  50567. * Free any resources and references associated to a mesh.
  50568. * Internal use
  50569. * @param mesh The mesh to free.
  50570. */
  50571. abstract _disposeMesh(mesh: Mesh): void;
  50572. /**
  50573. * Serializes this layer (Glow or Highlight for example)
  50574. * @returns a serialized layer object
  50575. */
  50576. abstract serialize?(): any;
  50577. /**
  50578. * Initializes the effect layer with the required options.
  50579. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50580. */
  50581. protected _init(options: Partial<IEffectLayerOptions>): void;
  50582. /**
  50583. * Generates the index buffer of the full screen quad blending to the main canvas.
  50584. */
  50585. private _generateIndexBuffer;
  50586. /**
  50587. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50588. */
  50589. private _generateVertexBuffer;
  50590. /**
  50591. * Sets the main texture desired size which is the closest power of two
  50592. * of the engine canvas size.
  50593. */
  50594. private _setMainTextureSize;
  50595. /**
  50596. * Creates the main texture for the effect layer.
  50597. */
  50598. protected _createMainTexture(): void;
  50599. /**
  50600. * Adds specific effects defines.
  50601. * @param defines The defines to add specifics to.
  50602. */
  50603. protected _addCustomEffectDefines(defines: string[]): void;
  50604. /**
  50605. * Checks for the readiness of the element composing the layer.
  50606. * @param subMesh the mesh to check for
  50607. * @param useInstances specify wether or not to use instances to render the mesh
  50608. * @param emissiveTexture the associated emissive texture used to generate the glow
  50609. * @return true if ready otherwise, false
  50610. */
  50611. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50612. /**
  50613. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50614. */
  50615. render(): void;
  50616. /**
  50617. * Determine if a given mesh will be used in the current effect.
  50618. * @param mesh mesh to test
  50619. * @returns true if the mesh will be used
  50620. */
  50621. hasMesh(mesh: AbstractMesh): boolean;
  50622. /**
  50623. * Returns true if the layer contains information to display, otherwise false.
  50624. * @returns true if the glow layer should be rendered
  50625. */
  50626. shouldRender(): boolean;
  50627. /**
  50628. * Returns true if the mesh should render, otherwise false.
  50629. * @param mesh The mesh to render
  50630. * @returns true if it should render otherwise false
  50631. */
  50632. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50633. /**
  50634. * Returns true if the mesh can be rendered, otherwise false.
  50635. * @param mesh The mesh to render
  50636. * @param material The material used on the mesh
  50637. * @returns true if it can be rendered otherwise false
  50638. */
  50639. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50640. /**
  50641. * Returns true if the mesh should render, otherwise false.
  50642. * @param mesh The mesh to render
  50643. * @returns true if it should render otherwise false
  50644. */
  50645. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50646. /**
  50647. * Renders the submesh passed in parameter to the generation map.
  50648. */
  50649. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50650. /**
  50651. * Rebuild the required buffers.
  50652. * @hidden Internal use only.
  50653. */
  50654. _rebuild(): void;
  50655. /**
  50656. * Dispose only the render target textures and post process.
  50657. */
  50658. private _disposeTextureAndPostProcesses;
  50659. /**
  50660. * Dispose the highlight layer and free resources.
  50661. */
  50662. dispose(): void;
  50663. /**
  50664. * Gets the class name of the effect layer
  50665. * @returns the string with the class name of the effect layer
  50666. */
  50667. getClassName(): string;
  50668. /**
  50669. * Creates an effect layer from parsed effect layer data
  50670. * @param parsedEffectLayer defines effect layer data
  50671. * @param scene defines the current scene
  50672. * @param rootUrl defines the root URL containing the effect layer information
  50673. * @returns a parsed effect Layer
  50674. */
  50675. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50676. }
  50677. }
  50678. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50679. import { Scene } from "babylonjs/scene";
  50680. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50681. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50682. import { AbstractScene } from "babylonjs/abstractScene";
  50683. module "babylonjs/abstractScene" {
  50684. interface AbstractScene {
  50685. /**
  50686. * The list of effect layers (highlights/glow) added to the scene
  50687. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50688. * @see http://doc.babylonjs.com/how_to/glow_layer
  50689. */
  50690. effectLayers: Array<EffectLayer>;
  50691. /**
  50692. * Removes the given effect layer from this scene.
  50693. * @param toRemove defines the effect layer to remove
  50694. * @returns the index of the removed effect layer
  50695. */
  50696. removeEffectLayer(toRemove: EffectLayer): number;
  50697. /**
  50698. * Adds the given effect layer to this scene
  50699. * @param newEffectLayer defines the effect layer to add
  50700. */
  50701. addEffectLayer(newEffectLayer: EffectLayer): void;
  50702. }
  50703. }
  50704. /**
  50705. * Defines the layer scene component responsible to manage any effect layers
  50706. * in a given scene.
  50707. */
  50708. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50709. /**
  50710. * The component name helpfull to identify the component in the list of scene components.
  50711. */
  50712. readonly name: string;
  50713. /**
  50714. * The scene the component belongs to.
  50715. */
  50716. scene: Scene;
  50717. private _engine;
  50718. private _renderEffects;
  50719. private _needStencil;
  50720. private _previousStencilState;
  50721. /**
  50722. * Creates a new instance of the component for the given scene
  50723. * @param scene Defines the scene to register the component in
  50724. */
  50725. constructor(scene: Scene);
  50726. /**
  50727. * Registers the component in a given scene
  50728. */
  50729. register(): void;
  50730. /**
  50731. * Rebuilds the elements related to this component in case of
  50732. * context lost for instance.
  50733. */
  50734. rebuild(): void;
  50735. /**
  50736. * Serializes the component data to the specified json object
  50737. * @param serializationObject The object to serialize to
  50738. */
  50739. serialize(serializationObject: any): void;
  50740. /**
  50741. * Adds all the elements from the container to the scene
  50742. * @param container the container holding the elements
  50743. */
  50744. addFromContainer(container: AbstractScene): void;
  50745. /**
  50746. * Removes all the elements in the container from the scene
  50747. * @param container contains the elements to remove
  50748. * @param dispose if the removed element should be disposed (default: false)
  50749. */
  50750. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50751. /**
  50752. * Disposes the component and the associated ressources.
  50753. */
  50754. dispose(): void;
  50755. private _isReadyForMesh;
  50756. private _renderMainTexture;
  50757. private _setStencil;
  50758. private _setStencilBack;
  50759. private _draw;
  50760. private _drawCamera;
  50761. private _drawRenderingGroup;
  50762. }
  50763. }
  50764. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50765. /** @hidden */
  50766. export var glowMapMergePixelShader: {
  50767. name: string;
  50768. shader: string;
  50769. };
  50770. }
  50771. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50772. /** @hidden */
  50773. export var glowMapMergeVertexShader: {
  50774. name: string;
  50775. shader: string;
  50776. };
  50777. }
  50778. declare module "babylonjs/Layers/glowLayer" {
  50779. import { Nullable } from "babylonjs/types";
  50780. import { Camera } from "babylonjs/Cameras/camera";
  50781. import { Scene } from "babylonjs/scene";
  50782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50784. import { Mesh } from "babylonjs/Meshes/mesh";
  50785. import { Texture } from "babylonjs/Materials/Textures/texture";
  50786. import { Effect } from "babylonjs/Materials/effect";
  50787. import { Material } from "babylonjs/Materials/material";
  50788. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50789. import { Color4 } from "babylonjs/Maths/math.color";
  50790. import "babylonjs/Shaders/glowMapMerge.fragment";
  50791. import "babylonjs/Shaders/glowMapMerge.vertex";
  50792. import "babylonjs/Layers/effectLayerSceneComponent";
  50793. module "babylonjs/abstractScene" {
  50794. interface AbstractScene {
  50795. /**
  50796. * Return a the first highlight layer of the scene with a given name.
  50797. * @param name The name of the highlight layer to look for.
  50798. * @return The highlight layer if found otherwise null.
  50799. */
  50800. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50801. }
  50802. }
  50803. /**
  50804. * Glow layer options. This helps customizing the behaviour
  50805. * of the glow layer.
  50806. */
  50807. export interface IGlowLayerOptions {
  50808. /**
  50809. * Multiplication factor apply to the canvas size to compute the render target size
  50810. * used to generated the glowing objects (the smaller the faster).
  50811. */
  50812. mainTextureRatio: number;
  50813. /**
  50814. * Enforces a fixed size texture to ensure resize independant blur.
  50815. */
  50816. mainTextureFixedSize?: number;
  50817. /**
  50818. * How big is the kernel of the blur texture.
  50819. */
  50820. blurKernelSize: number;
  50821. /**
  50822. * The camera attached to the layer.
  50823. */
  50824. camera: Nullable<Camera>;
  50825. /**
  50826. * Enable MSAA by chosing the number of samples.
  50827. */
  50828. mainTextureSamples?: number;
  50829. /**
  50830. * The rendering group to draw the layer in.
  50831. */
  50832. renderingGroupId: number;
  50833. }
  50834. /**
  50835. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50836. *
  50837. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50838. * glowy meshes to your scene.
  50839. *
  50840. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50841. */
  50842. export class GlowLayer extends EffectLayer {
  50843. /**
  50844. * Effect Name of the layer.
  50845. */
  50846. static readonly EffectName: string;
  50847. /**
  50848. * The default blur kernel size used for the glow.
  50849. */
  50850. static DefaultBlurKernelSize: number;
  50851. /**
  50852. * The default texture size ratio used for the glow.
  50853. */
  50854. static DefaultTextureRatio: number;
  50855. /**
  50856. * Sets the kernel size of the blur.
  50857. */
  50858. /**
  50859. * Gets the kernel size of the blur.
  50860. */
  50861. blurKernelSize: number;
  50862. /**
  50863. * Sets the glow intensity.
  50864. */
  50865. /**
  50866. * Gets the glow intensity.
  50867. */
  50868. intensity: number;
  50869. private _options;
  50870. private _intensity;
  50871. private _horizontalBlurPostprocess1;
  50872. private _verticalBlurPostprocess1;
  50873. private _horizontalBlurPostprocess2;
  50874. private _verticalBlurPostprocess2;
  50875. private _blurTexture1;
  50876. private _blurTexture2;
  50877. private _postProcesses1;
  50878. private _postProcesses2;
  50879. private _includedOnlyMeshes;
  50880. private _excludedMeshes;
  50881. /**
  50882. * Callback used to let the user override the color selection on a per mesh basis
  50883. */
  50884. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50885. /**
  50886. * Callback used to let the user override the texture selection on a per mesh basis
  50887. */
  50888. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50889. /**
  50890. * Instantiates a new glow Layer and references it to the scene.
  50891. * @param name The name of the layer
  50892. * @param scene The scene to use the layer in
  50893. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50894. */
  50895. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50896. /**
  50897. * Get the effect name of the layer.
  50898. * @return The effect name
  50899. */
  50900. getEffectName(): string;
  50901. /**
  50902. * Create the merge effect. This is the shader use to blit the information back
  50903. * to the main canvas at the end of the scene rendering.
  50904. */
  50905. protected _createMergeEffect(): Effect;
  50906. /**
  50907. * Creates the render target textures and post processes used in the glow layer.
  50908. */
  50909. protected _createTextureAndPostProcesses(): void;
  50910. /**
  50911. * Checks for the readiness of the element composing the layer.
  50912. * @param subMesh the mesh to check for
  50913. * @param useInstances specify wether or not to use instances to render the mesh
  50914. * @param emissiveTexture the associated emissive texture used to generate the glow
  50915. * @return true if ready otherwise, false
  50916. */
  50917. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50918. /**
  50919. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50920. */
  50921. needStencil(): boolean;
  50922. /**
  50923. * Returns true if the mesh can be rendered, otherwise false.
  50924. * @param mesh The mesh to render
  50925. * @param material The material used on the mesh
  50926. * @returns true if it can be rendered otherwise false
  50927. */
  50928. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50929. /**
  50930. * Implementation specific of rendering the generating effect on the main canvas.
  50931. * @param effect The effect used to render through
  50932. */
  50933. protected _internalRender(effect: Effect): void;
  50934. /**
  50935. * Sets the required values for both the emissive texture and and the main color.
  50936. */
  50937. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50938. /**
  50939. * Returns true if the mesh should render, otherwise false.
  50940. * @param mesh The mesh to render
  50941. * @returns true if it should render otherwise false
  50942. */
  50943. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50944. /**
  50945. * Adds specific effects defines.
  50946. * @param defines The defines to add specifics to.
  50947. */
  50948. protected _addCustomEffectDefines(defines: string[]): void;
  50949. /**
  50950. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50951. * @param mesh The mesh to exclude from the glow layer
  50952. */
  50953. addExcludedMesh(mesh: Mesh): void;
  50954. /**
  50955. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50956. * @param mesh The mesh to remove
  50957. */
  50958. removeExcludedMesh(mesh: Mesh): void;
  50959. /**
  50960. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50961. * @param mesh The mesh to include in the glow layer
  50962. */
  50963. addIncludedOnlyMesh(mesh: Mesh): void;
  50964. /**
  50965. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50966. * @param mesh The mesh to remove
  50967. */
  50968. removeIncludedOnlyMesh(mesh: Mesh): void;
  50969. /**
  50970. * Determine if a given mesh will be used in the glow layer
  50971. * @param mesh The mesh to test
  50972. * @returns true if the mesh will be highlighted by the current glow layer
  50973. */
  50974. hasMesh(mesh: AbstractMesh): boolean;
  50975. /**
  50976. * Free any resources and references associated to a mesh.
  50977. * Internal use
  50978. * @param mesh The mesh to free.
  50979. * @hidden
  50980. */
  50981. _disposeMesh(mesh: Mesh): void;
  50982. /**
  50983. * Gets the class name of the effect layer
  50984. * @returns the string with the class name of the effect layer
  50985. */
  50986. getClassName(): string;
  50987. /**
  50988. * Serializes this glow layer
  50989. * @returns a serialized glow layer object
  50990. */
  50991. serialize(): any;
  50992. /**
  50993. * Creates a Glow Layer from parsed glow layer data
  50994. * @param parsedGlowLayer defines glow layer data
  50995. * @param scene defines the current scene
  50996. * @param rootUrl defines the root URL containing the glow layer information
  50997. * @returns a parsed Glow Layer
  50998. */
  50999. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51000. }
  51001. }
  51002. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51003. /** @hidden */
  51004. export var glowBlurPostProcessPixelShader: {
  51005. name: string;
  51006. shader: string;
  51007. };
  51008. }
  51009. declare module "babylonjs/Layers/highlightLayer" {
  51010. import { Observable } from "babylonjs/Misc/observable";
  51011. import { Nullable } from "babylonjs/types";
  51012. import { Camera } from "babylonjs/Cameras/camera";
  51013. import { Scene } from "babylonjs/scene";
  51014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51016. import { Mesh } from "babylonjs/Meshes/mesh";
  51017. import { Effect } from "babylonjs/Materials/effect";
  51018. import { Material } from "babylonjs/Materials/material";
  51019. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51020. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51021. import "babylonjs/Shaders/glowMapMerge.fragment";
  51022. import "babylonjs/Shaders/glowMapMerge.vertex";
  51023. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51024. module "babylonjs/abstractScene" {
  51025. interface AbstractScene {
  51026. /**
  51027. * Return a the first highlight layer of the scene with a given name.
  51028. * @param name The name of the highlight layer to look for.
  51029. * @return The highlight layer if found otherwise null.
  51030. */
  51031. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51032. }
  51033. }
  51034. /**
  51035. * Highlight layer options. This helps customizing the behaviour
  51036. * of the highlight layer.
  51037. */
  51038. export interface IHighlightLayerOptions {
  51039. /**
  51040. * Multiplication factor apply to the canvas size to compute the render target size
  51041. * used to generated the glowing objects (the smaller the faster).
  51042. */
  51043. mainTextureRatio: number;
  51044. /**
  51045. * Enforces a fixed size texture to ensure resize independant blur.
  51046. */
  51047. mainTextureFixedSize?: number;
  51048. /**
  51049. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51050. * of the picture to blur (the smaller the faster).
  51051. */
  51052. blurTextureSizeRatio: number;
  51053. /**
  51054. * How big in texel of the blur texture is the vertical blur.
  51055. */
  51056. blurVerticalSize: number;
  51057. /**
  51058. * How big in texel of the blur texture is the horizontal blur.
  51059. */
  51060. blurHorizontalSize: number;
  51061. /**
  51062. * Alpha blending mode used to apply the blur. Default is combine.
  51063. */
  51064. alphaBlendingMode: number;
  51065. /**
  51066. * The camera attached to the layer.
  51067. */
  51068. camera: Nullable<Camera>;
  51069. /**
  51070. * Should we display highlight as a solid stroke?
  51071. */
  51072. isStroke?: boolean;
  51073. /**
  51074. * The rendering group to draw the layer in.
  51075. */
  51076. renderingGroupId: number;
  51077. }
  51078. /**
  51079. * The highlight layer Helps adding a glow effect around a mesh.
  51080. *
  51081. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51082. * glowy meshes to your scene.
  51083. *
  51084. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51085. */
  51086. export class HighlightLayer extends EffectLayer {
  51087. name: string;
  51088. /**
  51089. * Effect Name of the highlight layer.
  51090. */
  51091. static readonly EffectName: string;
  51092. /**
  51093. * The neutral color used during the preparation of the glow effect.
  51094. * This is black by default as the blend operation is a blend operation.
  51095. */
  51096. static NeutralColor: Color4;
  51097. /**
  51098. * Stencil value used for glowing meshes.
  51099. */
  51100. static GlowingMeshStencilReference: number;
  51101. /**
  51102. * Stencil value used for the other meshes in the scene.
  51103. */
  51104. static NormalMeshStencilReference: number;
  51105. /**
  51106. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51107. */
  51108. innerGlow: boolean;
  51109. /**
  51110. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51111. */
  51112. outerGlow: boolean;
  51113. /**
  51114. * Specifies the horizontal size of the blur.
  51115. */
  51116. /**
  51117. * Gets the horizontal size of the blur.
  51118. */
  51119. blurHorizontalSize: number;
  51120. /**
  51121. * Specifies the vertical size of the blur.
  51122. */
  51123. /**
  51124. * Gets the vertical size of the blur.
  51125. */
  51126. blurVerticalSize: number;
  51127. /**
  51128. * An event triggered when the highlight layer is being blurred.
  51129. */
  51130. onBeforeBlurObservable: Observable<HighlightLayer>;
  51131. /**
  51132. * An event triggered when the highlight layer has been blurred.
  51133. */
  51134. onAfterBlurObservable: Observable<HighlightLayer>;
  51135. private _instanceGlowingMeshStencilReference;
  51136. private _options;
  51137. private _downSamplePostprocess;
  51138. private _horizontalBlurPostprocess;
  51139. private _verticalBlurPostprocess;
  51140. private _blurTexture;
  51141. private _meshes;
  51142. private _excludedMeshes;
  51143. /**
  51144. * Instantiates a new highlight Layer and references it to the scene..
  51145. * @param name The name of the layer
  51146. * @param scene The scene to use the layer in
  51147. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51148. */
  51149. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51150. /**
  51151. * Get the effect name of the layer.
  51152. * @return The effect name
  51153. */
  51154. getEffectName(): string;
  51155. /**
  51156. * Create the merge effect. This is the shader use to blit the information back
  51157. * to the main canvas at the end of the scene rendering.
  51158. */
  51159. protected _createMergeEffect(): Effect;
  51160. /**
  51161. * Creates the render target textures and post processes used in the highlight layer.
  51162. */
  51163. protected _createTextureAndPostProcesses(): void;
  51164. /**
  51165. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51166. */
  51167. needStencil(): boolean;
  51168. /**
  51169. * Checks for the readiness of the element composing the layer.
  51170. * @param subMesh the mesh to check for
  51171. * @param useInstances specify wether or not to use instances to render the mesh
  51172. * @param emissiveTexture the associated emissive texture used to generate the glow
  51173. * @return true if ready otherwise, false
  51174. */
  51175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51176. /**
  51177. * Implementation specific of rendering the generating effect on the main canvas.
  51178. * @param effect The effect used to render through
  51179. */
  51180. protected _internalRender(effect: Effect): void;
  51181. /**
  51182. * Returns true if the layer contains information to display, otherwise false.
  51183. */
  51184. shouldRender(): boolean;
  51185. /**
  51186. * Returns true if the mesh should render, otherwise false.
  51187. * @param mesh The mesh to render
  51188. * @returns true if it should render otherwise false
  51189. */
  51190. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51191. /**
  51192. * Sets the required values for both the emissive texture and and the main color.
  51193. */
  51194. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51195. /**
  51196. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51197. * @param mesh The mesh to exclude from the highlight layer
  51198. */
  51199. addExcludedMesh(mesh: Mesh): void;
  51200. /**
  51201. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51202. * @param mesh The mesh to highlight
  51203. */
  51204. removeExcludedMesh(mesh: Mesh): void;
  51205. /**
  51206. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51207. * @param mesh mesh to test
  51208. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51209. */
  51210. hasMesh(mesh: AbstractMesh): boolean;
  51211. /**
  51212. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51213. * @param mesh The mesh to highlight
  51214. * @param color The color of the highlight
  51215. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51216. */
  51217. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51218. /**
  51219. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51220. * @param mesh The mesh to highlight
  51221. */
  51222. removeMesh(mesh: Mesh): void;
  51223. /**
  51224. * Force the stencil to the normal expected value for none glowing parts
  51225. */
  51226. private _defaultStencilReference;
  51227. /**
  51228. * Free any resources and references associated to a mesh.
  51229. * Internal use
  51230. * @param mesh The mesh to free.
  51231. * @hidden
  51232. */
  51233. _disposeMesh(mesh: Mesh): void;
  51234. /**
  51235. * Dispose the highlight layer and free resources.
  51236. */
  51237. dispose(): void;
  51238. /**
  51239. * Gets the class name of the effect layer
  51240. * @returns the string with the class name of the effect layer
  51241. */
  51242. getClassName(): string;
  51243. /**
  51244. * Serializes this Highlight layer
  51245. * @returns a serialized Highlight layer object
  51246. */
  51247. serialize(): any;
  51248. /**
  51249. * Creates a Highlight layer from parsed Highlight layer data
  51250. * @param parsedHightlightLayer defines the Highlight layer data
  51251. * @param scene defines the current scene
  51252. * @param rootUrl defines the root URL containing the Highlight layer information
  51253. * @returns a parsed Highlight layer
  51254. */
  51255. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51256. }
  51257. }
  51258. declare module "babylonjs/Layers/layerSceneComponent" {
  51259. import { Scene } from "babylonjs/scene";
  51260. import { ISceneComponent } from "babylonjs/sceneComponent";
  51261. import { Layer } from "babylonjs/Layers/layer";
  51262. import { AbstractScene } from "babylonjs/abstractScene";
  51263. module "babylonjs/abstractScene" {
  51264. interface AbstractScene {
  51265. /**
  51266. * The list of layers (background and foreground) of the scene
  51267. */
  51268. layers: Array<Layer>;
  51269. }
  51270. }
  51271. /**
  51272. * Defines the layer scene component responsible to manage any layers
  51273. * in a given scene.
  51274. */
  51275. export class LayerSceneComponent implements ISceneComponent {
  51276. /**
  51277. * The component name helpfull to identify the component in the list of scene components.
  51278. */
  51279. readonly name: string;
  51280. /**
  51281. * The scene the component belongs to.
  51282. */
  51283. scene: Scene;
  51284. private _engine;
  51285. /**
  51286. * Creates a new instance of the component for the given scene
  51287. * @param scene Defines the scene to register the component in
  51288. */
  51289. constructor(scene: Scene);
  51290. /**
  51291. * Registers the component in a given scene
  51292. */
  51293. register(): void;
  51294. /**
  51295. * Rebuilds the elements related to this component in case of
  51296. * context lost for instance.
  51297. */
  51298. rebuild(): void;
  51299. /**
  51300. * Disposes the component and the associated ressources.
  51301. */
  51302. dispose(): void;
  51303. private _draw;
  51304. private _drawCameraPredicate;
  51305. private _drawCameraBackground;
  51306. private _drawCameraForeground;
  51307. private _drawRenderTargetPredicate;
  51308. private _drawRenderTargetBackground;
  51309. private _drawRenderTargetForeground;
  51310. /**
  51311. * Adds all the elements from the container to the scene
  51312. * @param container the container holding the elements
  51313. */
  51314. addFromContainer(container: AbstractScene): void;
  51315. /**
  51316. * Removes all the elements in the container from the scene
  51317. * @param container contains the elements to remove
  51318. * @param dispose if the removed element should be disposed (default: false)
  51319. */
  51320. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51321. }
  51322. }
  51323. declare module "babylonjs/Shaders/layer.fragment" {
  51324. /** @hidden */
  51325. export var layerPixelShader: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module "babylonjs/Shaders/layer.vertex" {
  51331. /** @hidden */
  51332. export var layerVertexShader: {
  51333. name: string;
  51334. shader: string;
  51335. };
  51336. }
  51337. declare module "babylonjs/Layers/layer" {
  51338. import { Observable } from "babylonjs/Misc/observable";
  51339. import { Nullable } from "babylonjs/types";
  51340. import { Scene } from "babylonjs/scene";
  51341. import { Vector2 } from "babylonjs/Maths/math.vector";
  51342. import { Color4 } from "babylonjs/Maths/math.color";
  51343. import { Texture } from "babylonjs/Materials/Textures/texture";
  51344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51345. import "babylonjs/Shaders/layer.fragment";
  51346. import "babylonjs/Shaders/layer.vertex";
  51347. /**
  51348. * This represents a full screen 2d layer.
  51349. * This can be useful to display a picture in the background of your scene for instance.
  51350. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51351. */
  51352. export class Layer {
  51353. /**
  51354. * Define the name of the layer.
  51355. */
  51356. name: string;
  51357. /**
  51358. * Define the texture the layer should display.
  51359. */
  51360. texture: Nullable<Texture>;
  51361. /**
  51362. * Is the layer in background or foreground.
  51363. */
  51364. isBackground: boolean;
  51365. /**
  51366. * Define the color of the layer (instead of texture).
  51367. */
  51368. color: Color4;
  51369. /**
  51370. * Define the scale of the layer in order to zoom in out of the texture.
  51371. */
  51372. scale: Vector2;
  51373. /**
  51374. * Define an offset for the layer in order to shift the texture.
  51375. */
  51376. offset: Vector2;
  51377. /**
  51378. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51379. */
  51380. alphaBlendingMode: number;
  51381. /**
  51382. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51383. * Alpha test will not mix with the background color in case of transparency.
  51384. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51385. */
  51386. alphaTest: boolean;
  51387. /**
  51388. * Define a mask to restrict the layer to only some of the scene cameras.
  51389. */
  51390. layerMask: number;
  51391. /**
  51392. * Define the list of render target the layer is visible into.
  51393. */
  51394. renderTargetTextures: RenderTargetTexture[];
  51395. /**
  51396. * Define if the layer is only used in renderTarget or if it also
  51397. * renders in the main frame buffer of the canvas.
  51398. */
  51399. renderOnlyInRenderTargetTextures: boolean;
  51400. private _scene;
  51401. private _vertexBuffers;
  51402. private _indexBuffer;
  51403. private _effect;
  51404. private _alphaTestEffect;
  51405. /**
  51406. * An event triggered when the layer is disposed.
  51407. */
  51408. onDisposeObservable: Observable<Layer>;
  51409. private _onDisposeObserver;
  51410. /**
  51411. * Back compatibility with callback before the onDisposeObservable existed.
  51412. * The set callback will be triggered when the layer has been disposed.
  51413. */
  51414. onDispose: () => void;
  51415. /**
  51416. * An event triggered before rendering the scene
  51417. */
  51418. onBeforeRenderObservable: Observable<Layer>;
  51419. private _onBeforeRenderObserver;
  51420. /**
  51421. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51422. * The set callback will be triggered just before rendering the layer.
  51423. */
  51424. onBeforeRender: () => void;
  51425. /**
  51426. * An event triggered after rendering the scene
  51427. */
  51428. onAfterRenderObservable: Observable<Layer>;
  51429. private _onAfterRenderObserver;
  51430. /**
  51431. * Back compatibility with callback before the onAfterRenderObservable existed.
  51432. * The set callback will be triggered just after rendering the layer.
  51433. */
  51434. onAfterRender: () => void;
  51435. /**
  51436. * Instantiates a new layer.
  51437. * This represents a full screen 2d layer.
  51438. * This can be useful to display a picture in the background of your scene for instance.
  51439. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51440. * @param name Define the name of the layer in the scene
  51441. * @param imgUrl Define the url of the texture to display in the layer
  51442. * @param scene Define the scene the layer belongs to
  51443. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51444. * @param color Defines a color for the layer
  51445. */
  51446. constructor(
  51447. /**
  51448. * Define the name of the layer.
  51449. */
  51450. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51451. private _createIndexBuffer;
  51452. /** @hidden */
  51453. _rebuild(): void;
  51454. /**
  51455. * Renders the layer in the scene.
  51456. */
  51457. render(): void;
  51458. /**
  51459. * Disposes and releases the associated ressources.
  51460. */
  51461. dispose(): void;
  51462. }
  51463. }
  51464. declare module "babylonjs/Layers/index" {
  51465. export * from "babylonjs/Layers/effectLayer";
  51466. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51467. export * from "babylonjs/Layers/glowLayer";
  51468. export * from "babylonjs/Layers/highlightLayer";
  51469. export * from "babylonjs/Layers/layer";
  51470. export * from "babylonjs/Layers/layerSceneComponent";
  51471. }
  51472. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51473. /** @hidden */
  51474. export var lensFlarePixelShader: {
  51475. name: string;
  51476. shader: string;
  51477. };
  51478. }
  51479. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51480. /** @hidden */
  51481. export var lensFlareVertexShader: {
  51482. name: string;
  51483. shader: string;
  51484. };
  51485. }
  51486. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51487. import { Scene } from "babylonjs/scene";
  51488. import { Vector3 } from "babylonjs/Maths/math.vector";
  51489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51490. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51491. import "babylonjs/Shaders/lensFlare.fragment";
  51492. import "babylonjs/Shaders/lensFlare.vertex";
  51493. import { Viewport } from "babylonjs/Maths/math.viewport";
  51494. /**
  51495. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51496. * It is usually composed of several `lensFlare`.
  51497. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51498. */
  51499. export class LensFlareSystem {
  51500. /**
  51501. * Define the name of the lens flare system
  51502. */
  51503. name: string;
  51504. /**
  51505. * List of lens flares used in this system.
  51506. */
  51507. lensFlares: LensFlare[];
  51508. /**
  51509. * Define a limit from the border the lens flare can be visible.
  51510. */
  51511. borderLimit: number;
  51512. /**
  51513. * Define a viewport border we do not want to see the lens flare in.
  51514. */
  51515. viewportBorder: number;
  51516. /**
  51517. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51518. */
  51519. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51520. /**
  51521. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51522. */
  51523. layerMask: number;
  51524. /**
  51525. * Define the id of the lens flare system in the scene.
  51526. * (equal to name by default)
  51527. */
  51528. id: string;
  51529. private _scene;
  51530. private _emitter;
  51531. private _vertexBuffers;
  51532. private _indexBuffer;
  51533. private _effect;
  51534. private _positionX;
  51535. private _positionY;
  51536. private _isEnabled;
  51537. /** @hidden */
  51538. static _SceneComponentInitialization: (scene: Scene) => void;
  51539. /**
  51540. * Instantiates a lens flare system.
  51541. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51542. * It is usually composed of several `lensFlare`.
  51543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51544. * @param name Define the name of the lens flare system in the scene
  51545. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51546. * @param scene Define the scene the lens flare system belongs to
  51547. */
  51548. constructor(
  51549. /**
  51550. * Define the name of the lens flare system
  51551. */
  51552. name: string, emitter: any, scene: Scene);
  51553. /**
  51554. * Define if the lens flare system is enabled.
  51555. */
  51556. isEnabled: boolean;
  51557. /**
  51558. * Get the scene the effects belongs to.
  51559. * @returns the scene holding the lens flare system
  51560. */
  51561. getScene(): Scene;
  51562. /**
  51563. * Get the emitter of the lens flare system.
  51564. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51565. * @returns the emitter of the lens flare system
  51566. */
  51567. getEmitter(): any;
  51568. /**
  51569. * Set the emitter of the lens flare system.
  51570. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51571. * @param newEmitter Define the new emitter of the system
  51572. */
  51573. setEmitter(newEmitter: any): void;
  51574. /**
  51575. * Get the lens flare system emitter position.
  51576. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51577. * @returns the position
  51578. */
  51579. getEmitterPosition(): Vector3;
  51580. /**
  51581. * @hidden
  51582. */
  51583. computeEffectivePosition(globalViewport: Viewport): boolean;
  51584. /** @hidden */
  51585. _isVisible(): boolean;
  51586. /**
  51587. * @hidden
  51588. */
  51589. render(): boolean;
  51590. /**
  51591. * Dispose and release the lens flare with its associated resources.
  51592. */
  51593. dispose(): void;
  51594. /**
  51595. * Parse a lens flare system from a JSON repressentation
  51596. * @param parsedLensFlareSystem Define the JSON to parse
  51597. * @param scene Define the scene the parsed system should be instantiated in
  51598. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51599. * @returns the parsed system
  51600. */
  51601. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51602. /**
  51603. * Serialize the current Lens Flare System into a JSON representation.
  51604. * @returns the serialized JSON
  51605. */
  51606. serialize(): any;
  51607. }
  51608. }
  51609. declare module "babylonjs/LensFlares/lensFlare" {
  51610. import { Nullable } from "babylonjs/types";
  51611. import { Color3 } from "babylonjs/Maths/math.color";
  51612. import { Texture } from "babylonjs/Materials/Textures/texture";
  51613. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51614. /**
  51615. * This represents one of the lens effect in a `lensFlareSystem`.
  51616. * It controls one of the indiviual texture used in the effect.
  51617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51618. */
  51619. export class LensFlare {
  51620. /**
  51621. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51622. */
  51623. size: number;
  51624. /**
  51625. * 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.
  51626. */
  51627. position: number;
  51628. /**
  51629. * Define the lens color.
  51630. */
  51631. color: Color3;
  51632. /**
  51633. * Define the lens texture.
  51634. */
  51635. texture: Nullable<Texture>;
  51636. /**
  51637. * Define the alpha mode to render this particular lens.
  51638. */
  51639. alphaMode: number;
  51640. private _system;
  51641. /**
  51642. * Creates a new Lens Flare.
  51643. * This represents one of the lens effect in a `lensFlareSystem`.
  51644. * It controls one of the indiviual texture used in the effect.
  51645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51646. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51647. * @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.
  51648. * @param color Define the lens color
  51649. * @param imgUrl Define the lens texture url
  51650. * @param system Define the `lensFlareSystem` this flare is part of
  51651. * @returns The newly created Lens Flare
  51652. */
  51653. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51654. /**
  51655. * Instantiates a new Lens Flare.
  51656. * This represents one of the lens effect in a `lensFlareSystem`.
  51657. * It controls one of the indiviual texture used in the effect.
  51658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51659. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51660. * @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.
  51661. * @param color Define the lens color
  51662. * @param imgUrl Define the lens texture url
  51663. * @param system Define the `lensFlareSystem` this flare is part of
  51664. */
  51665. constructor(
  51666. /**
  51667. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51668. */
  51669. size: number,
  51670. /**
  51671. * 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.
  51672. */
  51673. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51674. /**
  51675. * Dispose and release the lens flare with its associated resources.
  51676. */
  51677. dispose(): void;
  51678. }
  51679. }
  51680. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51681. import { Nullable } from "babylonjs/types";
  51682. import { Scene } from "babylonjs/scene";
  51683. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51684. import { AbstractScene } from "babylonjs/abstractScene";
  51685. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51686. module "babylonjs/abstractScene" {
  51687. interface AbstractScene {
  51688. /**
  51689. * The list of lens flare system added to the scene
  51690. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51691. */
  51692. lensFlareSystems: Array<LensFlareSystem>;
  51693. /**
  51694. * Removes the given lens flare system from this scene.
  51695. * @param toRemove The lens flare system to remove
  51696. * @returns The index of the removed lens flare system
  51697. */
  51698. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51699. /**
  51700. * Adds the given lens flare system to this scene
  51701. * @param newLensFlareSystem The lens flare system to add
  51702. */
  51703. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51704. /**
  51705. * Gets a lens flare system using its name
  51706. * @param name defines the name to look for
  51707. * @returns the lens flare system or null if not found
  51708. */
  51709. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51710. /**
  51711. * Gets a lens flare system using its id
  51712. * @param id defines the id to look for
  51713. * @returns the lens flare system or null if not found
  51714. */
  51715. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51716. }
  51717. }
  51718. /**
  51719. * Defines the lens flare scene component responsible to manage any lens flares
  51720. * in a given scene.
  51721. */
  51722. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51723. /**
  51724. * The component name helpfull to identify the component in the list of scene components.
  51725. */
  51726. readonly name: string;
  51727. /**
  51728. * The scene the component belongs to.
  51729. */
  51730. scene: Scene;
  51731. /**
  51732. * Creates a new instance of the component for the given scene
  51733. * @param scene Defines the scene to register the component in
  51734. */
  51735. constructor(scene: Scene);
  51736. /**
  51737. * Registers the component in a given scene
  51738. */
  51739. register(): void;
  51740. /**
  51741. * Rebuilds the elements related to this component in case of
  51742. * context lost for instance.
  51743. */
  51744. rebuild(): void;
  51745. /**
  51746. * Adds all the elements from the container to the scene
  51747. * @param container the container holding the elements
  51748. */
  51749. addFromContainer(container: AbstractScene): void;
  51750. /**
  51751. * Removes all the elements in the container from the scene
  51752. * @param container contains the elements to remove
  51753. * @param dispose if the removed element should be disposed (default: false)
  51754. */
  51755. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51756. /**
  51757. * Serializes the component data to the specified json object
  51758. * @param serializationObject The object to serialize to
  51759. */
  51760. serialize(serializationObject: any): void;
  51761. /**
  51762. * Disposes the component and the associated ressources.
  51763. */
  51764. dispose(): void;
  51765. private _draw;
  51766. }
  51767. }
  51768. declare module "babylonjs/LensFlares/index" {
  51769. export * from "babylonjs/LensFlares/lensFlare";
  51770. export * from "babylonjs/LensFlares/lensFlareSystem";
  51771. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51772. }
  51773. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51774. import { Scene } from "babylonjs/scene";
  51775. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51776. import { AbstractScene } from "babylonjs/abstractScene";
  51777. /**
  51778. * Defines the shadow generator component responsible to manage any shadow generators
  51779. * in a given scene.
  51780. */
  51781. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51782. /**
  51783. * The component name helpfull to identify the component in the list of scene components.
  51784. */
  51785. readonly name: string;
  51786. /**
  51787. * The scene the component belongs to.
  51788. */
  51789. scene: Scene;
  51790. /**
  51791. * Creates a new instance of the component for the given scene
  51792. * @param scene Defines the scene to register the component in
  51793. */
  51794. constructor(scene: Scene);
  51795. /**
  51796. * Registers the component in a given scene
  51797. */
  51798. register(): void;
  51799. /**
  51800. * Rebuilds the elements related to this component in case of
  51801. * context lost for instance.
  51802. */
  51803. rebuild(): void;
  51804. /**
  51805. * Serializes the component data to the specified json object
  51806. * @param serializationObject The object to serialize to
  51807. */
  51808. serialize(serializationObject: any): void;
  51809. /**
  51810. * Adds all the elements from the container to the scene
  51811. * @param container the container holding the elements
  51812. */
  51813. addFromContainer(container: AbstractScene): void;
  51814. /**
  51815. * Removes all the elements in the container from the scene
  51816. * @param container contains the elements to remove
  51817. * @param dispose if the removed element should be disposed (default: false)
  51818. */
  51819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51820. /**
  51821. * Rebuilds the elements related to this component in case of
  51822. * context lost for instance.
  51823. */
  51824. dispose(): void;
  51825. private _gatherRenderTargets;
  51826. }
  51827. }
  51828. declare module "babylonjs/Lights/Shadows/index" {
  51829. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51830. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51831. }
  51832. declare module "babylonjs/Lights/pointLight" {
  51833. import { Scene } from "babylonjs/scene";
  51834. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51836. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51837. import { Effect } from "babylonjs/Materials/effect";
  51838. /**
  51839. * A point light is a light defined by an unique point in world space.
  51840. * The light is emitted in every direction from this point.
  51841. * A good example of a point light is a standard light bulb.
  51842. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51843. */
  51844. export class PointLight extends ShadowLight {
  51845. private _shadowAngle;
  51846. /**
  51847. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51848. * This specifies what angle the shadow will use to be created.
  51849. *
  51850. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51851. */
  51852. /**
  51853. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51854. * This specifies what angle the shadow will use to be created.
  51855. *
  51856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51857. */
  51858. shadowAngle: number;
  51859. /**
  51860. * Gets the direction if it has been set.
  51861. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51862. */
  51863. /**
  51864. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51865. */
  51866. direction: Vector3;
  51867. /**
  51868. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51869. * A PointLight emits the light in every direction.
  51870. * It can cast shadows.
  51871. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51872. * ```javascript
  51873. * var pointLight = new PointLight("pl", camera.position, scene);
  51874. * ```
  51875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51876. * @param name The light friendly name
  51877. * @param position The position of the point light in the scene
  51878. * @param scene The scene the lights belongs to
  51879. */
  51880. constructor(name: string, position: Vector3, scene: Scene);
  51881. /**
  51882. * Returns the string "PointLight"
  51883. * @returns the class name
  51884. */
  51885. getClassName(): string;
  51886. /**
  51887. * Returns the integer 0.
  51888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51889. */
  51890. getTypeID(): number;
  51891. /**
  51892. * Specifies wether or not the shadowmap should be a cube texture.
  51893. * @returns true if the shadowmap needs to be a cube texture.
  51894. */
  51895. needCube(): boolean;
  51896. /**
  51897. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51900. */
  51901. getShadowDirection(faceIndex?: number): Vector3;
  51902. /**
  51903. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51904. * - fov = PI / 2
  51905. * - aspect ratio : 1.0
  51906. * - z-near and far equal to the active camera minZ and maxZ.
  51907. * Returns the PointLight.
  51908. */
  51909. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51910. protected _buildUniformLayout(): void;
  51911. /**
  51912. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51913. * @param effect The effect to update
  51914. * @param lightIndex The index of the light in the effect to update
  51915. * @returns The point light
  51916. */
  51917. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51918. /**
  51919. * Prepares the list of defines specific to the light type.
  51920. * @param defines the list of defines
  51921. * @param lightIndex defines the index of the light for the effect
  51922. */
  51923. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51924. }
  51925. }
  51926. declare module "babylonjs/Lights/index" {
  51927. export * from "babylonjs/Lights/light";
  51928. export * from "babylonjs/Lights/shadowLight";
  51929. export * from "babylonjs/Lights/Shadows/index";
  51930. export * from "babylonjs/Lights/directionalLight";
  51931. export * from "babylonjs/Lights/hemisphericLight";
  51932. export * from "babylonjs/Lights/pointLight";
  51933. export * from "babylonjs/Lights/spotLight";
  51934. }
  51935. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51936. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51937. /**
  51938. * Header information of HDR texture files.
  51939. */
  51940. export interface HDRInfo {
  51941. /**
  51942. * The height of the texture in pixels.
  51943. */
  51944. height: number;
  51945. /**
  51946. * The width of the texture in pixels.
  51947. */
  51948. width: number;
  51949. /**
  51950. * The index of the beginning of the data in the binary file.
  51951. */
  51952. dataPosition: number;
  51953. }
  51954. /**
  51955. * This groups tools to convert HDR texture to native colors array.
  51956. */
  51957. export class HDRTools {
  51958. private static Ldexp;
  51959. private static Rgbe2float;
  51960. private static readStringLine;
  51961. /**
  51962. * Reads header information from an RGBE texture stored in a native array.
  51963. * More information on this format are available here:
  51964. * https://en.wikipedia.org/wiki/RGBE_image_format
  51965. *
  51966. * @param uint8array The binary file stored in native array.
  51967. * @return The header information.
  51968. */
  51969. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51970. /**
  51971. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51972. * This RGBE texture needs to store the information as a panorama.
  51973. *
  51974. * More information on this format are available here:
  51975. * https://en.wikipedia.org/wiki/RGBE_image_format
  51976. *
  51977. * @param buffer The binary file stored in an array buffer.
  51978. * @param size The expected size of the extracted cubemap.
  51979. * @return The Cube Map information.
  51980. */
  51981. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51982. /**
  51983. * Returns the pixels data extracted from an RGBE texture.
  51984. * This pixels will be stored left to right up to down in the R G B order in one array.
  51985. *
  51986. * More information on this format are available here:
  51987. * https://en.wikipedia.org/wiki/RGBE_image_format
  51988. *
  51989. * @param uint8array The binary file stored in an array buffer.
  51990. * @param hdrInfo The header information of the file.
  51991. * @return The pixels data in RGB right to left up to down order.
  51992. */
  51993. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51994. private static RGBE_ReadPixels_RLE;
  51995. }
  51996. }
  51997. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51998. import { Nullable } from "babylonjs/types";
  51999. import { Scene } from "babylonjs/scene";
  52000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52002. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52003. /**
  52004. * This represents a texture coming from an HDR input.
  52005. *
  52006. * The only supported format is currently panorama picture stored in RGBE format.
  52007. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52008. */
  52009. export class HDRCubeTexture extends BaseTexture {
  52010. private static _facesMapping;
  52011. private _generateHarmonics;
  52012. private _noMipmap;
  52013. private _textureMatrix;
  52014. private _size;
  52015. private _onLoad;
  52016. private _onError;
  52017. /**
  52018. * The texture URL.
  52019. */
  52020. url: string;
  52021. /**
  52022. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52023. */
  52024. coordinatesMode: number;
  52025. protected _isBlocking: boolean;
  52026. /**
  52027. * Sets wether or not the texture is blocking during loading.
  52028. */
  52029. /**
  52030. * Gets wether or not the texture is blocking during loading.
  52031. */
  52032. isBlocking: boolean;
  52033. protected _rotationY: number;
  52034. /**
  52035. * Sets texture matrix rotation angle around Y axis in radians.
  52036. */
  52037. /**
  52038. * Gets texture matrix rotation angle around Y axis radians.
  52039. */
  52040. rotationY: number;
  52041. /**
  52042. * Gets or sets the center of the bounding box associated with the cube texture
  52043. * It must define where the camera used to render the texture was set
  52044. */
  52045. boundingBoxPosition: Vector3;
  52046. private _boundingBoxSize;
  52047. /**
  52048. * Gets or sets the size of the bounding box associated with the cube texture
  52049. * When defined, the cubemap will switch to local mode
  52050. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52051. * @example https://www.babylonjs-playground.com/#RNASML
  52052. */
  52053. boundingBoxSize: Vector3;
  52054. /**
  52055. * Instantiates an HDRTexture from the following parameters.
  52056. *
  52057. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52058. * @param scene The scene the texture will be used in
  52059. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52060. * @param noMipmap Forces to not generate the mipmap if true
  52061. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52062. * @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)
  52063. * @param reserved Reserved flag for internal use.
  52064. */
  52065. 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>);
  52066. /**
  52067. * Get the current class name of the texture useful for serialization or dynamic coding.
  52068. * @returns "HDRCubeTexture"
  52069. */
  52070. getClassName(): string;
  52071. /**
  52072. * Occurs when the file is raw .hdr file.
  52073. */
  52074. private loadTexture;
  52075. clone(): HDRCubeTexture;
  52076. delayLoad(): void;
  52077. /**
  52078. * Get the texture reflection matrix used to rotate/transform the reflection.
  52079. * @returns the reflection matrix
  52080. */
  52081. getReflectionTextureMatrix(): Matrix;
  52082. /**
  52083. * Set the texture reflection matrix used to rotate/transform the reflection.
  52084. * @param value Define the reflection matrix to set
  52085. */
  52086. setReflectionTextureMatrix(value: Matrix): void;
  52087. /**
  52088. * Parses a JSON representation of an HDR Texture in order to create the texture
  52089. * @param parsedTexture Define the JSON representation
  52090. * @param scene Define the scene the texture should be created in
  52091. * @param rootUrl Define the root url in case we need to load relative dependencies
  52092. * @returns the newly created texture after parsing
  52093. */
  52094. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52095. serialize(): any;
  52096. }
  52097. }
  52098. declare module "babylonjs/Physics/physicsEngine" {
  52099. import { Nullable } from "babylonjs/types";
  52100. import { Vector3 } from "babylonjs/Maths/math.vector";
  52101. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52102. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52103. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52104. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52105. /**
  52106. * Class used to control physics engine
  52107. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52108. */
  52109. export class PhysicsEngine implements IPhysicsEngine {
  52110. private _physicsPlugin;
  52111. /**
  52112. * Global value used to control the smallest number supported by the simulation
  52113. */
  52114. static Epsilon: number;
  52115. private _impostors;
  52116. private _joints;
  52117. /**
  52118. * Gets the gravity vector used by the simulation
  52119. */
  52120. gravity: Vector3;
  52121. /**
  52122. * Factory used to create the default physics plugin.
  52123. * @returns The default physics plugin
  52124. */
  52125. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52126. /**
  52127. * Creates a new Physics Engine
  52128. * @param gravity defines the gravity vector used by the simulation
  52129. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52130. */
  52131. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52132. /**
  52133. * Sets the gravity vector used by the simulation
  52134. * @param gravity defines the gravity vector to use
  52135. */
  52136. setGravity(gravity: Vector3): void;
  52137. /**
  52138. * Set the time step of the physics engine.
  52139. * Default is 1/60.
  52140. * To slow it down, enter 1/600 for example.
  52141. * To speed it up, 1/30
  52142. * @param newTimeStep defines the new timestep to apply to this world.
  52143. */
  52144. setTimeStep(newTimeStep?: number): void;
  52145. /**
  52146. * Get the time step of the physics engine.
  52147. * @returns the current time step
  52148. */
  52149. getTimeStep(): number;
  52150. /**
  52151. * Release all resources
  52152. */
  52153. dispose(): void;
  52154. /**
  52155. * Gets the name of the current physics plugin
  52156. * @returns the name of the plugin
  52157. */
  52158. getPhysicsPluginName(): string;
  52159. /**
  52160. * Adding a new impostor for the impostor tracking.
  52161. * This will be done by the impostor itself.
  52162. * @param impostor the impostor to add
  52163. */
  52164. addImpostor(impostor: PhysicsImpostor): void;
  52165. /**
  52166. * Remove an impostor from the engine.
  52167. * This impostor and its mesh will not longer be updated by the physics engine.
  52168. * @param impostor the impostor to remove
  52169. */
  52170. removeImpostor(impostor: PhysicsImpostor): void;
  52171. /**
  52172. * Add a joint to the physics engine
  52173. * @param mainImpostor defines the main impostor to which the joint is added.
  52174. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52175. * @param joint defines the joint that will connect both impostors.
  52176. */
  52177. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52178. /**
  52179. * Removes a joint from the simulation
  52180. * @param mainImpostor defines the impostor used with the joint
  52181. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52182. * @param joint defines the joint to remove
  52183. */
  52184. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52185. /**
  52186. * Called by the scene. No need to call it.
  52187. * @param delta defines the timespam between frames
  52188. */
  52189. _step(delta: number): void;
  52190. /**
  52191. * Gets the current plugin used to run the simulation
  52192. * @returns current plugin
  52193. */
  52194. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52195. /**
  52196. * Gets the list of physic impostors
  52197. * @returns an array of PhysicsImpostor
  52198. */
  52199. getImpostors(): Array<PhysicsImpostor>;
  52200. /**
  52201. * Gets the impostor for a physics enabled object
  52202. * @param object defines the object impersonated by the impostor
  52203. * @returns the PhysicsImpostor or null if not found
  52204. */
  52205. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52206. /**
  52207. * Gets the impostor for a physics body object
  52208. * @param body defines physics body used by the impostor
  52209. * @returns the PhysicsImpostor or null if not found
  52210. */
  52211. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52212. /**
  52213. * Does a raycast in the physics world
  52214. * @param from when should the ray start?
  52215. * @param to when should the ray end?
  52216. * @returns PhysicsRaycastResult
  52217. */
  52218. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52219. }
  52220. }
  52221. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52222. import { Nullable } from "babylonjs/types";
  52223. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52225. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52226. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52227. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52228. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52229. /** @hidden */
  52230. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52231. private _useDeltaForWorldStep;
  52232. world: any;
  52233. name: string;
  52234. private _physicsMaterials;
  52235. private _fixedTimeStep;
  52236. private _cannonRaycastResult;
  52237. private _raycastResult;
  52238. private _physicsBodysToRemoveAfterStep;
  52239. BJSCANNON: any;
  52240. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52241. setGravity(gravity: Vector3): void;
  52242. setTimeStep(timeStep: number): void;
  52243. getTimeStep(): number;
  52244. executeStep(delta: number): void;
  52245. private _removeMarkedPhysicsBodiesFromWorld;
  52246. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52247. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52248. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52249. private _processChildMeshes;
  52250. removePhysicsBody(impostor: PhysicsImpostor): void;
  52251. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52252. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52253. private _addMaterial;
  52254. private _checkWithEpsilon;
  52255. private _createShape;
  52256. private _createHeightmap;
  52257. private _minus90X;
  52258. private _plus90X;
  52259. private _tmpPosition;
  52260. private _tmpDeltaPosition;
  52261. private _tmpUnityRotation;
  52262. private _updatePhysicsBodyTransformation;
  52263. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52264. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52265. isSupported(): boolean;
  52266. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52267. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52268. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52269. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52270. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52271. getBodyMass(impostor: PhysicsImpostor): number;
  52272. getBodyFriction(impostor: PhysicsImpostor): number;
  52273. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52274. getBodyRestitution(impostor: PhysicsImpostor): number;
  52275. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52276. sleepBody(impostor: PhysicsImpostor): void;
  52277. wakeUpBody(impostor: PhysicsImpostor): void;
  52278. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52279. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52280. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52281. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52282. getRadius(impostor: PhysicsImpostor): number;
  52283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52284. dispose(): void;
  52285. private _extendNamespace;
  52286. /**
  52287. * Does a raycast in the physics world
  52288. * @param from when should the ray start?
  52289. * @param to when should the ray end?
  52290. * @returns PhysicsRaycastResult
  52291. */
  52292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52293. }
  52294. }
  52295. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52296. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52298. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52300. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52301. import { Nullable } from "babylonjs/types";
  52302. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52303. /** @hidden */
  52304. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52305. world: any;
  52306. name: string;
  52307. BJSOIMO: any;
  52308. private _raycastResult;
  52309. constructor(iterations?: number, oimoInjection?: any);
  52310. setGravity(gravity: Vector3): void;
  52311. setTimeStep(timeStep: number): void;
  52312. getTimeStep(): number;
  52313. private _tmpImpostorsArray;
  52314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52315. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52317. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52318. private _tmpPositionVector;
  52319. removePhysicsBody(impostor: PhysicsImpostor): void;
  52320. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52321. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52322. isSupported(): boolean;
  52323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52324. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52330. getBodyMass(impostor: PhysicsImpostor): number;
  52331. getBodyFriction(impostor: PhysicsImpostor): number;
  52332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52333. getBodyRestitution(impostor: PhysicsImpostor): number;
  52334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52335. sleepBody(impostor: PhysicsImpostor): void;
  52336. wakeUpBody(impostor: PhysicsImpostor): void;
  52337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52338. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52341. getRadius(impostor: PhysicsImpostor): number;
  52342. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52343. dispose(): void;
  52344. /**
  52345. * Does a raycast in the physics world
  52346. * @param from when should the ray start?
  52347. * @param to when should the ray end?
  52348. * @returns PhysicsRaycastResult
  52349. */
  52350. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52351. }
  52352. }
  52353. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52354. import { Nullable } from "babylonjs/types";
  52355. import { Scene } from "babylonjs/scene";
  52356. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52357. import { Color4 } from "babylonjs/Maths/math.color";
  52358. import { Mesh } from "babylonjs/Meshes/mesh";
  52359. /**
  52360. * Class containing static functions to help procedurally build meshes
  52361. */
  52362. export class RibbonBuilder {
  52363. /**
  52364. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52365. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52366. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52367. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52368. * * 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
  52369. * * 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
  52370. * * 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
  52371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52374. * * 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
  52375. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52376. * * 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
  52377. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52379. * @param name defines the name of the mesh
  52380. * @param options defines the options used to create the mesh
  52381. * @param scene defines the hosting scene
  52382. * @returns the ribbon mesh
  52383. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52385. */
  52386. static CreateRibbon(name: string, options: {
  52387. pathArray: Vector3[][];
  52388. closeArray?: boolean;
  52389. closePath?: boolean;
  52390. offset?: number;
  52391. updatable?: boolean;
  52392. sideOrientation?: number;
  52393. frontUVs?: Vector4;
  52394. backUVs?: Vector4;
  52395. instance?: Mesh;
  52396. invertUV?: boolean;
  52397. uvs?: Vector2[];
  52398. colors?: Color4[];
  52399. }, scene?: Nullable<Scene>): Mesh;
  52400. }
  52401. }
  52402. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52403. import { Nullable } from "babylonjs/types";
  52404. import { Scene } from "babylonjs/scene";
  52405. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52406. import { Mesh } from "babylonjs/Meshes/mesh";
  52407. /**
  52408. * Class containing static functions to help procedurally build meshes
  52409. */
  52410. export class ShapeBuilder {
  52411. /**
  52412. * 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.
  52413. * * 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.
  52414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52415. * * 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.
  52416. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52417. * * 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
  52418. * * 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
  52419. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52424. * @param name defines the name of the mesh
  52425. * @param options defines the options used to create the mesh
  52426. * @param scene defines the hosting scene
  52427. * @returns the extruded shape mesh
  52428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52430. */
  52431. static ExtrudeShape(name: string, options: {
  52432. shape: Vector3[];
  52433. path: Vector3[];
  52434. scale?: number;
  52435. rotation?: number;
  52436. cap?: number;
  52437. updatable?: boolean;
  52438. sideOrientation?: number;
  52439. frontUVs?: Vector4;
  52440. backUVs?: Vector4;
  52441. instance?: Mesh;
  52442. invertUV?: boolean;
  52443. }, scene?: Nullable<Scene>): Mesh;
  52444. /**
  52445. * Creates an custom extruded shape mesh.
  52446. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52447. * * 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.
  52448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52449. * * 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
  52450. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52451. * * 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
  52452. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52453. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52454. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52455. * * 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
  52456. * * 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
  52457. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52462. * @param name defines the name of the mesh
  52463. * @param options defines the options used to create the mesh
  52464. * @param scene defines the hosting scene
  52465. * @returns the custom extruded shape mesh
  52466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52469. */
  52470. static ExtrudeShapeCustom(name: string, options: {
  52471. shape: Vector3[];
  52472. path: Vector3[];
  52473. scaleFunction?: any;
  52474. rotationFunction?: any;
  52475. ribbonCloseArray?: boolean;
  52476. ribbonClosePath?: boolean;
  52477. cap?: number;
  52478. updatable?: boolean;
  52479. sideOrientation?: number;
  52480. frontUVs?: Vector4;
  52481. backUVs?: Vector4;
  52482. instance?: Mesh;
  52483. invertUV?: boolean;
  52484. }, scene?: Nullable<Scene>): Mesh;
  52485. private static _ExtrudeShapeGeneric;
  52486. }
  52487. }
  52488. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52489. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52490. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52491. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52492. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52493. import { Nullable } from "babylonjs/types";
  52494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52495. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52496. /**
  52497. * AmmoJS Physics plugin
  52498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52499. * @see https://github.com/kripken/ammo.js/
  52500. */
  52501. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52502. private _useDeltaForWorldStep;
  52503. /**
  52504. * Reference to the Ammo library
  52505. */
  52506. bjsAMMO: any;
  52507. /**
  52508. * Created ammoJS world which physics bodies are added to
  52509. */
  52510. world: any;
  52511. /**
  52512. * Name of the plugin
  52513. */
  52514. name: string;
  52515. private _timeStep;
  52516. private _fixedTimeStep;
  52517. private _maxSteps;
  52518. private _tmpQuaternion;
  52519. private _tmpAmmoTransform;
  52520. private _tmpAmmoQuaternion;
  52521. private _tmpAmmoConcreteContactResultCallback;
  52522. private _collisionConfiguration;
  52523. private _dispatcher;
  52524. private _overlappingPairCache;
  52525. private _solver;
  52526. private _softBodySolver;
  52527. private _tmpAmmoVectorA;
  52528. private _tmpAmmoVectorB;
  52529. private _tmpAmmoVectorC;
  52530. private _tmpAmmoVectorD;
  52531. private _tmpContactCallbackResult;
  52532. private _tmpAmmoVectorRCA;
  52533. private _tmpAmmoVectorRCB;
  52534. private _raycastResult;
  52535. private static readonly DISABLE_COLLISION_FLAG;
  52536. private static readonly KINEMATIC_FLAG;
  52537. private static readonly DISABLE_DEACTIVATION_FLAG;
  52538. /**
  52539. * Initializes the ammoJS plugin
  52540. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52541. * @param ammoInjection can be used to inject your own ammo reference
  52542. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52543. */
  52544. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52545. /**
  52546. * Sets the gravity of the physics world (m/(s^2))
  52547. * @param gravity Gravity to set
  52548. */
  52549. setGravity(gravity: Vector3): void;
  52550. /**
  52551. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52552. * @param timeStep timestep to use in seconds
  52553. */
  52554. setTimeStep(timeStep: number): void;
  52555. /**
  52556. * 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)
  52557. * @param fixedTimeStep fixedTimeStep to use in seconds
  52558. */
  52559. setFixedTimeStep(fixedTimeStep: number): void;
  52560. /**
  52561. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52562. * @param maxSteps the maximum number of steps by the physics engine per frame
  52563. */
  52564. setMaxSteps(maxSteps: number): void;
  52565. /**
  52566. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52567. * @returns the current timestep in seconds
  52568. */
  52569. getTimeStep(): number;
  52570. private _isImpostorInContact;
  52571. private _isImpostorPairInContact;
  52572. private _stepSimulation;
  52573. /**
  52574. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52575. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52576. * After the step the babylon meshes are set to the position of the physics imposters
  52577. * @param delta amount of time to step forward
  52578. * @param impostors array of imposters to update before/after the step
  52579. */
  52580. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52581. /**
  52582. * Update babylon mesh to match physics world object
  52583. * @param impostor imposter to match
  52584. */
  52585. private _afterSoftStep;
  52586. /**
  52587. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52588. * @param impostor imposter to match
  52589. */
  52590. private _ropeStep;
  52591. /**
  52592. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52593. * @param impostor imposter to match
  52594. */
  52595. private _softbodyOrClothStep;
  52596. private _tmpVector;
  52597. private _tmpMatrix;
  52598. /**
  52599. * Applies an impulse on the imposter
  52600. * @param impostor imposter to apply impulse to
  52601. * @param force amount of force to be applied to the imposter
  52602. * @param contactPoint the location to apply the impulse on the imposter
  52603. */
  52604. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52605. /**
  52606. * Applies a force on the imposter
  52607. * @param impostor imposter to apply force
  52608. * @param force amount of force to be applied to the imposter
  52609. * @param contactPoint the location to apply the force on the imposter
  52610. */
  52611. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52612. /**
  52613. * Creates a physics body using the plugin
  52614. * @param impostor the imposter to create the physics body on
  52615. */
  52616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52617. /**
  52618. * Removes the physics body from the imposter and disposes of the body's memory
  52619. * @param impostor imposter to remove the physics body from
  52620. */
  52621. removePhysicsBody(impostor: PhysicsImpostor): void;
  52622. /**
  52623. * Generates a joint
  52624. * @param impostorJoint the imposter joint to create the joint with
  52625. */
  52626. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52627. /**
  52628. * Removes a joint
  52629. * @param impostorJoint the imposter joint to remove the joint from
  52630. */
  52631. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52632. private _addMeshVerts;
  52633. /**
  52634. * Initialise the soft body vertices to match its object's (mesh) vertices
  52635. * Softbody vertices (nodes) are in world space and to match this
  52636. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52637. * @param impostor to create the softbody for
  52638. */
  52639. private _softVertexData;
  52640. /**
  52641. * Create an impostor's soft body
  52642. * @param impostor to create the softbody for
  52643. */
  52644. private _createSoftbody;
  52645. /**
  52646. * Create cloth for an impostor
  52647. * @param impostor to create the softbody for
  52648. */
  52649. private _createCloth;
  52650. /**
  52651. * Create rope for an impostor
  52652. * @param impostor to create the softbody for
  52653. */
  52654. private _createRope;
  52655. private _addHullVerts;
  52656. private _createShape;
  52657. /**
  52658. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52659. * @param impostor imposter containing the physics body and babylon object
  52660. */
  52661. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52662. /**
  52663. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52664. * @param impostor imposter containing the physics body and babylon object
  52665. * @param newPosition new position
  52666. * @param newRotation new rotation
  52667. */
  52668. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52669. /**
  52670. * If this plugin is supported
  52671. * @returns true if its supported
  52672. */
  52673. isSupported(): boolean;
  52674. /**
  52675. * Sets the linear velocity of the physics body
  52676. * @param impostor imposter to set the velocity on
  52677. * @param velocity velocity to set
  52678. */
  52679. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52680. /**
  52681. * Sets the angular velocity of the physics body
  52682. * @param impostor imposter to set the velocity on
  52683. * @param velocity velocity to set
  52684. */
  52685. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52686. /**
  52687. * gets the linear velocity
  52688. * @param impostor imposter to get linear velocity from
  52689. * @returns linear velocity
  52690. */
  52691. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52692. /**
  52693. * gets the angular velocity
  52694. * @param impostor imposter to get angular velocity from
  52695. * @returns angular velocity
  52696. */
  52697. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52698. /**
  52699. * Sets the mass of physics body
  52700. * @param impostor imposter to set the mass on
  52701. * @param mass mass to set
  52702. */
  52703. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52704. /**
  52705. * Gets the mass of the physics body
  52706. * @param impostor imposter to get the mass from
  52707. * @returns mass
  52708. */
  52709. getBodyMass(impostor: PhysicsImpostor): number;
  52710. /**
  52711. * Gets friction of the impostor
  52712. * @param impostor impostor to get friction from
  52713. * @returns friction value
  52714. */
  52715. getBodyFriction(impostor: PhysicsImpostor): number;
  52716. /**
  52717. * Sets friction of the impostor
  52718. * @param impostor impostor to set friction on
  52719. * @param friction friction value
  52720. */
  52721. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52722. /**
  52723. * Gets restitution of the impostor
  52724. * @param impostor impostor to get restitution from
  52725. * @returns restitution value
  52726. */
  52727. getBodyRestitution(impostor: PhysicsImpostor): number;
  52728. /**
  52729. * Sets resitution of the impostor
  52730. * @param impostor impostor to set resitution on
  52731. * @param restitution resitution value
  52732. */
  52733. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52734. /**
  52735. * Gets pressure inside the impostor
  52736. * @param impostor impostor to get pressure from
  52737. * @returns pressure value
  52738. */
  52739. getBodyPressure(impostor: PhysicsImpostor): number;
  52740. /**
  52741. * Sets pressure inside a soft body impostor
  52742. * Cloth and rope must remain 0 pressure
  52743. * @param impostor impostor to set pressure on
  52744. * @param pressure pressure value
  52745. */
  52746. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52747. /**
  52748. * Gets stiffness of the impostor
  52749. * @param impostor impostor to get stiffness from
  52750. * @returns pressure value
  52751. */
  52752. getBodyStiffness(impostor: PhysicsImpostor): number;
  52753. /**
  52754. * Sets stiffness of the impostor
  52755. * @param impostor impostor to set stiffness on
  52756. * @param stiffness stiffness value from 0 to 1
  52757. */
  52758. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52759. /**
  52760. * Gets velocityIterations of the impostor
  52761. * @param impostor impostor to get velocity iterations from
  52762. * @returns velocityIterations value
  52763. */
  52764. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52765. /**
  52766. * Sets velocityIterations of the impostor
  52767. * @param impostor impostor to set velocity iterations on
  52768. * @param velocityIterations velocityIterations value
  52769. */
  52770. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52771. /**
  52772. * Gets positionIterations of the impostor
  52773. * @param impostor impostor to get position iterations from
  52774. * @returns positionIterations value
  52775. */
  52776. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52777. /**
  52778. * Sets positionIterations of the impostor
  52779. * @param impostor impostor to set position on
  52780. * @param positionIterations positionIterations value
  52781. */
  52782. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52783. /**
  52784. * Append an anchor to a cloth object
  52785. * @param impostor is the cloth impostor to add anchor to
  52786. * @param otherImpostor is the rigid impostor to anchor to
  52787. * @param width ratio across width from 0 to 1
  52788. * @param height ratio up height from 0 to 1
  52789. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52790. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52791. */
  52792. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52793. /**
  52794. * Append an hook to a rope object
  52795. * @param impostor is the rope impostor to add hook to
  52796. * @param otherImpostor is the rigid impostor to hook to
  52797. * @param length ratio along the rope from 0 to 1
  52798. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52799. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52800. */
  52801. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52802. /**
  52803. * Sleeps the physics body and stops it from being active
  52804. * @param impostor impostor to sleep
  52805. */
  52806. sleepBody(impostor: PhysicsImpostor): void;
  52807. /**
  52808. * Activates the physics body
  52809. * @param impostor impostor to activate
  52810. */
  52811. wakeUpBody(impostor: PhysicsImpostor): void;
  52812. /**
  52813. * Updates the distance parameters of the joint
  52814. * @param joint joint to update
  52815. * @param maxDistance maximum distance of the joint
  52816. * @param minDistance minimum distance of the joint
  52817. */
  52818. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52819. /**
  52820. * Sets a motor on the joint
  52821. * @param joint joint to set motor on
  52822. * @param speed speed of the motor
  52823. * @param maxForce maximum force of the motor
  52824. * @param motorIndex index of the motor
  52825. */
  52826. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52827. /**
  52828. * Sets the motors limit
  52829. * @param joint joint to set limit on
  52830. * @param upperLimit upper limit
  52831. * @param lowerLimit lower limit
  52832. */
  52833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52834. /**
  52835. * Syncs the position and rotation of a mesh with the impostor
  52836. * @param mesh mesh to sync
  52837. * @param impostor impostor to update the mesh with
  52838. */
  52839. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52840. /**
  52841. * Gets the radius of the impostor
  52842. * @param impostor impostor to get radius from
  52843. * @returns the radius
  52844. */
  52845. getRadius(impostor: PhysicsImpostor): number;
  52846. /**
  52847. * Gets the box size of the impostor
  52848. * @param impostor impostor to get box size from
  52849. * @param result the resulting box size
  52850. */
  52851. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52852. /**
  52853. * Disposes of the impostor
  52854. */
  52855. dispose(): void;
  52856. /**
  52857. * Does a raycast in the physics world
  52858. * @param from when should the ray start?
  52859. * @param to when should the ray end?
  52860. * @returns PhysicsRaycastResult
  52861. */
  52862. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52863. }
  52864. }
  52865. declare module "babylonjs/Probes/reflectionProbe" {
  52866. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52867. import { Vector3 } from "babylonjs/Maths/math.vector";
  52868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52869. import { Nullable } from "babylonjs/types";
  52870. import { Scene } from "babylonjs/scene";
  52871. module "babylonjs/abstractScene" {
  52872. interface AbstractScene {
  52873. /**
  52874. * The list of reflection probes added to the scene
  52875. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52876. */
  52877. reflectionProbes: Array<ReflectionProbe>;
  52878. /**
  52879. * Removes the given reflection probe from this scene.
  52880. * @param toRemove The reflection probe to remove
  52881. * @returns The index of the removed reflection probe
  52882. */
  52883. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52884. /**
  52885. * Adds the given reflection probe to this scene.
  52886. * @param newReflectionProbe The reflection probe to add
  52887. */
  52888. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52889. }
  52890. }
  52891. /**
  52892. * Class used to generate realtime reflection / refraction cube textures
  52893. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52894. */
  52895. export class ReflectionProbe {
  52896. /** defines the name of the probe */
  52897. name: string;
  52898. private _scene;
  52899. private _renderTargetTexture;
  52900. private _projectionMatrix;
  52901. private _viewMatrix;
  52902. private _target;
  52903. private _add;
  52904. private _attachedMesh;
  52905. private _invertYAxis;
  52906. /** Gets or sets probe position (center of the cube map) */
  52907. position: Vector3;
  52908. /**
  52909. * Creates a new reflection probe
  52910. * @param name defines the name of the probe
  52911. * @param size defines the texture resolution (for each face)
  52912. * @param scene defines the hosting scene
  52913. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52914. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52915. */
  52916. constructor(
  52917. /** defines the name of the probe */
  52918. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52919. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52920. samples: number;
  52921. /** Gets or sets the refresh rate to use (on every frame by default) */
  52922. refreshRate: number;
  52923. /**
  52924. * Gets the hosting scene
  52925. * @returns a Scene
  52926. */
  52927. getScene(): Scene;
  52928. /** Gets the internal CubeTexture used to render to */
  52929. readonly cubeTexture: RenderTargetTexture;
  52930. /** Gets the list of meshes to render */
  52931. readonly renderList: Nullable<AbstractMesh[]>;
  52932. /**
  52933. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52934. * @param mesh defines the mesh to attach to
  52935. */
  52936. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52937. /**
  52938. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52939. * @param renderingGroupId The rendering group id corresponding to its index
  52940. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52941. */
  52942. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52943. /**
  52944. * Clean all associated resources
  52945. */
  52946. dispose(): void;
  52947. /**
  52948. * Converts the reflection probe information to a readable string for debug purpose.
  52949. * @param fullDetails Supports for multiple levels of logging within scene loading
  52950. * @returns the human readable reflection probe info
  52951. */
  52952. toString(fullDetails?: boolean): string;
  52953. /**
  52954. * Get the class name of the relfection probe.
  52955. * @returns "ReflectionProbe"
  52956. */
  52957. getClassName(): string;
  52958. /**
  52959. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52960. * @returns The JSON representation of the texture
  52961. */
  52962. serialize(): any;
  52963. /**
  52964. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52965. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52966. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52967. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52968. * @returns The parsed reflection probe if successful
  52969. */
  52970. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52971. }
  52972. }
  52973. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52974. /** @hidden */
  52975. export var _BabylonLoaderRegistered: boolean;
  52976. }
  52977. declare module "babylonjs/Loading/Plugins/index" {
  52978. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52979. }
  52980. declare module "babylonjs/Loading/index" {
  52981. export * from "babylonjs/Loading/loadingScreen";
  52982. export * from "babylonjs/Loading/Plugins/index";
  52983. export * from "babylonjs/Loading/sceneLoader";
  52984. export * from "babylonjs/Loading/sceneLoaderFlags";
  52985. }
  52986. declare module "babylonjs/Materials/Background/index" {
  52987. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52988. }
  52989. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52990. import { Scene } from "babylonjs/scene";
  52991. import { Color3 } from "babylonjs/Maths/math.color";
  52992. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52994. /**
  52995. * The Physically based simple base material of BJS.
  52996. *
  52997. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52998. * It is used as the base class for both the specGloss and metalRough conventions.
  52999. */
  53000. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53001. /**
  53002. * Number of Simultaneous lights allowed on the material.
  53003. */
  53004. maxSimultaneousLights: number;
  53005. /**
  53006. * If sets to true, disables all the lights affecting the material.
  53007. */
  53008. disableLighting: boolean;
  53009. /**
  53010. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53011. */
  53012. environmentTexture: BaseTexture;
  53013. /**
  53014. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53015. */
  53016. invertNormalMapX: boolean;
  53017. /**
  53018. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53019. */
  53020. invertNormalMapY: boolean;
  53021. /**
  53022. * Normal map used in the model.
  53023. */
  53024. normalTexture: BaseTexture;
  53025. /**
  53026. * Emissivie color used to self-illuminate the model.
  53027. */
  53028. emissiveColor: Color3;
  53029. /**
  53030. * Emissivie texture used to self-illuminate the model.
  53031. */
  53032. emissiveTexture: BaseTexture;
  53033. /**
  53034. * Occlusion Channel Strenght.
  53035. */
  53036. occlusionStrength: number;
  53037. /**
  53038. * Occlusion Texture of the material (adding extra occlusion effects).
  53039. */
  53040. occlusionTexture: BaseTexture;
  53041. /**
  53042. * Defines the alpha limits in alpha test mode.
  53043. */
  53044. alphaCutOff: number;
  53045. /**
  53046. * Gets the current double sided mode.
  53047. */
  53048. /**
  53049. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53050. */
  53051. doubleSided: boolean;
  53052. /**
  53053. * Stores the pre-calculated light information of a mesh in a texture.
  53054. */
  53055. lightmapTexture: BaseTexture;
  53056. /**
  53057. * If true, the light map contains occlusion information instead of lighting info.
  53058. */
  53059. useLightmapAsShadowmap: boolean;
  53060. /**
  53061. * Instantiates a new PBRMaterial instance.
  53062. *
  53063. * @param name The material name
  53064. * @param scene The scene the material will be use in.
  53065. */
  53066. constructor(name: string, scene: Scene);
  53067. getClassName(): string;
  53068. }
  53069. }
  53070. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53071. import { Scene } from "babylonjs/scene";
  53072. import { Color3 } from "babylonjs/Maths/math.color";
  53073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53074. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53075. /**
  53076. * The PBR material of BJS following the metal roughness convention.
  53077. *
  53078. * This fits to the PBR convention in the GLTF definition:
  53079. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53080. */
  53081. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53082. /**
  53083. * The base color has two different interpretations depending on the value of metalness.
  53084. * When the material is a metal, the base color is the specific measured reflectance value
  53085. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53086. * of the material.
  53087. */
  53088. baseColor: Color3;
  53089. /**
  53090. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53091. * well as opacity information in the alpha channel.
  53092. */
  53093. baseTexture: BaseTexture;
  53094. /**
  53095. * Specifies the metallic scalar value of the material.
  53096. * Can also be used to scale the metalness values of the metallic texture.
  53097. */
  53098. metallic: number;
  53099. /**
  53100. * Specifies the roughness scalar value of the material.
  53101. * Can also be used to scale the roughness values of the metallic texture.
  53102. */
  53103. roughness: number;
  53104. /**
  53105. * Texture containing both the metallic value in the B channel and the
  53106. * roughness value in the G channel to keep better precision.
  53107. */
  53108. metallicRoughnessTexture: BaseTexture;
  53109. /**
  53110. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53111. *
  53112. * @param name The material name
  53113. * @param scene The scene the material will be use in.
  53114. */
  53115. constructor(name: string, scene: Scene);
  53116. /**
  53117. * Return the currrent class name of the material.
  53118. */
  53119. getClassName(): string;
  53120. /**
  53121. * Makes a duplicate of the current material.
  53122. * @param name - name to use for the new material.
  53123. */
  53124. clone(name: string): PBRMetallicRoughnessMaterial;
  53125. /**
  53126. * Serialize the material to a parsable JSON object.
  53127. */
  53128. serialize(): any;
  53129. /**
  53130. * Parses a JSON object correponding to the serialize function.
  53131. */
  53132. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53133. }
  53134. }
  53135. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53136. import { Scene } from "babylonjs/scene";
  53137. import { Color3 } from "babylonjs/Maths/math.color";
  53138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53139. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53140. /**
  53141. * The PBR material of BJS following the specular glossiness convention.
  53142. *
  53143. * This fits to the PBR convention in the GLTF definition:
  53144. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53145. */
  53146. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53147. /**
  53148. * Specifies the diffuse color of the material.
  53149. */
  53150. diffuseColor: Color3;
  53151. /**
  53152. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53153. * channel.
  53154. */
  53155. diffuseTexture: BaseTexture;
  53156. /**
  53157. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53158. */
  53159. specularColor: Color3;
  53160. /**
  53161. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53162. */
  53163. glossiness: number;
  53164. /**
  53165. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53166. */
  53167. specularGlossinessTexture: BaseTexture;
  53168. /**
  53169. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53170. *
  53171. * @param name The material name
  53172. * @param scene The scene the material will be use in.
  53173. */
  53174. constructor(name: string, scene: Scene);
  53175. /**
  53176. * Return the currrent class name of the material.
  53177. */
  53178. getClassName(): string;
  53179. /**
  53180. * Makes a duplicate of the current material.
  53181. * @param name - name to use for the new material.
  53182. */
  53183. clone(name: string): PBRSpecularGlossinessMaterial;
  53184. /**
  53185. * Serialize the material to a parsable JSON object.
  53186. */
  53187. serialize(): any;
  53188. /**
  53189. * Parses a JSON object correponding to the serialize function.
  53190. */
  53191. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53192. }
  53193. }
  53194. declare module "babylonjs/Materials/PBR/index" {
  53195. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53196. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53197. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53198. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53199. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53200. }
  53201. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53202. import { Nullable } from "babylonjs/types";
  53203. import { Scene } from "babylonjs/scene";
  53204. import { Matrix } from "babylonjs/Maths/math.vector";
  53205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53206. /**
  53207. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53208. * It can help converting any input color in a desired output one. This can then be used to create effects
  53209. * from sepia, black and white to sixties or futuristic rendering...
  53210. *
  53211. * The only supported format is currently 3dl.
  53212. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53213. */
  53214. export class ColorGradingTexture extends BaseTexture {
  53215. /**
  53216. * The current texture matrix. (will always be identity in color grading texture)
  53217. */
  53218. private _textureMatrix;
  53219. /**
  53220. * The texture URL.
  53221. */
  53222. url: string;
  53223. /**
  53224. * Empty line regex stored for GC.
  53225. */
  53226. private static _noneEmptyLineRegex;
  53227. private _engine;
  53228. /**
  53229. * Instantiates a ColorGradingTexture from the following parameters.
  53230. *
  53231. * @param url The location of the color gradind data (currently only supporting 3dl)
  53232. * @param scene The scene the texture will be used in
  53233. */
  53234. constructor(url: string, scene: Scene);
  53235. /**
  53236. * Returns the texture matrix used in most of the material.
  53237. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53238. */
  53239. getTextureMatrix(): Matrix;
  53240. /**
  53241. * Occurs when the file being loaded is a .3dl LUT file.
  53242. */
  53243. private load3dlTexture;
  53244. /**
  53245. * Starts the loading process of the texture.
  53246. */
  53247. private loadTexture;
  53248. /**
  53249. * Clones the color gradind texture.
  53250. */
  53251. clone(): ColorGradingTexture;
  53252. /**
  53253. * Called during delayed load for textures.
  53254. */
  53255. delayLoad(): void;
  53256. /**
  53257. * Parses a color grading texture serialized by Babylon.
  53258. * @param parsedTexture The texture information being parsedTexture
  53259. * @param scene The scene to load the texture in
  53260. * @param rootUrl The root url of the data assets to load
  53261. * @return A color gradind texture
  53262. */
  53263. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53264. /**
  53265. * Serializes the LUT texture to json format.
  53266. */
  53267. serialize(): any;
  53268. }
  53269. }
  53270. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53272. import { Scene } from "babylonjs/scene";
  53273. import { Nullable } from "babylonjs/types";
  53274. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53275. /**
  53276. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53277. */
  53278. export class EquiRectangularCubeTexture extends BaseTexture {
  53279. /** The six faces of the cube. */
  53280. private static _FacesMapping;
  53281. private _noMipmap;
  53282. private _onLoad;
  53283. private _onError;
  53284. /** The size of the cubemap. */
  53285. private _size;
  53286. /** The buffer of the image. */
  53287. private _buffer;
  53288. /** The width of the input image. */
  53289. private _width;
  53290. /** The height of the input image. */
  53291. private _height;
  53292. /** The URL to the image. */
  53293. url: string;
  53294. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53295. coordinatesMode: number;
  53296. /**
  53297. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53298. * @param url The location of the image
  53299. * @param scene The scene the texture will be used in
  53300. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53301. * @param noMipmap Forces to not generate the mipmap if true
  53302. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53303. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53304. * @param onLoad — defines a callback called when texture is loaded
  53305. * @param onError — defines a callback called if there is an error
  53306. */
  53307. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53308. /**
  53309. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53310. */
  53311. private loadImage;
  53312. /**
  53313. * Convert the image buffer into a cubemap and create a CubeTexture.
  53314. */
  53315. private loadTexture;
  53316. /**
  53317. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53318. * @param buffer The ArrayBuffer that should be converted.
  53319. * @returns The buffer as Float32Array.
  53320. */
  53321. private getFloat32ArrayFromArrayBuffer;
  53322. /**
  53323. * Get the current class name of the texture useful for serialization or dynamic coding.
  53324. * @returns "EquiRectangularCubeTexture"
  53325. */
  53326. getClassName(): string;
  53327. /**
  53328. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53329. * @returns A clone of the current EquiRectangularCubeTexture.
  53330. */
  53331. clone(): EquiRectangularCubeTexture;
  53332. }
  53333. }
  53334. declare module "babylonjs/Misc/tga" {
  53335. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53336. /**
  53337. * Based on jsTGALoader - Javascript loader for TGA file
  53338. * By Vincent Thibault
  53339. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53340. */
  53341. export class TGATools {
  53342. private static _TYPE_INDEXED;
  53343. private static _TYPE_RGB;
  53344. private static _TYPE_GREY;
  53345. private static _TYPE_RLE_INDEXED;
  53346. private static _TYPE_RLE_RGB;
  53347. private static _TYPE_RLE_GREY;
  53348. private static _ORIGIN_MASK;
  53349. private static _ORIGIN_SHIFT;
  53350. private static _ORIGIN_BL;
  53351. private static _ORIGIN_BR;
  53352. private static _ORIGIN_UL;
  53353. private static _ORIGIN_UR;
  53354. /**
  53355. * Gets the header of a TGA file
  53356. * @param data defines the TGA data
  53357. * @returns the header
  53358. */
  53359. static GetTGAHeader(data: Uint8Array): any;
  53360. /**
  53361. * Uploads TGA content to a Babylon Texture
  53362. * @hidden
  53363. */
  53364. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53365. /** @hidden */
  53366. 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;
  53367. /** @hidden */
  53368. 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;
  53369. /** @hidden */
  53370. 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;
  53371. /** @hidden */
  53372. 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;
  53373. /** @hidden */
  53374. 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;
  53375. /** @hidden */
  53376. 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;
  53377. }
  53378. }
  53379. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53380. import { Nullable } from "babylonjs/types";
  53381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53382. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53383. /**
  53384. * Implementation of the TGA Texture Loader.
  53385. * @hidden
  53386. */
  53387. export class _TGATextureLoader implements IInternalTextureLoader {
  53388. /**
  53389. * Defines wether the loader supports cascade loading the different faces.
  53390. */
  53391. readonly supportCascades: boolean;
  53392. /**
  53393. * This returns if the loader support the current file information.
  53394. * @param extension defines the file extension of the file being loaded
  53395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53396. * @param fallback defines the fallback internal texture if any
  53397. * @param isBase64 defines whether the texture is encoded as a base64
  53398. * @param isBuffer defines whether the texture data are stored as a buffer
  53399. * @returns true if the loader can load the specified file
  53400. */
  53401. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53402. /**
  53403. * Transform the url before loading if required.
  53404. * @param rootUrl the url of the texture
  53405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53406. * @returns the transformed texture
  53407. */
  53408. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53409. /**
  53410. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53411. * @param rootUrl the url of the texture
  53412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53413. * @returns the fallback texture
  53414. */
  53415. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53416. /**
  53417. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53418. * @param data contains the texture data
  53419. * @param texture defines the BabylonJS internal texture
  53420. * @param createPolynomials will be true if polynomials have been requested
  53421. * @param onLoad defines the callback to trigger once the texture is ready
  53422. * @param onError defines the callback to trigger in case of error
  53423. */
  53424. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53425. /**
  53426. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53427. * @param data contains the texture data
  53428. * @param texture defines the BabylonJS internal texture
  53429. * @param callback defines the method to call once ready to upload
  53430. */
  53431. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53432. }
  53433. }
  53434. declare module "babylonjs/Misc/basis" {
  53435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53436. /**
  53437. * Info about the .basis files
  53438. */
  53439. class BasisFileInfo {
  53440. /**
  53441. * If the file has alpha
  53442. */
  53443. hasAlpha: boolean;
  53444. /**
  53445. * Info about each image of the basis file
  53446. */
  53447. images: Array<{
  53448. levels: Array<{
  53449. width: number;
  53450. height: number;
  53451. transcodedPixels: ArrayBufferView;
  53452. }>;
  53453. }>;
  53454. }
  53455. /**
  53456. * Result of transcoding a basis file
  53457. */
  53458. class TranscodeResult {
  53459. /**
  53460. * Info about the .basis file
  53461. */
  53462. fileInfo: BasisFileInfo;
  53463. /**
  53464. * Format to use when loading the file
  53465. */
  53466. format: number;
  53467. }
  53468. /**
  53469. * Configuration options for the Basis transcoder
  53470. */
  53471. export class BasisTranscodeConfiguration {
  53472. /**
  53473. * Supported compression formats used to determine the supported output format of the transcoder
  53474. */
  53475. supportedCompressionFormats?: {
  53476. /**
  53477. * etc1 compression format
  53478. */
  53479. etc1?: boolean;
  53480. /**
  53481. * s3tc compression format
  53482. */
  53483. s3tc?: boolean;
  53484. /**
  53485. * pvrtc compression format
  53486. */
  53487. pvrtc?: boolean;
  53488. /**
  53489. * etc2 compression format
  53490. */
  53491. etc2?: boolean;
  53492. };
  53493. /**
  53494. * If mipmap levels should be loaded for transcoded images (Default: true)
  53495. */
  53496. loadMipmapLevels?: boolean;
  53497. /**
  53498. * Index of a single image to load (Default: all images)
  53499. */
  53500. loadSingleImage?: number;
  53501. }
  53502. /**
  53503. * Used to load .Basis files
  53504. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53505. */
  53506. export class BasisTools {
  53507. private static _IgnoreSupportedFormats;
  53508. /**
  53509. * URL to use when loading the basis transcoder
  53510. */
  53511. static JSModuleURL: string;
  53512. /**
  53513. * URL to use when loading the wasm module for the transcoder
  53514. */
  53515. static WasmModuleURL: string;
  53516. /**
  53517. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53518. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53519. * @returns internal format corresponding to the Basis format
  53520. */
  53521. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53522. private static _WorkerPromise;
  53523. private static _Worker;
  53524. private static _actionId;
  53525. private static _CreateWorkerAsync;
  53526. /**
  53527. * Transcodes a loaded image file to compressed pixel data
  53528. * @param imageData image data to transcode
  53529. * @param config configuration options for the transcoding
  53530. * @returns a promise resulting in the transcoded image
  53531. */
  53532. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53533. /**
  53534. * Loads a texture from the transcode result
  53535. * @param texture texture load to
  53536. * @param transcodeResult the result of transcoding the basis file to load from
  53537. */
  53538. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53539. }
  53540. }
  53541. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53542. import { Nullable } from "babylonjs/types";
  53543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53544. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53545. /**
  53546. * Loader for .basis file format
  53547. */
  53548. export class _BasisTextureLoader implements IInternalTextureLoader {
  53549. /**
  53550. * Defines whether the loader supports cascade loading the different faces.
  53551. */
  53552. readonly supportCascades: boolean;
  53553. /**
  53554. * This returns if the loader support the current file information.
  53555. * @param extension defines the file extension of the file being loaded
  53556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53557. * @param fallback defines the fallback internal texture if any
  53558. * @param isBase64 defines whether the texture is encoded as a base64
  53559. * @param isBuffer defines whether the texture data are stored as a buffer
  53560. * @returns true if the loader can load the specified file
  53561. */
  53562. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53563. /**
  53564. * Transform the url before loading if required.
  53565. * @param rootUrl the url of the texture
  53566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53567. * @returns the transformed texture
  53568. */
  53569. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53570. /**
  53571. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53572. * @param rootUrl the url of the texture
  53573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53574. * @returns the fallback texture
  53575. */
  53576. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53577. /**
  53578. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53579. * @param data contains the texture data
  53580. * @param texture defines the BabylonJS internal texture
  53581. * @param createPolynomials will be true if polynomials have been requested
  53582. * @param onLoad defines the callback to trigger once the texture is ready
  53583. * @param onError defines the callback to trigger in case of error
  53584. */
  53585. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53586. /**
  53587. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53588. * @param data contains the texture data
  53589. * @param texture defines the BabylonJS internal texture
  53590. * @param callback defines the method to call once ready to upload
  53591. */
  53592. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53593. }
  53594. }
  53595. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53596. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53597. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53598. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53599. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53600. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53601. }
  53602. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53603. import { Scene } from "babylonjs/scene";
  53604. import { Texture } from "babylonjs/Materials/Textures/texture";
  53605. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53606. /**
  53607. * 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.
  53608. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53609. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53610. */
  53611. export class CustomProceduralTexture extends ProceduralTexture {
  53612. private _animate;
  53613. private _time;
  53614. private _config;
  53615. private _texturePath;
  53616. /**
  53617. * Instantiates a new Custom Procedural Texture.
  53618. * 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.
  53619. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53620. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53621. * @param name Define the name of the texture
  53622. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53623. * @param size Define the size of the texture to create
  53624. * @param scene Define the scene the texture belongs to
  53625. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53626. * @param generateMipMaps Define if the texture should creates mip maps or not
  53627. */
  53628. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53629. private _loadJson;
  53630. /**
  53631. * Is the texture ready to be used ? (rendered at least once)
  53632. * @returns true if ready, otherwise, false.
  53633. */
  53634. isReady(): boolean;
  53635. /**
  53636. * Render the texture to its associated render target.
  53637. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53638. */
  53639. render(useCameraPostProcess?: boolean): void;
  53640. /**
  53641. * Update the list of dependant textures samplers in the shader.
  53642. */
  53643. updateTextures(): void;
  53644. /**
  53645. * Update the uniform values of the procedural texture in the shader.
  53646. */
  53647. updateShaderUniforms(): void;
  53648. /**
  53649. * Define if the texture animates or not.
  53650. */
  53651. animate: boolean;
  53652. }
  53653. }
  53654. declare module "babylonjs/Shaders/noise.fragment" {
  53655. /** @hidden */
  53656. export var noisePixelShader: {
  53657. name: string;
  53658. shader: string;
  53659. };
  53660. }
  53661. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53662. import { Nullable } from "babylonjs/types";
  53663. import { Scene } from "babylonjs/scene";
  53664. import { Texture } from "babylonjs/Materials/Textures/texture";
  53665. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53666. import "babylonjs/Shaders/noise.fragment";
  53667. /**
  53668. * Class used to generate noise procedural textures
  53669. */
  53670. export class NoiseProceduralTexture extends ProceduralTexture {
  53671. private _time;
  53672. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53673. brightness: number;
  53674. /** Defines the number of octaves to process */
  53675. octaves: number;
  53676. /** Defines the level of persistence (0.8 by default) */
  53677. persistence: number;
  53678. /** Gets or sets animation speed factor (default is 1) */
  53679. animationSpeedFactor: number;
  53680. /**
  53681. * Creates a new NoiseProceduralTexture
  53682. * @param name defines the name fo the texture
  53683. * @param size defines the size of the texture (default is 256)
  53684. * @param scene defines the hosting scene
  53685. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53686. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53687. */
  53688. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53689. private _updateShaderUniforms;
  53690. protected _getDefines(): string;
  53691. /** Generate the current state of the procedural texture */
  53692. render(useCameraPostProcess?: boolean): void;
  53693. /**
  53694. * Serializes this noise procedural texture
  53695. * @returns a serialized noise procedural texture object
  53696. */
  53697. serialize(): any;
  53698. /**
  53699. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53700. * @param parsedTexture defines parsed texture data
  53701. * @param scene defines the current scene
  53702. * @param rootUrl defines the root URL containing noise procedural texture information
  53703. * @returns a parsed NoiseProceduralTexture
  53704. */
  53705. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53706. }
  53707. }
  53708. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53709. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53710. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53711. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53712. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53713. }
  53714. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53715. import { Nullable } from "babylonjs/types";
  53716. import { Scene } from "babylonjs/scene";
  53717. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53718. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53719. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53720. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53721. /**
  53722. * Raw cube texture where the raw buffers are passed in
  53723. */
  53724. export class RawCubeTexture extends CubeTexture {
  53725. /**
  53726. * Creates a cube texture where the raw buffers are passed in.
  53727. * @param scene defines the scene the texture is attached to
  53728. * @param data defines the array of data to use to create each face
  53729. * @param size defines the size of the textures
  53730. * @param format defines the format of the data
  53731. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53732. * @param generateMipMaps defines if the engine should generate the mip levels
  53733. * @param invertY defines if data must be stored with Y axis inverted
  53734. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53735. * @param compression defines the compression used (null by default)
  53736. */
  53737. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53738. /**
  53739. * Updates the raw cube texture.
  53740. * @param data defines the data to store
  53741. * @param format defines the data format
  53742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53743. * @param invertY defines if data must be stored with Y axis inverted
  53744. * @param compression defines the compression used (null by default)
  53745. * @param level defines which level of the texture to update
  53746. */
  53747. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53748. /**
  53749. * Updates a raw cube texture with RGBD encoded data.
  53750. * @param data defines the array of data [mipmap][face] to use to create each face
  53751. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53752. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53753. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53754. * @returns a promsie that resolves when the operation is complete
  53755. */
  53756. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53757. /**
  53758. * Clones the raw cube texture.
  53759. * @return a new cube texture
  53760. */
  53761. clone(): CubeTexture;
  53762. /** @hidden */
  53763. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53764. }
  53765. }
  53766. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53767. import { Scene } from "babylonjs/scene";
  53768. import { Texture } from "babylonjs/Materials/Textures/texture";
  53769. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53770. /**
  53771. * Class used to store 3D textures containing user data
  53772. */
  53773. export class RawTexture3D extends Texture {
  53774. /** Gets or sets the texture format to use */
  53775. format: number;
  53776. private _engine;
  53777. /**
  53778. * Create a new RawTexture3D
  53779. * @param data defines the data of the texture
  53780. * @param width defines the width of the texture
  53781. * @param height defines the height of the texture
  53782. * @param depth defines the depth of the texture
  53783. * @param format defines the texture format to use
  53784. * @param scene defines the hosting scene
  53785. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53786. * @param invertY defines if texture must be stored with Y axis inverted
  53787. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53789. */
  53790. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53791. /** Gets or sets the texture format to use */
  53792. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53793. /**
  53794. * Update the texture with new data
  53795. * @param data defines the data to store in the texture
  53796. */
  53797. update(data: ArrayBufferView): void;
  53798. }
  53799. }
  53800. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53801. import { Scene } from "babylonjs/scene";
  53802. import { Plane } from "babylonjs/Maths/math.plane";
  53803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53804. /**
  53805. * Creates a refraction texture used by refraction channel of the standard material.
  53806. * It is like a mirror but to see through a material.
  53807. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53808. */
  53809. export class RefractionTexture extends RenderTargetTexture {
  53810. /**
  53811. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53812. * 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.
  53813. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53814. */
  53815. refractionPlane: Plane;
  53816. /**
  53817. * Define how deep under the surface we should see.
  53818. */
  53819. depth: number;
  53820. /**
  53821. * Creates a refraction texture used by refraction channel of the standard material.
  53822. * It is like a mirror but to see through a material.
  53823. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53824. * @param name Define the texture name
  53825. * @param size Define the size of the underlying texture
  53826. * @param scene Define the scene the refraction belongs to
  53827. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53828. */
  53829. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53830. /**
  53831. * Clone the refraction texture.
  53832. * @returns the cloned texture
  53833. */
  53834. clone(): RefractionTexture;
  53835. /**
  53836. * Serialize the texture to a JSON representation you could use in Parse later on
  53837. * @returns the serialized JSON representation
  53838. */
  53839. serialize(): any;
  53840. }
  53841. }
  53842. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53843. import { Nullable } from "babylonjs/types";
  53844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53845. import { Matrix } from "babylonjs/Maths/math.vector";
  53846. import { Engine } from "babylonjs/Engines/engine";
  53847. import { Scene } from "babylonjs/scene";
  53848. /**
  53849. * Defines the options related to the creation of an HtmlElementTexture
  53850. */
  53851. export interface IHtmlElementTextureOptions {
  53852. /**
  53853. * Defines wether mip maps should be created or not.
  53854. */
  53855. generateMipMaps?: boolean;
  53856. /**
  53857. * Defines the sampling mode of the texture.
  53858. */
  53859. samplingMode?: number;
  53860. /**
  53861. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53862. */
  53863. engine: Nullable<Engine>;
  53864. /**
  53865. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53866. */
  53867. scene: Nullable<Scene>;
  53868. }
  53869. /**
  53870. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53871. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53872. * is automatically managed.
  53873. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53874. * in your application.
  53875. *
  53876. * As the update is not automatic, you need to call them manually.
  53877. */
  53878. export class HtmlElementTexture extends BaseTexture {
  53879. /**
  53880. * The texture URL.
  53881. */
  53882. element: HTMLVideoElement | HTMLCanvasElement;
  53883. private static readonly DefaultOptions;
  53884. private _textureMatrix;
  53885. private _engine;
  53886. private _isVideo;
  53887. private _generateMipMaps;
  53888. private _samplingMode;
  53889. /**
  53890. * Instantiates a HtmlElementTexture from the following parameters.
  53891. *
  53892. * @param name Defines the name of the texture
  53893. * @param element Defines the video or canvas the texture is filled with
  53894. * @param options Defines the other none mandatory texture creation options
  53895. */
  53896. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53897. private _createInternalTexture;
  53898. /**
  53899. * Returns the texture matrix used in most of the material.
  53900. */
  53901. getTextureMatrix(): Matrix;
  53902. /**
  53903. * Updates the content of the texture.
  53904. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53905. */
  53906. update(invertY?: Nullable<boolean>): void;
  53907. }
  53908. }
  53909. declare module "babylonjs/Materials/Textures/index" {
  53910. export * from "babylonjs/Materials/Textures/baseTexture";
  53911. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53912. export * from "babylonjs/Materials/Textures/cubeTexture";
  53913. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53914. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53915. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53916. export * from "babylonjs/Materials/Textures/internalTexture";
  53917. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53918. export * from "babylonjs/Materials/Textures/Loaders/index";
  53919. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53920. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53921. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53922. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53923. export * from "babylonjs/Materials/Textures/rawTexture";
  53924. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53925. export * from "babylonjs/Materials/Textures/refractionTexture";
  53926. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53927. export * from "babylonjs/Materials/Textures/texture";
  53928. export * from "babylonjs/Materials/Textures/videoTexture";
  53929. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53930. }
  53931. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53932. /**
  53933. * Enum used to define the target of a block
  53934. */
  53935. export enum NodeMaterialBlockTargets {
  53936. /** Vertex shader */
  53937. Vertex = 1,
  53938. /** Fragment shader */
  53939. Fragment = 2,
  53940. /** Neutral */
  53941. Neutral = 4,
  53942. /** Vertex and Fragment */
  53943. VertexAndFragment = 3
  53944. }
  53945. }
  53946. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53947. /**
  53948. * Defines the kind of connection point for node based material
  53949. */
  53950. export enum NodeMaterialBlockConnectionPointTypes {
  53951. /** Float */
  53952. Float = 1,
  53953. /** Int */
  53954. Int = 2,
  53955. /** Vector2 */
  53956. Vector2 = 4,
  53957. /** Vector3 */
  53958. Vector3 = 8,
  53959. /** Vector4 */
  53960. Vector4 = 16,
  53961. /** Color3 */
  53962. Color3 = 32,
  53963. /** Color4 */
  53964. Color4 = 64,
  53965. /** Matrix */
  53966. Matrix = 128,
  53967. /** Detect type based on connection */
  53968. AutoDetect = 1024,
  53969. /** Output type that will be defined by input type */
  53970. BasedOnInput = 2048
  53971. }
  53972. }
  53973. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53975. /**
  53976. * Root class for all node material optimizers
  53977. */
  53978. export class NodeMaterialOptimizer {
  53979. /**
  53980. * Function used to optimize a NodeMaterial graph
  53981. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53982. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53983. */
  53984. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53985. }
  53986. }
  53987. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53991. import { Scene } from "babylonjs/scene";
  53992. /**
  53993. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53994. */
  53995. export class TransformBlock extends NodeMaterialBlock {
  53996. /**
  53997. * Defines the value to use to complement W value to transform it to a Vector4
  53998. */
  53999. complementW: number;
  54000. /**
  54001. * Defines the value to use to complement z value to transform it to a Vector4
  54002. */
  54003. complementZ: number;
  54004. /**
  54005. * Creates a new TransformBlock
  54006. * @param name defines the block name
  54007. */
  54008. constructor(name: string);
  54009. /**
  54010. * Gets the current class name
  54011. * @returns the class name
  54012. */
  54013. getClassName(): string;
  54014. /**
  54015. * Gets the vector input
  54016. */
  54017. readonly vector: NodeMaterialConnectionPoint;
  54018. /**
  54019. * Gets the output component
  54020. */
  54021. readonly output: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the matrix transform input
  54024. */
  54025. readonly transform: NodeMaterialConnectionPoint;
  54026. protected _buildBlock(state: NodeMaterialBuildState): this;
  54027. serialize(): any;
  54028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54029. }
  54030. }
  54031. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54035. /**
  54036. * Block used to output the vertex position
  54037. */
  54038. export class VertexOutputBlock extends NodeMaterialBlock {
  54039. /**
  54040. * Creates a new VertexOutputBlock
  54041. * @param name defines the block name
  54042. */
  54043. constructor(name: string);
  54044. /**
  54045. * Gets the current class name
  54046. * @returns the class name
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Gets the vector input component
  54051. */
  54052. readonly vector: NodeMaterialConnectionPoint;
  54053. protected _buildBlock(state: NodeMaterialBuildState): this;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54060. /**
  54061. * Block used to output the final color
  54062. */
  54063. export class FragmentOutputBlock extends NodeMaterialBlock {
  54064. /**
  54065. * Create a new FragmentOutputBlock
  54066. * @param name defines the block name
  54067. */
  54068. constructor(name: string);
  54069. /**
  54070. * Gets the current class name
  54071. * @returns the class name
  54072. */
  54073. getClassName(): string;
  54074. /**
  54075. * Gets the rgba input component
  54076. */
  54077. readonly rgba: NodeMaterialConnectionPoint;
  54078. /**
  54079. * Gets the rgb input component
  54080. */
  54081. readonly rgb: NodeMaterialConnectionPoint;
  54082. /**
  54083. * Gets the a input component
  54084. */
  54085. readonly a: NodeMaterialConnectionPoint;
  54086. protected _buildBlock(state: NodeMaterialBuildState): this;
  54087. }
  54088. }
  54089. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54091. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54092. import { Scene } from "babylonjs/scene";
  54093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54094. import { Matrix } from "babylonjs/Maths/math.vector";
  54095. import { Mesh } from "babylonjs/Meshes/mesh";
  54096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54097. import { Observable } from "babylonjs/Misc/observable";
  54098. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54100. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54101. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54102. import { Nullable } from "babylonjs/types";
  54103. /**
  54104. * Interface used to configure the node material editor
  54105. */
  54106. export interface INodeMaterialEditorOptions {
  54107. /** Define the URl to load node editor script */
  54108. editorURL?: string;
  54109. }
  54110. /** @hidden */
  54111. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54112. /** BONES */
  54113. NUM_BONE_INFLUENCERS: number;
  54114. BonesPerMesh: number;
  54115. BONETEXTURE: boolean;
  54116. /** MORPH TARGETS */
  54117. MORPHTARGETS: boolean;
  54118. MORPHTARGETS_NORMAL: boolean;
  54119. MORPHTARGETS_TANGENT: boolean;
  54120. MORPHTARGETS_UV: boolean;
  54121. NUM_MORPH_INFLUENCERS: number;
  54122. /** IMAGE PROCESSING */
  54123. IMAGEPROCESSING: boolean;
  54124. VIGNETTE: boolean;
  54125. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54126. VIGNETTEBLENDMODEOPAQUE: boolean;
  54127. TONEMAPPING: boolean;
  54128. TONEMAPPING_ACES: boolean;
  54129. CONTRAST: boolean;
  54130. EXPOSURE: boolean;
  54131. COLORCURVES: boolean;
  54132. COLORGRADING: boolean;
  54133. COLORGRADING3D: boolean;
  54134. SAMPLER3DGREENDEPTH: boolean;
  54135. SAMPLER3DBGRMAP: boolean;
  54136. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54137. constructor();
  54138. setValue(name: string, value: boolean): void;
  54139. }
  54140. /**
  54141. * Class used to configure NodeMaterial
  54142. */
  54143. export interface INodeMaterialOptions {
  54144. /**
  54145. * Defines if blocks should emit comments
  54146. */
  54147. emitComments: boolean;
  54148. }
  54149. /**
  54150. * Class used to create a node based material built by assembling shader blocks
  54151. */
  54152. export class NodeMaterial extends PushMaterial {
  54153. private static _BuildIdGenerator;
  54154. private _options;
  54155. private _vertexCompilationState;
  54156. private _fragmentCompilationState;
  54157. private _sharedData;
  54158. private _buildId;
  54159. private _buildWasSuccessful;
  54160. private _cachedWorldViewMatrix;
  54161. private _cachedWorldViewProjectionMatrix;
  54162. private _optimizers;
  54163. private _animationFrame;
  54164. /** Define the URl to load node editor script */
  54165. static EditorURL: string;
  54166. private BJSNODEMATERIALEDITOR;
  54167. /** Get the inspector from bundle or global */
  54168. private _getGlobalNodeMaterialEditor;
  54169. /**
  54170. * 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)
  54171. */
  54172. ignoreAlpha: boolean;
  54173. /**
  54174. * Defines the maximum number of lights that can be used in the material
  54175. */
  54176. maxSimultaneousLights: number;
  54177. /**
  54178. * Observable raised when the material is built
  54179. */
  54180. onBuildObservable: Observable<NodeMaterial>;
  54181. /**
  54182. * Gets or sets the root nodes of the material vertex shader
  54183. */
  54184. _vertexOutputNodes: NodeMaterialBlock[];
  54185. /**
  54186. * Gets or sets the root nodes of the material fragment (pixel) shader
  54187. */
  54188. _fragmentOutputNodes: NodeMaterialBlock[];
  54189. /** Gets or sets options to control the node material overall behavior */
  54190. options: INodeMaterialOptions;
  54191. /**
  54192. * Default configuration related to image processing available in the standard Material.
  54193. */
  54194. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54195. /**
  54196. * Gets the image processing configuration used either in this material.
  54197. */
  54198. /**
  54199. * Sets the Default image processing configuration used either in the this material.
  54200. *
  54201. * If sets to null, the scene one is in use.
  54202. */
  54203. imageProcessingConfiguration: ImageProcessingConfiguration;
  54204. /**
  54205. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54206. */
  54207. attachedBlocks: NodeMaterialBlock[];
  54208. /**
  54209. * Create a new node based material
  54210. * @param name defines the material name
  54211. * @param scene defines the hosting scene
  54212. * @param options defines creation option
  54213. */
  54214. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54215. /**
  54216. * Gets the current class name of the material e.g. "NodeMaterial"
  54217. * @returns the class name
  54218. */
  54219. getClassName(): string;
  54220. /**
  54221. * Keep track of the image processing observer to allow dispose and replace.
  54222. */
  54223. private _imageProcessingObserver;
  54224. /**
  54225. * Attaches a new image processing configuration to the Standard Material.
  54226. * @param configuration
  54227. */
  54228. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54229. /**
  54230. * Adds a new optimizer to the list of optimizers
  54231. * @param optimizer defines the optimizers to add
  54232. * @returns the current material
  54233. */
  54234. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54235. /**
  54236. * Remove an optimizer from the list of optimizers
  54237. * @param optimizer defines the optimizers to remove
  54238. * @returns the current material
  54239. */
  54240. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54241. /**
  54242. * Add a new block to the list of output nodes
  54243. * @param node defines the node to add
  54244. * @returns the current material
  54245. */
  54246. addOutputNode(node: NodeMaterialBlock): this;
  54247. /**
  54248. * Remove a block from the list of root nodes
  54249. * @param node defines the node to remove
  54250. * @returns the current material
  54251. */
  54252. removeOutputNode(node: NodeMaterialBlock): this;
  54253. private _addVertexOutputNode;
  54254. private _removeVertexOutputNode;
  54255. private _addFragmentOutputNode;
  54256. private _removeFragmentOutputNode;
  54257. /**
  54258. * Specifies if the material will require alpha blending
  54259. * @returns a boolean specifying if alpha blending is needed
  54260. */
  54261. needAlphaBlending(): boolean;
  54262. /**
  54263. * Specifies if this material should be rendered in alpha test mode
  54264. * @returns a boolean specifying if an alpha test is needed.
  54265. */
  54266. needAlphaTesting(): boolean;
  54267. private _initializeBlock;
  54268. private _resetDualBlocks;
  54269. /**
  54270. * Build the material and generates the inner effect
  54271. * @param verbose defines if the build should log activity
  54272. */
  54273. build(verbose?: boolean): void;
  54274. /**
  54275. * Runs an otpimization phase to try to improve the shader code
  54276. */
  54277. optimize(): void;
  54278. private _prepareDefinesForAttributes;
  54279. /**
  54280. * Get if the submesh is ready to be used and all its information available.
  54281. * Child classes can use it to update shaders
  54282. * @param mesh defines the mesh to check
  54283. * @param subMesh defines which submesh to check
  54284. * @param useInstances specifies that instances should be used
  54285. * @returns a boolean indicating that the submesh is ready or not
  54286. */
  54287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54288. /**
  54289. * Get a string representing the shaders built by the current node graph
  54290. */
  54291. readonly compiledShaders: string;
  54292. /**
  54293. * Binds the world matrix to the material
  54294. * @param world defines the world transformation matrix
  54295. */
  54296. bindOnlyWorldMatrix(world: Matrix): void;
  54297. /**
  54298. * Binds the submesh to this material by preparing the effect and shader to draw
  54299. * @param world defines the world transformation matrix
  54300. * @param mesh defines the mesh containing the submesh
  54301. * @param subMesh defines the submesh to bind the material to
  54302. */
  54303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54304. /**
  54305. * Gets the active textures from the material
  54306. * @returns an array of textures
  54307. */
  54308. getActiveTextures(): BaseTexture[];
  54309. /**
  54310. * Specifies if the material uses a texture
  54311. * @param texture defines the texture to check against the material
  54312. * @returns a boolean specifying if the material uses the texture
  54313. */
  54314. hasTexture(texture: BaseTexture): boolean;
  54315. /**
  54316. * Disposes the material
  54317. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54318. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54319. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54320. */
  54321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54322. /** Creates the node editor window. */
  54323. private _createNodeEditor;
  54324. /**
  54325. * Launch the node material editor
  54326. * @param config Define the configuration of the editor
  54327. * @return a promise fulfilled when the node editor is visible
  54328. */
  54329. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54330. /**
  54331. * Clear the current material
  54332. */
  54333. clear(): void;
  54334. /**
  54335. * Clear the current material and set it to a default state
  54336. */
  54337. setToDefault(): void;
  54338. private _gatherBlocks;
  54339. /**
  54340. * Serializes this material in a JSON representation
  54341. * @returns the serialized material object
  54342. */
  54343. serialize(): any;
  54344. /**
  54345. * Clear the current graph and load a new one from a serialization object
  54346. * @param source defines the JSON representation of the material
  54347. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54348. */
  54349. loadFromSerialization(source: any, rootUrl?: string): void;
  54350. /**
  54351. * Creates a node material from parsed material data
  54352. * @param source defines the JSON representation of the material
  54353. * @param scene defines the hosting scene
  54354. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54355. * @returns a new node material
  54356. */
  54357. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54358. }
  54359. }
  54360. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54366. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54367. import { Effect } from "babylonjs/Materials/effect";
  54368. import { Mesh } from "babylonjs/Meshes/mesh";
  54369. import { Nullable } from "babylonjs/types";
  54370. import { Scene } from "babylonjs/scene";
  54371. /**
  54372. * Block used to read a texture from a sampler
  54373. */
  54374. export class TextureBlock extends NodeMaterialBlock {
  54375. private _defineName;
  54376. private _samplerName;
  54377. private _transformedUVName;
  54378. private _textureTransformName;
  54379. private _textureInfoName;
  54380. private _mainUVName;
  54381. private _mainUVDefineName;
  54382. /**
  54383. * Gets or sets the texture associated with the node
  54384. */
  54385. texture: Nullable<BaseTexture>;
  54386. /**
  54387. * Create a new TextureBlock
  54388. * @param name defines the block name
  54389. */
  54390. constructor(name: string);
  54391. /**
  54392. * Gets the current class name
  54393. * @returns the class name
  54394. */
  54395. getClassName(): string;
  54396. /**
  54397. * Gets the uv input component
  54398. */
  54399. readonly uv: NodeMaterialConnectionPoint;
  54400. /**
  54401. * Gets the rgba output component
  54402. */
  54403. readonly rgba: NodeMaterialConnectionPoint;
  54404. /**
  54405. * Gets the rgb output component
  54406. */
  54407. readonly rgb: NodeMaterialConnectionPoint;
  54408. /**
  54409. * Gets the r output component
  54410. */
  54411. readonly r: NodeMaterialConnectionPoint;
  54412. /**
  54413. * Gets the g output component
  54414. */
  54415. readonly g: NodeMaterialConnectionPoint;
  54416. /**
  54417. * Gets the b output component
  54418. */
  54419. readonly b: NodeMaterialConnectionPoint;
  54420. /**
  54421. * Gets the a output component
  54422. */
  54423. readonly a: NodeMaterialConnectionPoint;
  54424. autoConfigure(): void;
  54425. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54427. isReady(): boolean;
  54428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54429. private _injectVertexCode;
  54430. private _writeOutput;
  54431. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54432. serialize(): any;
  54433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54437. /**
  54438. * Enum used to define well known values e.g. values automatically provided by the system
  54439. */
  54440. export enum NodeMaterialWellKnownValues {
  54441. /** World */
  54442. World = 1,
  54443. /** View */
  54444. View = 2,
  54445. /** Projection */
  54446. Projection = 3,
  54447. /** ViewProjection */
  54448. ViewProjection = 4,
  54449. /** WorldView */
  54450. WorldView = 5,
  54451. /** WorldViewProjection */
  54452. WorldViewProjection = 6,
  54453. /** CameraPosition */
  54454. CameraPosition = 7,
  54455. /** Fog Color */
  54456. FogColor = 8
  54457. }
  54458. }
  54459. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54465. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54466. import { Effect } from "babylonjs/Materials/effect";
  54467. import { Mesh } from "babylonjs/Meshes/mesh";
  54468. import { Nullable } from "babylonjs/types";
  54469. import { Scene } from "babylonjs/scene";
  54470. /**
  54471. * Block used to read a reflection texture from a sampler
  54472. */
  54473. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54474. private _define3DName;
  54475. private _defineCubicName;
  54476. private _defineExplicitName;
  54477. private _defineProjectionName;
  54478. private _defineLocalCubicName;
  54479. private _defineSphericalName;
  54480. private _definePlanarName;
  54481. private _defineEquirectangularName;
  54482. private _defineMirroredEquirectangularFixedName;
  54483. private _defineEquirectangularFixedName;
  54484. private _defineSkyboxName;
  54485. private _cubeSamplerName;
  54486. private _2DSamplerName;
  54487. private _positionUVWName;
  54488. private _directionWName;
  54489. private _reflectionCoordsName;
  54490. private _reflection2DCoordsName;
  54491. private _reflectionColorName;
  54492. private _reflectionMatrixName;
  54493. /**
  54494. * Gets or sets the texture associated with the node
  54495. */
  54496. texture: Nullable<BaseTexture>;
  54497. /**
  54498. * Create a new TextureBlock
  54499. * @param name defines the block name
  54500. */
  54501. constructor(name: string);
  54502. /**
  54503. * Gets the current class name
  54504. * @returns the class name
  54505. */
  54506. getClassName(): string;
  54507. /**
  54508. * Gets the world position input component
  54509. */
  54510. readonly position: NodeMaterialConnectionPoint;
  54511. /**
  54512. * Gets the world position input component
  54513. */
  54514. readonly worldPosition: NodeMaterialConnectionPoint;
  54515. /**
  54516. * Gets the world normal input component
  54517. */
  54518. readonly worldNormal: NodeMaterialConnectionPoint;
  54519. /**
  54520. * Gets the world input component
  54521. */
  54522. readonly world: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the camera (or eye) position component
  54525. */
  54526. readonly cameraPosition: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the view input component
  54529. */
  54530. readonly view: NodeMaterialConnectionPoint;
  54531. /**
  54532. * Gets the rgb output component
  54533. */
  54534. readonly rgb: NodeMaterialConnectionPoint;
  54535. /**
  54536. * Gets the r output component
  54537. */
  54538. readonly r: NodeMaterialConnectionPoint;
  54539. /**
  54540. * Gets the g output component
  54541. */
  54542. readonly g: NodeMaterialConnectionPoint;
  54543. /**
  54544. * Gets the b output component
  54545. */
  54546. readonly b: NodeMaterialConnectionPoint;
  54547. autoConfigure(): void;
  54548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54549. isReady(): boolean;
  54550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54551. private _injectVertexCode;
  54552. private _writeOutput;
  54553. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54554. serialize(): any;
  54555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54556. }
  54557. }
  54558. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54561. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54562. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54563. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54564. /**
  54565. * Class used to store shared data between 2 NodeMaterialBuildState
  54566. */
  54567. export class NodeMaterialBuildStateSharedData {
  54568. /**
  54569. * Gets the list of emitted varyings
  54570. */
  54571. varyings: string[];
  54572. /**
  54573. * Gets the varying declaration string
  54574. */
  54575. varyingDeclaration: string;
  54576. /**
  54577. * Input blocks
  54578. */
  54579. inputBlocks: InputBlock[];
  54580. /**
  54581. * Input blocks
  54582. */
  54583. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  54584. /**
  54585. * Bindable blocks (Blocks that need to set data to the effect)
  54586. */
  54587. bindableBlocks: NodeMaterialBlock[];
  54588. /**
  54589. * List of blocks that can provide a compilation fallback
  54590. */
  54591. blocksWithFallbacks: NodeMaterialBlock[];
  54592. /**
  54593. * List of blocks that can provide a define update
  54594. */
  54595. blocksWithDefines: NodeMaterialBlock[];
  54596. /**
  54597. * List of blocks that can provide a repeatable content
  54598. */
  54599. repeatableContentBlocks: NodeMaterialBlock[];
  54600. /**
  54601. * List of blocks that can provide a dynamic list of uniforms
  54602. */
  54603. dynamicUniformBlocks: NodeMaterialBlock[];
  54604. /**
  54605. * List of blocks that can block the isReady function for the material
  54606. */
  54607. blockingBlocks: NodeMaterialBlock[];
  54608. /**
  54609. * Gets the list of animated inputs
  54610. */
  54611. animatedInputs: InputBlock[];
  54612. /**
  54613. * Build Id used to avoid multiple recompilations
  54614. */
  54615. buildId: number;
  54616. /** List of emitted variables */
  54617. variableNames: {
  54618. [key: string]: number;
  54619. };
  54620. /** List of emitted defines */
  54621. defineNames: {
  54622. [key: string]: number;
  54623. };
  54624. /** Should emit comments? */
  54625. emitComments: boolean;
  54626. /** Emit build activity */
  54627. verbose: boolean;
  54628. /**
  54629. * Gets the compilation hints emitted at compilation time
  54630. */
  54631. hints: {
  54632. needWorldViewMatrix: boolean;
  54633. needWorldViewProjectionMatrix: boolean;
  54634. needAlphaBlending: boolean;
  54635. needAlphaTesting: boolean;
  54636. };
  54637. /**
  54638. * List of compilation checks
  54639. */
  54640. checks: {
  54641. emitVertex: boolean;
  54642. emitFragment: boolean;
  54643. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54644. };
  54645. /** Creates a new shared data */
  54646. constructor();
  54647. /**
  54648. * Emits console errors and exceptions if there is a failing check
  54649. */
  54650. emitErrors(): void;
  54651. }
  54652. }
  54653. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54654. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54655. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54656. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54657. /**
  54658. * Class used to store node based material build state
  54659. */
  54660. export class NodeMaterialBuildState {
  54661. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54662. supportUniformBuffers: boolean;
  54663. /**
  54664. * Gets the list of emitted attributes
  54665. */
  54666. attributes: string[];
  54667. /**
  54668. * Gets the list of emitted uniforms
  54669. */
  54670. uniforms: string[];
  54671. /**
  54672. * Gets the list of emitted uniform buffers
  54673. */
  54674. uniformBuffers: string[];
  54675. /**
  54676. * Gets the list of emitted samplers
  54677. */
  54678. samplers: string[];
  54679. /**
  54680. * Gets the list of emitted functions
  54681. */
  54682. functions: {
  54683. [key: string]: string;
  54684. };
  54685. /**
  54686. * Gets the target of the compilation state
  54687. */
  54688. target: NodeMaterialBlockTargets;
  54689. /**
  54690. * Gets the list of emitted counters
  54691. */
  54692. counters: {
  54693. [key: string]: number;
  54694. };
  54695. /**
  54696. * Shared data between multiple NodeMaterialBuildState instances
  54697. */
  54698. sharedData: NodeMaterialBuildStateSharedData;
  54699. /** @hidden */
  54700. _vertexState: NodeMaterialBuildState;
  54701. /** @hidden */
  54702. _attributeDeclaration: string;
  54703. /** @hidden */
  54704. _uniformDeclaration: string;
  54705. /** @hidden */
  54706. _samplerDeclaration: string;
  54707. /** @hidden */
  54708. _varyingTransfer: string;
  54709. private _repeatableContentAnchorIndex;
  54710. /** @hidden */
  54711. _builtCompilationString: string;
  54712. /**
  54713. * Gets the emitted compilation strings
  54714. */
  54715. compilationString: string;
  54716. /**
  54717. * Finalize the compilation strings
  54718. * @param state defines the current compilation state
  54719. */
  54720. finalize(state: NodeMaterialBuildState): void;
  54721. /** @hidden */
  54722. readonly _repeatableContentAnchor: string;
  54723. /** @hidden */
  54724. _getFreeVariableName(prefix: string): string;
  54725. /** @hidden */
  54726. _getFreeDefineName(prefix: string): string;
  54727. /** @hidden */
  54728. _excludeVariableName(name: string): void;
  54729. /** @hidden */
  54730. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54731. /** @hidden */
  54732. _emitFunction(name: string, code: string, comments: string): void;
  54733. /** @hidden */
  54734. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54735. replaceStrings?: {
  54736. search: RegExp;
  54737. replace: string;
  54738. }[];
  54739. repeatKey?: string;
  54740. }): string;
  54741. /** @hidden */
  54742. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54743. repeatKey?: string;
  54744. removeAttributes?: boolean;
  54745. removeUniforms?: boolean;
  54746. removeVaryings?: boolean;
  54747. removeIfDef?: boolean;
  54748. replaceStrings?: {
  54749. search: RegExp;
  54750. replace: string;
  54751. }[];
  54752. }, storeKey?: string): void;
  54753. /** @hidden */
  54754. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54755. /** @hidden */
  54756. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54757. }
  54758. }
  54759. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54760. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54762. import { Nullable } from "babylonjs/types";
  54763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54764. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54765. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54767. import { Mesh } from "babylonjs/Meshes/mesh";
  54768. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54769. import { Scene } from "babylonjs/scene";
  54770. /**
  54771. * Defines a block that can be used inside a node based material
  54772. */
  54773. export class NodeMaterialBlock {
  54774. private _buildId;
  54775. private _buildTarget;
  54776. private _target;
  54777. private _isFinalMerger;
  54778. private _isInput;
  54779. /** @hidden */
  54780. _inputs: NodeMaterialConnectionPoint[];
  54781. /** @hidden */
  54782. _outputs: NodeMaterialConnectionPoint[];
  54783. /**
  54784. * Gets or sets the name of the block
  54785. */
  54786. name: string;
  54787. /**
  54788. * Gets or sets the unique id of the node
  54789. */
  54790. uniqueId: number;
  54791. /**
  54792. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54793. */
  54794. readonly isFinalMerger: boolean;
  54795. /**
  54796. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54797. */
  54798. readonly isInput: boolean;
  54799. /**
  54800. * Gets or sets the build Id
  54801. */
  54802. buildId: number;
  54803. /**
  54804. * Gets or sets the target of the block
  54805. */
  54806. target: NodeMaterialBlockTargets;
  54807. /**
  54808. * Gets the list of input points
  54809. */
  54810. readonly inputs: NodeMaterialConnectionPoint[];
  54811. /** Gets the list of output points */
  54812. readonly outputs: NodeMaterialConnectionPoint[];
  54813. /**
  54814. * Find an input by its name
  54815. * @param name defines the name of the input to look for
  54816. * @returns the input or null if not found
  54817. */
  54818. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54819. /**
  54820. * Find an output by its name
  54821. * @param name defines the name of the outputto look for
  54822. * @returns the output or null if not found
  54823. */
  54824. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54825. /**
  54826. * Creates a new NodeMaterialBlock
  54827. * @param name defines the block name
  54828. * @param target defines the target of that block (Vertex by default)
  54829. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54830. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54831. */
  54832. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54833. /**
  54834. * Initialize the block and prepare the context for build
  54835. * @param state defines the state that will be used for the build
  54836. */
  54837. initialize(state: NodeMaterialBuildState): void;
  54838. /**
  54839. * Bind data to effect. Will only be called for blocks with isBindable === true
  54840. * @param effect defines the effect to bind data to
  54841. * @param nodeMaterial defines the hosting NodeMaterial
  54842. * @param mesh defines the mesh that will be rendered
  54843. */
  54844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54845. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54846. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54847. protected _writeFloat(value: number): string;
  54848. /**
  54849. * Gets the current class name e.g. "NodeMaterialBlock"
  54850. * @returns the class name
  54851. */
  54852. getClassName(): string;
  54853. /**
  54854. * Register a new input. Must be called inside a block constructor
  54855. * @param name defines the connection point name
  54856. * @param type defines the connection point type
  54857. * @param isOptional defines a boolean indicating that this input can be omitted
  54858. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54859. * @returns the current block
  54860. */
  54861. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54862. /**
  54863. * Register a new output. Must be called inside a block constructor
  54864. * @param name defines the connection point name
  54865. * @param type defines the connection point type
  54866. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54867. * @returns the current block
  54868. */
  54869. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54870. /**
  54871. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54872. * @param forOutput defines an optional connection point to check compatibility with
  54873. * @returns the first available input or null
  54874. */
  54875. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54876. /**
  54877. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54878. * @param forBlock defines an optional block to check compatibility with
  54879. * @returns the first available input or null
  54880. */
  54881. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54882. /**
  54883. * Gets the sibling of the given output
  54884. * @param current defines the current output
  54885. * @returns the next output in the list or null
  54886. */
  54887. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54888. /**
  54889. * Connect current block with another block
  54890. * @param other defines the block to connect with
  54891. * @param options define the various options to help pick the right connections
  54892. * @returns the current block
  54893. */
  54894. connectTo(other: NodeMaterialBlock, options?: {
  54895. input?: string;
  54896. output?: string;
  54897. outputSwizzle?: string;
  54898. }): this | undefined;
  54899. protected _buildBlock(state: NodeMaterialBuildState): void;
  54900. /**
  54901. * Add uniforms, samplers and uniform buffers at compilation time
  54902. * @param state defines the state to update
  54903. * @param nodeMaterial defines the node material requesting the update
  54904. * @param defines defines the material defines to update
  54905. */
  54906. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54907. /**
  54908. * Add potential fallbacks if shader compilation fails
  54909. * @param mesh defines the mesh to be rendered
  54910. * @param fallbacks defines the current prioritized list of fallbacks
  54911. */
  54912. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54913. /**
  54914. * Update defines for shader compilation
  54915. * @param mesh defines the mesh to be rendered
  54916. * @param nodeMaterial defines the node material requesting the update
  54917. * @param defines defines the material defines to update
  54918. * @param useInstances specifies that instances should be used
  54919. */
  54920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54921. /**
  54922. * Initialize defines for shader compilation
  54923. * @param mesh defines the mesh to be rendered
  54924. * @param nodeMaterial defines the node material requesting the update
  54925. * @param defines defines the material defines to be prepared
  54926. * @param useInstances specifies that instances should be used
  54927. */
  54928. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54929. /**
  54930. * Lets the block try to connect some inputs automatically
  54931. */
  54932. autoConfigure(): void;
  54933. /**
  54934. * Function called when a block is declared as repeatable content generator
  54935. * @param vertexShaderState defines the current compilation state for the vertex shader
  54936. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54937. * @param mesh defines the mesh to be rendered
  54938. * @param defines defines the material defines to update
  54939. */
  54940. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54941. /**
  54942. * Checks if the block is ready
  54943. * @param mesh defines the mesh to be rendered
  54944. * @param nodeMaterial defines the node material requesting the update
  54945. * @param defines defines the material defines to update
  54946. * @param useInstances specifies that instances should be used
  54947. * @returns true if the block is ready
  54948. */
  54949. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54950. private _processBuild;
  54951. /**
  54952. * Compile the current node and generate the shader code
  54953. * @param state defines the current compilation state (uniforms, samplers, current string)
  54954. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54955. * @returns true if already built
  54956. */
  54957. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54958. /**
  54959. * Clone the current block to a new identical block
  54960. * @param scene defines the hosting scene
  54961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54962. * @returns a copy of the current block
  54963. */
  54964. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54965. /**
  54966. * Serializes this block in a JSON representation
  54967. * @returns the serialized block object
  54968. */
  54969. serialize(): any;
  54970. /** @hidden */
  54971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54972. }
  54973. }
  54974. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54975. /**
  54976. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54977. */
  54978. export enum NodeMaterialBlockConnectionPointMode {
  54979. /** Value is an uniform */
  54980. Uniform = 0,
  54981. /** Value is a mesh attribute */
  54982. Attribute = 1,
  54983. /** Value is a varying between vertex and fragment shaders */
  54984. Varying = 2,
  54985. /** Mode is undefined */
  54986. Undefined = 3
  54987. }
  54988. }
  54989. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  54990. /**
  54991. * Enum defining the type of animations supported by InputBlock
  54992. */
  54993. export enum AnimatedInputBlockTypes {
  54994. /** No animation */
  54995. None = 0,
  54996. /** Time based animation. Will only work for floats */
  54997. Time = 1
  54998. }
  54999. }
  55000. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55002. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55003. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55004. import { Nullable } from "babylonjs/types";
  55005. import { Effect } from "babylonjs/Materials/effect";
  55006. import { Matrix } from "babylonjs/Maths/math.vector";
  55007. import { Scene } from "babylonjs/scene";
  55008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55010. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55011. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55012. /**
  55013. * Block used to expose an input value
  55014. */
  55015. export class InputBlock extends NodeMaterialBlock {
  55016. private _mode;
  55017. private _associatedVariableName;
  55018. private _storedValue;
  55019. private _valueCallback;
  55020. private _type;
  55021. private _animationType;
  55022. /** @hidden */
  55023. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55024. /**
  55025. * Gets or sets the connection point type (default is float)
  55026. */
  55027. readonly type: NodeMaterialBlockConnectionPointTypes;
  55028. /**
  55029. * Creates a new InputBlock
  55030. * @param name defines the block name
  55031. * @param target defines the target of that block (Vertex by default)
  55032. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55033. */
  55034. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55035. /**
  55036. * Gets the output component
  55037. */
  55038. readonly output: NodeMaterialConnectionPoint;
  55039. /**
  55040. * Set the source of this connection point to a vertex attribute
  55041. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55042. * @returns the current connection point
  55043. */
  55044. setAsAttribute(attributeName?: string): InputBlock;
  55045. /**
  55046. * Set the source of this connection point to a well known value
  55047. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55048. * @returns the current connection point
  55049. */
  55050. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55051. /**
  55052. * Gets or sets the value of that point.
  55053. * Please note that this value will be ignored if valueCallback is defined
  55054. */
  55055. value: any;
  55056. /**
  55057. * Gets or sets a callback used to get the value of that point.
  55058. * Please note that setting this value will force the connection point to ignore the value property
  55059. */
  55060. valueCallback: () => any;
  55061. /**
  55062. * Gets or sets the associated variable name in the shader
  55063. */
  55064. associatedVariableName: string;
  55065. /** Gets or sets the type of animation applied to the input */
  55066. animationType: AnimatedInputBlockTypes;
  55067. /**
  55068. * Gets a boolean indicating that this connection point not defined yet
  55069. */
  55070. readonly isUndefined: boolean;
  55071. /**
  55072. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55073. * In this case the connection point name must be the name of the uniform to use.
  55074. * Can only be set on inputs
  55075. */
  55076. isUniform: boolean;
  55077. /**
  55078. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55079. * In this case the connection point name must be the name of the attribute to use
  55080. * Can only be set on inputs
  55081. */
  55082. isAttribute: boolean;
  55083. /**
  55084. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55085. * Can only be set on exit points
  55086. */
  55087. isVarying: boolean;
  55088. /**
  55089. * Gets a boolean indicating that the current connection point is a well known value
  55090. */
  55091. readonly isWellKnownValue: boolean;
  55092. /**
  55093. * Gets or sets the current well known value or null if not defined as well know value
  55094. */
  55095. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55096. /**
  55097. * Gets the current class name
  55098. * @returns the class name
  55099. */
  55100. getClassName(): string;
  55101. /**
  55102. * Animate the input if animationType !== None
  55103. * @param scene defines the rendering scene
  55104. */
  55105. animate(scene: Scene): void;
  55106. private _emitDefine;
  55107. /**
  55108. * Set the input block to its default value (based on its type)
  55109. */
  55110. setDefaultValue(): void;
  55111. private _emit;
  55112. /** @hidden */
  55113. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55114. /** @hidden */
  55115. _transmit(effect: Effect, scene: Scene): void;
  55116. protected _buildBlock(state: NodeMaterialBuildState): void;
  55117. serialize(): any;
  55118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55119. }
  55120. }
  55121. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55122. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55123. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55124. import { Nullable } from "babylonjs/types";
  55125. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55127. /**
  55128. * Defines a connection point for a block
  55129. */
  55130. export class NodeMaterialConnectionPoint {
  55131. /** @hidden */
  55132. _ownerBlock: NodeMaterialBlock;
  55133. /** @hidden */
  55134. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55135. private _endpoints;
  55136. private _associatedVariableName;
  55137. /** @hidden */
  55138. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55139. private _type;
  55140. /** @hidden */
  55141. _enforceAssociatedVariableName: boolean;
  55142. /**
  55143. * Gets or sets the additional types supported byt this connection point
  55144. */
  55145. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55146. /**
  55147. * Gets or sets the associated variable name in the shader
  55148. */
  55149. associatedVariableName: string;
  55150. /**
  55151. * Gets or sets the connection point type (default is float)
  55152. */
  55153. type: NodeMaterialBlockConnectionPointTypes;
  55154. /**
  55155. * Gets or sets the connection point name
  55156. */
  55157. name: string;
  55158. /**
  55159. * Gets or sets a boolean indicating that this connection point can be omitted
  55160. */
  55161. isOptional: boolean;
  55162. /**
  55163. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55164. */
  55165. define: string;
  55166. /** Gets or sets the target of that connection point */
  55167. target: NodeMaterialBlockTargets;
  55168. /**
  55169. * Gets a boolean indicating that the current point is connected
  55170. */
  55171. readonly isConnected: boolean;
  55172. /**
  55173. * Gets a boolean indicating that the current point is connected to an input block
  55174. */
  55175. readonly isConnectedToInput: boolean;
  55176. /**
  55177. * Gets a the connected input block (if any)
  55178. */
  55179. readonly connectInputBlock: Nullable<InputBlock>;
  55180. /** Get the other side of the connection (if any) */
  55181. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55182. /** Get the block that owns this connection point */
  55183. readonly ownerBlock: NodeMaterialBlock;
  55184. /** Get the block connected on the other side of this connection (if any) */
  55185. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55186. /** Get the block connected on the endpoints of this connection (if any) */
  55187. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55188. /** Gets the list of connected endpoints */
  55189. readonly endpoints: NodeMaterialConnectionPoint[];
  55190. /**
  55191. * Creates a new connection point
  55192. * @param name defines the connection point name
  55193. * @param ownerBlock defines the block hosting this connection point
  55194. */
  55195. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55196. /**
  55197. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55198. * @returns the class name
  55199. */
  55200. getClassName(): string;
  55201. /**
  55202. * Gets an boolean indicating if the current point can be connected to another point
  55203. * @param connectionPoint defines the other connection point
  55204. * @returns true if the connection is possible
  55205. */
  55206. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55207. /**
  55208. * Connect this point to another connection point
  55209. * @param connectionPoint defines the other connection point
  55210. * @returns the current connection point
  55211. */
  55212. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55213. /**
  55214. * Disconnect this point from one of his endpoint
  55215. * @param endpoint defines the other connection point
  55216. * @returns the current connection point
  55217. */
  55218. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55219. /**
  55220. * Serializes this point in a JSON representation
  55221. * @returns the serialized point object
  55222. */
  55223. serialize(): any;
  55224. }
  55225. }
  55226. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55230. import { Mesh } from "babylonjs/Meshes/mesh";
  55231. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55233. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55234. /**
  55235. * Block used to add support for vertex skinning (bones)
  55236. */
  55237. export class BonesBlock extends NodeMaterialBlock {
  55238. /**
  55239. * Creates a new BonesBlock
  55240. * @param name defines the block name
  55241. */
  55242. constructor(name: string);
  55243. /**
  55244. * Initialize the block and prepare the context for build
  55245. * @param state defines the state that will be used for the build
  55246. */
  55247. initialize(state: NodeMaterialBuildState): void;
  55248. /**
  55249. * Gets the current class name
  55250. * @returns the class name
  55251. */
  55252. getClassName(): string;
  55253. /**
  55254. * Gets the matrix indices input component
  55255. */
  55256. readonly matricesIndices: NodeMaterialConnectionPoint;
  55257. /**
  55258. * Gets the matrix weights input component
  55259. */
  55260. readonly matricesWeights: NodeMaterialConnectionPoint;
  55261. /**
  55262. * Gets the extra matrix indices input component
  55263. */
  55264. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55265. /**
  55266. * Gets the extra matrix weights input component
  55267. */
  55268. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55269. /**
  55270. * Gets the world input component
  55271. */
  55272. readonly world: NodeMaterialConnectionPoint;
  55273. /**
  55274. * Gets the output component
  55275. */
  55276. readonly output: NodeMaterialConnectionPoint;
  55277. autoConfigure(): void;
  55278. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55281. protected _buildBlock(state: NodeMaterialBuildState): this;
  55282. }
  55283. }
  55284. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55289. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55290. /**
  55291. * Block used to add support for instances
  55292. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55293. */
  55294. export class InstancesBlock extends NodeMaterialBlock {
  55295. /**
  55296. * Creates a new InstancesBlock
  55297. * @param name defines the block name
  55298. */
  55299. constructor(name: string);
  55300. /**
  55301. * Gets the current class name
  55302. * @returns the class name
  55303. */
  55304. getClassName(): string;
  55305. /**
  55306. * Gets the first world row input component
  55307. */
  55308. readonly world0: NodeMaterialConnectionPoint;
  55309. /**
  55310. * Gets the second world row input component
  55311. */
  55312. readonly world1: NodeMaterialConnectionPoint;
  55313. /**
  55314. * Gets the third world row input component
  55315. */
  55316. readonly world2: NodeMaterialConnectionPoint;
  55317. /**
  55318. * Gets the forth world row input component
  55319. */
  55320. readonly world3: NodeMaterialConnectionPoint;
  55321. /**
  55322. * Gets the world input component
  55323. */
  55324. readonly world: NodeMaterialConnectionPoint;
  55325. /**
  55326. * Gets the output component
  55327. */
  55328. readonly output: NodeMaterialConnectionPoint;
  55329. autoConfigure(): void;
  55330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55331. protected _buildBlock(state: NodeMaterialBuildState): this;
  55332. }
  55333. }
  55334. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55339. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55340. import { Effect } from "babylonjs/Materials/effect";
  55341. import { Mesh } from "babylonjs/Meshes/mesh";
  55342. /**
  55343. * Block used to add morph targets support to vertex shader
  55344. */
  55345. export class MorphTargetsBlock extends NodeMaterialBlock {
  55346. private _repeatableContentAnchor;
  55347. private _repeatebleContentGenerated;
  55348. /**
  55349. * Create a new MorphTargetsBlock
  55350. * @param name defines the block name
  55351. */
  55352. constructor(name: string);
  55353. /**
  55354. * Gets the current class name
  55355. * @returns the class name
  55356. */
  55357. getClassName(): string;
  55358. /**
  55359. * Gets the position input component
  55360. */
  55361. readonly position: NodeMaterialConnectionPoint;
  55362. /**
  55363. * Gets the normal input component
  55364. */
  55365. readonly normal: NodeMaterialConnectionPoint;
  55366. /**
  55367. * Gets the tangent input component
  55368. */
  55369. readonly tangent: NodeMaterialConnectionPoint;
  55370. /**
  55371. * Gets the tangent input component
  55372. */
  55373. readonly uv: NodeMaterialConnectionPoint;
  55374. /**
  55375. * Gets the position output component
  55376. */
  55377. readonly positionOutput: NodeMaterialConnectionPoint;
  55378. /**
  55379. * Gets the normal output component
  55380. */
  55381. readonly normalOutput: NodeMaterialConnectionPoint;
  55382. /**
  55383. * Gets the tangent output component
  55384. */
  55385. readonly tangentOutput: NodeMaterialConnectionPoint;
  55386. /**
  55387. * Gets the tangent output component
  55388. */
  55389. readonly uvOutput: NodeMaterialConnectionPoint;
  55390. initialize(state: NodeMaterialBuildState): void;
  55391. autoConfigure(): void;
  55392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55394. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55395. protected _buildBlock(state: NodeMaterialBuildState): this;
  55396. }
  55397. }
  55398. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55399. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55400. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55401. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55402. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55403. }
  55404. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55408. /**
  55409. * Block used to add an alpha test in the fragment shader
  55410. */
  55411. export class AlphaTestBlock extends NodeMaterialBlock {
  55412. /**
  55413. * Gets or sets the alpha value where alpha testing happens
  55414. */
  55415. alphaCutOff: number;
  55416. /**
  55417. * Create a new AlphaTestBlock
  55418. * @param name defines the block name
  55419. */
  55420. constructor(name: string);
  55421. /**
  55422. * Gets the current class name
  55423. * @returns the class name
  55424. */
  55425. getClassName(): string;
  55426. /**
  55427. * Gets the color input component
  55428. */
  55429. readonly color: NodeMaterialConnectionPoint;
  55430. /**
  55431. * Gets the alpha input component
  55432. */
  55433. readonly alpha: NodeMaterialConnectionPoint;
  55434. protected _buildBlock(state: NodeMaterialBuildState): this;
  55435. }
  55436. }
  55437. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  55438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55441. /**
  55442. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55443. */
  55444. export class ColorMergerBlock extends NodeMaterialBlock {
  55445. /**
  55446. * Create a new ColorMergerBlock
  55447. * @param name defines the block name
  55448. */
  55449. constructor(name: string);
  55450. /**
  55451. * Gets the current class name
  55452. * @returns the class name
  55453. */
  55454. getClassName(): string;
  55455. /**
  55456. * Gets the r component (input)
  55457. */
  55458. readonly r: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the g component (input)
  55461. */
  55462. readonly g: NodeMaterialConnectionPoint;
  55463. /**
  55464. * Gets the b component (input)
  55465. */
  55466. readonly b: NodeMaterialConnectionPoint;
  55467. /**
  55468. * Gets the a component (input)
  55469. */
  55470. readonly a: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the rgba component (output)
  55473. */
  55474. readonly rgba: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the rgb component (output)
  55477. */
  55478. readonly rgb: NodeMaterialConnectionPoint;
  55479. protected _buildBlock(state: NodeMaterialBuildState): this;
  55480. }
  55481. }
  55482. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55486. /**
  55487. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55488. */
  55489. export class VectorMergerBlock extends NodeMaterialBlock {
  55490. /**
  55491. * Create a new VectorMergerBlock
  55492. * @param name defines the block name
  55493. */
  55494. constructor(name: string);
  55495. /**
  55496. * Gets the current class name
  55497. * @returns the class name
  55498. */
  55499. getClassName(): string;
  55500. /**
  55501. * Gets the x component (input)
  55502. */
  55503. readonly x: NodeMaterialConnectionPoint;
  55504. /**
  55505. * Gets the y component (input)
  55506. */
  55507. readonly y: NodeMaterialConnectionPoint;
  55508. /**
  55509. * Gets the z component (input)
  55510. */
  55511. readonly z: NodeMaterialConnectionPoint;
  55512. /**
  55513. * Gets the w component (input)
  55514. */
  55515. readonly w: NodeMaterialConnectionPoint;
  55516. /**
  55517. * Gets the xyzw component (output)
  55518. */
  55519. readonly xyzw: NodeMaterialConnectionPoint;
  55520. /**
  55521. * Gets the xyz component (output)
  55522. */
  55523. readonly xyz: NodeMaterialConnectionPoint;
  55524. /**
  55525. * Gets the xy component (output)
  55526. */
  55527. readonly xy: NodeMaterialConnectionPoint;
  55528. protected _buildBlock(state: NodeMaterialBuildState): this;
  55529. }
  55530. }
  55531. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55535. /**
  55536. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55537. */
  55538. export class ColorSplitterBlock extends NodeMaterialBlock {
  55539. /**
  55540. * Create a new ColorSplitterBlock
  55541. * @param name defines the block name
  55542. */
  55543. constructor(name: string);
  55544. /**
  55545. * Gets the current class name
  55546. * @returns the class name
  55547. */
  55548. getClassName(): string;
  55549. /**
  55550. * Gets the rgba component (input)
  55551. */
  55552. readonly rgba: NodeMaterialConnectionPoint;
  55553. /**
  55554. * Gets the rgb component (input)
  55555. */
  55556. readonly rgbIn: NodeMaterialConnectionPoint;
  55557. /**
  55558. * Gets the rgb component (output)
  55559. */
  55560. readonly rgbOut: NodeMaterialConnectionPoint;
  55561. /**
  55562. * Gets the r component (output)
  55563. */
  55564. readonly r: NodeMaterialConnectionPoint;
  55565. /**
  55566. * Gets the g component (output)
  55567. */
  55568. readonly g: NodeMaterialConnectionPoint;
  55569. /**
  55570. * Gets the b component (output)
  55571. */
  55572. readonly b: NodeMaterialConnectionPoint;
  55573. /**
  55574. * Gets the a component (output)
  55575. */
  55576. readonly a: NodeMaterialConnectionPoint;
  55577. protected _buildBlock(state: NodeMaterialBuildState): this;
  55578. }
  55579. }
  55580. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55584. /**
  55585. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55586. */
  55587. export class VectorSplitterBlock extends NodeMaterialBlock {
  55588. /**
  55589. * Create a new VectorSplitterBlock
  55590. * @param name defines the block name
  55591. */
  55592. constructor(name: string);
  55593. /**
  55594. * Gets the current class name
  55595. * @returns the class name
  55596. */
  55597. getClassName(): string;
  55598. /**
  55599. * Gets the xyzw component (input)
  55600. */
  55601. readonly xyzw: NodeMaterialConnectionPoint;
  55602. /**
  55603. * Gets the xyz component (input)
  55604. */
  55605. readonly xyzIn: NodeMaterialConnectionPoint;
  55606. /**
  55607. * Gets the xy component (input)
  55608. */
  55609. readonly xyIn: NodeMaterialConnectionPoint;
  55610. /**
  55611. * Gets the xyz component (output)
  55612. */
  55613. readonly xyzOut: NodeMaterialConnectionPoint;
  55614. /**
  55615. * Gets the xy component (output)
  55616. */
  55617. readonly xyOut: NodeMaterialConnectionPoint;
  55618. /**
  55619. * Gets the x component (output)
  55620. */
  55621. readonly x: NodeMaterialConnectionPoint;
  55622. /**
  55623. * Gets the y component (output)
  55624. */
  55625. readonly y: NodeMaterialConnectionPoint;
  55626. /**
  55627. * Gets the z component (output)
  55628. */
  55629. readonly z: NodeMaterialConnectionPoint;
  55630. /**
  55631. * Gets the w component (output)
  55632. */
  55633. readonly w: NodeMaterialConnectionPoint;
  55634. protected _buildBlock(state: NodeMaterialBuildState): this;
  55635. }
  55636. }
  55637. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55642. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55643. import { Effect } from "babylonjs/Materials/effect";
  55644. import { Mesh } from "babylonjs/Meshes/mesh";
  55645. /**
  55646. * Block used to add image processing support to fragment shader
  55647. */
  55648. export class ImageProcessingBlock extends NodeMaterialBlock {
  55649. /**
  55650. * Create a new ImageProcessingBlock
  55651. * @param name defines the block name
  55652. */
  55653. constructor(name: string);
  55654. /**
  55655. * Gets the current class name
  55656. * @returns the class name
  55657. */
  55658. getClassName(): string;
  55659. /**
  55660. * Gets the color input component
  55661. */
  55662. readonly color: NodeMaterialConnectionPoint;
  55663. /**
  55664. * Gets the output component
  55665. */
  55666. readonly output: NodeMaterialConnectionPoint;
  55667. /**
  55668. * Initialize the block and prepare the context for build
  55669. * @param state defines the state that will be used for the build
  55670. */
  55671. initialize(state: NodeMaterialBuildState): void;
  55672. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55675. protected _buildBlock(state: NodeMaterialBuildState): this;
  55676. }
  55677. }
  55678. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55679. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55680. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55681. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55682. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55683. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55684. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55685. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55686. }
  55687. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55690. import { Mesh } from "babylonjs/Meshes/mesh";
  55691. import { Effect } from "babylonjs/Materials/effect";
  55692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55695. /**
  55696. * Block used to add support for scene fog
  55697. */
  55698. export class FogBlock extends NodeMaterialBlock {
  55699. private _fogDistanceName;
  55700. private _fogParameters;
  55701. /**
  55702. * Create a new FogBlock
  55703. * @param name defines the block name
  55704. */
  55705. constructor(name: string);
  55706. /**
  55707. * Gets the current class name
  55708. * @returns the class name
  55709. */
  55710. getClassName(): string;
  55711. /**
  55712. * Gets the world position input component
  55713. */
  55714. readonly worldPosition: NodeMaterialConnectionPoint;
  55715. /**
  55716. * Gets the view input component
  55717. */
  55718. readonly view: NodeMaterialConnectionPoint;
  55719. /**
  55720. * Gets the color input component
  55721. */
  55722. readonly color: NodeMaterialConnectionPoint;
  55723. /**
  55724. * Gets the fog color input component
  55725. */
  55726. readonly fogColor: NodeMaterialConnectionPoint;
  55727. /**
  55728. * Gets the output component
  55729. */
  55730. readonly output: NodeMaterialConnectionPoint;
  55731. autoConfigure(): void;
  55732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55734. protected _buildBlock(state: NodeMaterialBuildState): this;
  55735. }
  55736. }
  55737. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55743. import { Effect } from "babylonjs/Materials/effect";
  55744. import { Mesh } from "babylonjs/Meshes/mesh";
  55745. import { Light } from "babylonjs/Lights/light";
  55746. import { Nullable } from "babylonjs/types";
  55747. import { Scene } from "babylonjs/scene";
  55748. /**
  55749. * Block used to add light in the fragment shader
  55750. */
  55751. export class LightBlock extends NodeMaterialBlock {
  55752. private _lightId;
  55753. /**
  55754. * Gets or sets the light associated with this block
  55755. */
  55756. light: Nullable<Light>;
  55757. /**
  55758. * Create a new LightBlock
  55759. * @param name defines the block name
  55760. */
  55761. constructor(name: string);
  55762. /**
  55763. * Gets the current class name
  55764. * @returns the class name
  55765. */
  55766. getClassName(): string;
  55767. /**
  55768. * Gets the world position input component
  55769. */
  55770. readonly worldPosition: NodeMaterialConnectionPoint;
  55771. /**
  55772. * Gets the world normal input component
  55773. */
  55774. readonly worldNormal: NodeMaterialConnectionPoint;
  55775. /**
  55776. * Gets the camera (or eye) position component
  55777. */
  55778. readonly cameraPosition: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the diffuse output component
  55781. */
  55782. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55783. /**
  55784. * Gets the specular output component
  55785. */
  55786. readonly specularOutput: NodeMaterialConnectionPoint;
  55787. autoConfigure(): void;
  55788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55789. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55791. private _injectVertexCode;
  55792. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55793. serialize(): any;
  55794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55795. }
  55796. }
  55797. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55798. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55799. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55800. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55801. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55802. }
  55803. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55804. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55805. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55806. }
  55807. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55811. /**
  55812. * Block used to multiply 2 values
  55813. */
  55814. export class MultiplyBlock extends NodeMaterialBlock {
  55815. /**
  55816. * Creates a new MultiplyBlock
  55817. * @param name defines the block name
  55818. */
  55819. constructor(name: string);
  55820. /**
  55821. * Gets the current class name
  55822. * @returns the class name
  55823. */
  55824. getClassName(): string;
  55825. /**
  55826. * Gets the left operand input component
  55827. */
  55828. readonly left: NodeMaterialConnectionPoint;
  55829. /**
  55830. * Gets the right operand input component
  55831. */
  55832. readonly right: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the output component
  55835. */
  55836. readonly output: NodeMaterialConnectionPoint;
  55837. protected _buildBlock(state: NodeMaterialBuildState): this;
  55838. }
  55839. }
  55840. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55844. /**
  55845. * Block used to add 2 vectors
  55846. */
  55847. export class AddBlock extends NodeMaterialBlock {
  55848. /**
  55849. * Creates a new AddBlock
  55850. * @param name defines the block name
  55851. */
  55852. constructor(name: string);
  55853. /**
  55854. * Gets the current class name
  55855. * @returns the class name
  55856. */
  55857. getClassName(): string;
  55858. /**
  55859. * Gets the left operand input component
  55860. */
  55861. readonly left: NodeMaterialConnectionPoint;
  55862. /**
  55863. * Gets the right operand input component
  55864. */
  55865. readonly right: NodeMaterialConnectionPoint;
  55866. /**
  55867. * Gets the output component
  55868. */
  55869. readonly output: NodeMaterialConnectionPoint;
  55870. protected _buildBlock(state: NodeMaterialBuildState): this;
  55871. }
  55872. }
  55873. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55877. /**
  55878. * Block used to scale a vector by a float
  55879. */
  55880. export class ScaleBlock extends NodeMaterialBlock {
  55881. /**
  55882. * Creates a new ScaleBlock
  55883. * @param name defines the block name
  55884. */
  55885. constructor(name: string);
  55886. /**
  55887. * Gets the current class name
  55888. * @returns the class name
  55889. */
  55890. getClassName(): string;
  55891. /**
  55892. * Gets the input component
  55893. */
  55894. readonly input: NodeMaterialConnectionPoint;
  55895. /**
  55896. * Gets the factor input component
  55897. */
  55898. readonly factor: NodeMaterialConnectionPoint;
  55899. /**
  55900. * Gets the output component
  55901. */
  55902. readonly output: NodeMaterialConnectionPoint;
  55903. protected _buildBlock(state: NodeMaterialBuildState): this;
  55904. }
  55905. }
  55906. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55910. /**
  55911. * Block used to clamp a float
  55912. */
  55913. export class ClampBlock extends NodeMaterialBlock {
  55914. /** Gets or sets the minimum range */
  55915. minimum: number;
  55916. /** Gets or sets the maximum range */
  55917. maximum: number;
  55918. /**
  55919. * Creates a new ClampBlock
  55920. * @param name defines the block name
  55921. */
  55922. constructor(name: string);
  55923. /**
  55924. * Gets the current class name
  55925. * @returns the class name
  55926. */
  55927. getClassName(): string;
  55928. /**
  55929. * Gets the value input component
  55930. */
  55931. readonly value: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the output component
  55934. */
  55935. readonly output: NodeMaterialConnectionPoint;
  55936. protected _buildBlock(state: NodeMaterialBuildState): this;
  55937. }
  55938. }
  55939. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55943. /**
  55944. * Block used to apply a cross product between 2 vectors
  55945. */
  55946. export class CrossBlock extends NodeMaterialBlock {
  55947. /**
  55948. * Creates a new CrossBlock
  55949. * @param name defines the block name
  55950. */
  55951. constructor(name: string);
  55952. /**
  55953. * Gets the current class name
  55954. * @returns the class name
  55955. */
  55956. getClassName(): string;
  55957. /**
  55958. * Gets the left operand input component
  55959. */
  55960. readonly left: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the right operand input component
  55963. */
  55964. readonly right: NodeMaterialConnectionPoint;
  55965. /**
  55966. * Gets the output component
  55967. */
  55968. readonly output: NodeMaterialConnectionPoint;
  55969. protected _buildBlock(state: NodeMaterialBuildState): this;
  55970. }
  55971. }
  55972. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55976. /**
  55977. * Block used to apply a dot product between 2 vectors
  55978. */
  55979. export class DotBlock extends NodeMaterialBlock {
  55980. /**
  55981. * Creates a new DotBlock
  55982. * @param name defines the block name
  55983. */
  55984. constructor(name: string);
  55985. /**
  55986. * Gets the current class name
  55987. * @returns the class name
  55988. */
  55989. getClassName(): string;
  55990. /**
  55991. * Gets the left operand input component
  55992. */
  55993. readonly left: NodeMaterialConnectionPoint;
  55994. /**
  55995. * Gets the right operand input component
  55996. */
  55997. readonly right: NodeMaterialConnectionPoint;
  55998. /**
  55999. * Gets the output component
  56000. */
  56001. readonly output: NodeMaterialConnectionPoint;
  56002. protected _buildBlock(state: NodeMaterialBuildState): this;
  56003. }
  56004. }
  56005. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56009. import { Vector2 } from "babylonjs/Maths/math.vector";
  56010. /**
  56011. * Block used to remap a float from a range to a new one
  56012. */
  56013. export class RemapBlock extends NodeMaterialBlock {
  56014. /**
  56015. * Gets or sets the source range
  56016. */
  56017. sourceRange: Vector2;
  56018. /**
  56019. * Gets or sets the target range
  56020. */
  56021. targetRange: Vector2;
  56022. /**
  56023. * Creates a new RemapBlock
  56024. * @param name defines the block name
  56025. */
  56026. constructor(name: string);
  56027. /**
  56028. * Gets the current class name
  56029. * @returns the class name
  56030. */
  56031. getClassName(): string;
  56032. /**
  56033. * Gets the input component
  56034. */
  56035. readonly input: NodeMaterialConnectionPoint;
  56036. /**
  56037. * Gets the output component
  56038. */
  56039. readonly output: NodeMaterialConnectionPoint;
  56040. protected _buildBlock(state: NodeMaterialBuildState): this;
  56041. }
  56042. }
  56043. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56047. /**
  56048. * Block used to normalize a vector
  56049. */
  56050. export class NormalizeBlock extends NodeMaterialBlock {
  56051. /**
  56052. * Creates a new NormalizeBlock
  56053. * @param name defines the block name
  56054. */
  56055. constructor(name: string);
  56056. /**
  56057. * Gets the current class name
  56058. * @returns the class name
  56059. */
  56060. getClassName(): string;
  56061. /**
  56062. * Gets the input component
  56063. */
  56064. readonly input: NodeMaterialConnectionPoint;
  56065. /**
  56066. * Gets the output component
  56067. */
  56068. readonly output: NodeMaterialConnectionPoint;
  56069. protected _buildBlock(state: NodeMaterialBuildState): this;
  56070. }
  56071. }
  56072. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56076. /**
  56077. * Operations supported by the Trigonometry block
  56078. */
  56079. export enum TrigonometryBlockOperations {
  56080. /** Cos */
  56081. Cos = 0,
  56082. /** Sin */
  56083. Sin = 1,
  56084. /** Abs */
  56085. Abs = 2
  56086. }
  56087. /**
  56088. * Block used to apply trigonometry operation to floats
  56089. */
  56090. export class TrigonometryBlock extends NodeMaterialBlock {
  56091. /**
  56092. * Gets or sets the operation applied by the block
  56093. */
  56094. operation: TrigonometryBlockOperations;
  56095. /**
  56096. * Creates a new TrigonometryBlock
  56097. * @param name defines the block name
  56098. */
  56099. constructor(name: string);
  56100. /**
  56101. * Gets the current class name
  56102. * @returns the class name
  56103. */
  56104. getClassName(): string;
  56105. /**
  56106. * Gets the input component
  56107. */
  56108. readonly input: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the output component
  56111. */
  56112. readonly output: NodeMaterialConnectionPoint;
  56113. protected _buildBlock(state: NodeMaterialBuildState): this;
  56114. }
  56115. }
  56116. declare module "babylonjs/Materials/Node/Blocks/index" {
  56117. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56118. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56119. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56120. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56121. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56122. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56123. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56124. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56125. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56126. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56127. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56128. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56129. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56130. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56131. }
  56132. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56133. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56134. }
  56135. declare module "babylonjs/Materials/Node/index" {
  56136. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56137. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56138. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56139. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56140. export * from "babylonjs/Materials/Node/nodeMaterial";
  56141. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56142. export * from "babylonjs/Materials/Node/Blocks/index";
  56143. export * from "babylonjs/Materials/Node/Optimizers/index";
  56144. }
  56145. declare module "babylonjs/Materials/effectRenderer" {
  56146. import { Nullable } from "babylonjs/types";
  56147. import { Texture } from "babylonjs/Materials/Textures/texture";
  56148. import { Engine } from "babylonjs/Engines/engine";
  56149. import { Viewport } from "babylonjs/Maths/math.viewport";
  56150. import { Observable } from "babylonjs/Misc/observable";
  56151. import { Effect } from "babylonjs/Materials/effect";
  56152. import "babylonjs/Shaders/postprocess.vertex";
  56153. /**
  56154. * Effect Render Options
  56155. */
  56156. export interface IEffectRendererOptions {
  56157. /**
  56158. * Defines the vertices positions.
  56159. */
  56160. positions?: number[];
  56161. /**
  56162. * Defines the indices.
  56163. */
  56164. indices?: number[];
  56165. }
  56166. /**
  56167. * Helper class to render one or more effects
  56168. */
  56169. export class EffectRenderer {
  56170. private engine;
  56171. private static _DefaultOptions;
  56172. private _vertexBuffers;
  56173. private _indexBuffer;
  56174. private _ringBufferIndex;
  56175. private _ringScreenBuffer;
  56176. private _fullscreenViewport;
  56177. private _getNextFrameBuffer;
  56178. /**
  56179. * Creates an effect renderer
  56180. * @param engine the engine to use for rendering
  56181. * @param options defines the options of the effect renderer
  56182. */
  56183. constructor(engine: Engine, options?: IEffectRendererOptions);
  56184. /**
  56185. * Sets the current viewport in normalized coordinates 0-1
  56186. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56187. */
  56188. setViewport(viewport?: Viewport): void;
  56189. /**
  56190. * Sets the current effect wrapper to use during draw.
  56191. * The effect needs to be ready before calling this api.
  56192. * This also sets the default full screen position attribute.
  56193. * @param effectWrapper Defines the effect to draw with
  56194. */
  56195. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56196. /**
  56197. * Draws a full screen quad.
  56198. */
  56199. draw(): void;
  56200. /**
  56201. * renders one or more effects to a specified texture
  56202. * @param effectWrappers list of effects to renderer
  56203. * @param outputTexture texture to draw to, if null it will render to the screen
  56204. */
  56205. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56206. /**
  56207. * Disposes of the effect renderer
  56208. */
  56209. dispose(): void;
  56210. }
  56211. /**
  56212. * Options to create an EffectWrapper
  56213. */
  56214. interface EffectWrapperCreationOptions {
  56215. /**
  56216. * Engine to use to create the effect
  56217. */
  56218. engine: Engine;
  56219. /**
  56220. * Fragment shader for the effect
  56221. */
  56222. fragmentShader: string;
  56223. /**
  56224. * Vertex shader for the effect
  56225. */
  56226. vertexShader?: string;
  56227. /**
  56228. * Attributes to use in the shader
  56229. */
  56230. attributeNames?: Array<string>;
  56231. /**
  56232. * Uniforms to use in the shader
  56233. */
  56234. uniformNames?: Array<string>;
  56235. /**
  56236. * Texture sampler names to use in the shader
  56237. */
  56238. samplerNames?: Array<string>;
  56239. /**
  56240. * The friendly name of the effect displayed in Spector.
  56241. */
  56242. name?: string;
  56243. }
  56244. /**
  56245. * Wraps an effect to be used for rendering
  56246. */
  56247. export class EffectWrapper {
  56248. /**
  56249. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56250. */
  56251. onApplyObservable: Observable<{}>;
  56252. /**
  56253. * The underlying effect
  56254. */
  56255. effect: Effect;
  56256. /**
  56257. * Creates an effect to be renderer
  56258. * @param creationOptions options to create the effect
  56259. */
  56260. constructor(creationOptions: EffectWrapperCreationOptions);
  56261. /**
  56262. * Disposes of the effect wrapper
  56263. */
  56264. dispose(): void;
  56265. }
  56266. }
  56267. declare module "babylonjs/Materials/index" {
  56268. export * from "babylonjs/Materials/Background/index";
  56269. export * from "babylonjs/Materials/colorCurves";
  56270. export * from "babylonjs/Materials/effect";
  56271. export * from "babylonjs/Materials/fresnelParameters";
  56272. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56273. export * from "babylonjs/Materials/material";
  56274. export * from "babylonjs/Materials/materialDefines";
  56275. export * from "babylonjs/Materials/materialHelper";
  56276. export * from "babylonjs/Materials/multiMaterial";
  56277. export * from "babylonjs/Materials/PBR/index";
  56278. export * from "babylonjs/Materials/pushMaterial";
  56279. export * from "babylonjs/Materials/shaderMaterial";
  56280. export * from "babylonjs/Materials/standardMaterial";
  56281. export * from "babylonjs/Materials/Textures/index";
  56282. export * from "babylonjs/Materials/uniformBuffer";
  56283. export * from "babylonjs/Materials/materialFlags";
  56284. export * from "babylonjs/Materials/Node/index";
  56285. export * from "babylonjs/Materials/effectRenderer";
  56286. }
  56287. declare module "babylonjs/Maths/index" {
  56288. export * from "babylonjs/Maths/math.scalar";
  56289. export * from "babylonjs/Maths/math";
  56290. export * from "babylonjs/Maths/sphericalPolynomial";
  56291. }
  56292. declare module "babylonjs/Misc/workerPool" {
  56293. import { IDisposable } from "babylonjs/scene";
  56294. /**
  56295. * Helper class to push actions to a pool of workers.
  56296. */
  56297. export class WorkerPool implements IDisposable {
  56298. private _workerInfos;
  56299. private _pendingActions;
  56300. /**
  56301. * Constructor
  56302. * @param workers Array of workers to use for actions
  56303. */
  56304. constructor(workers: Array<Worker>);
  56305. /**
  56306. * Terminates all workers and clears any pending actions.
  56307. */
  56308. dispose(): void;
  56309. /**
  56310. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56311. * pended until a worker has completed its action.
  56312. * @param action The action to perform. Call onComplete when the action is complete.
  56313. */
  56314. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56315. private _execute;
  56316. }
  56317. }
  56318. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56319. import { IDisposable } from "babylonjs/scene";
  56320. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56321. /**
  56322. * Configuration for Draco compression
  56323. */
  56324. export interface IDracoCompressionConfiguration {
  56325. /**
  56326. * Configuration for the decoder.
  56327. */
  56328. decoder: {
  56329. /**
  56330. * The url to the WebAssembly module.
  56331. */
  56332. wasmUrl?: string;
  56333. /**
  56334. * The url to the WebAssembly binary.
  56335. */
  56336. wasmBinaryUrl?: string;
  56337. /**
  56338. * The url to the fallback JavaScript module.
  56339. */
  56340. fallbackUrl?: string;
  56341. };
  56342. }
  56343. /**
  56344. * Draco compression (https://google.github.io/draco/)
  56345. *
  56346. * This class wraps the Draco module.
  56347. *
  56348. * **Encoder**
  56349. *
  56350. * The encoder is not currently implemented.
  56351. *
  56352. * **Decoder**
  56353. *
  56354. * 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.
  56355. *
  56356. * To update the configuration, use the following code:
  56357. * ```javascript
  56358. * DracoCompression.Configuration = {
  56359. * decoder: {
  56360. * wasmUrl: "<url to the WebAssembly library>",
  56361. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56362. * fallbackUrl: "<url to the fallback JavaScript library>",
  56363. * }
  56364. * };
  56365. * ```
  56366. *
  56367. * 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.
  56368. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56369. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56370. *
  56371. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56372. * ```javascript
  56373. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56374. * ```
  56375. *
  56376. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56377. */
  56378. export class DracoCompression implements IDisposable {
  56379. private _workerPoolPromise?;
  56380. private _decoderModulePromise?;
  56381. /**
  56382. * The configuration. Defaults to the following urls:
  56383. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56384. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56385. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56386. */
  56387. static Configuration: IDracoCompressionConfiguration;
  56388. /**
  56389. * Returns true if the decoder configuration is available.
  56390. */
  56391. static readonly DecoderAvailable: boolean;
  56392. /**
  56393. * Default number of workers to create when creating the draco compression object.
  56394. */
  56395. static DefaultNumWorkers: number;
  56396. private static GetDefaultNumWorkers;
  56397. private static _Default;
  56398. /**
  56399. * Default instance for the draco compression object.
  56400. */
  56401. static readonly Default: DracoCompression;
  56402. /**
  56403. * Constructor
  56404. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56405. */
  56406. constructor(numWorkers?: number);
  56407. /**
  56408. * Stop all async operations and release resources.
  56409. */
  56410. dispose(): void;
  56411. /**
  56412. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56413. * @returns a promise that resolves when ready
  56414. */
  56415. whenReadyAsync(): Promise<void>;
  56416. /**
  56417. * Decode Draco compressed mesh data to vertex data.
  56418. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56419. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56420. * @returns A promise that resolves with the decoded vertex data
  56421. */
  56422. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56423. [kind: string]: number;
  56424. }): Promise<VertexData>;
  56425. }
  56426. }
  56427. declare module "babylonjs/Meshes/Compression/index" {
  56428. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56429. }
  56430. declare module "babylonjs/Meshes/csg" {
  56431. import { Nullable } from "babylonjs/types";
  56432. import { Scene } from "babylonjs/scene";
  56433. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56434. import { Mesh } from "babylonjs/Meshes/mesh";
  56435. import { Material } from "babylonjs/Materials/material";
  56436. /**
  56437. * Class for building Constructive Solid Geometry
  56438. */
  56439. export class CSG {
  56440. private polygons;
  56441. /**
  56442. * The world matrix
  56443. */
  56444. matrix: Matrix;
  56445. /**
  56446. * Stores the position
  56447. */
  56448. position: Vector3;
  56449. /**
  56450. * Stores the rotation
  56451. */
  56452. rotation: Vector3;
  56453. /**
  56454. * Stores the rotation quaternion
  56455. */
  56456. rotationQuaternion: Nullable<Quaternion>;
  56457. /**
  56458. * Stores the scaling vector
  56459. */
  56460. scaling: Vector3;
  56461. /**
  56462. * Convert the Mesh to CSG
  56463. * @param mesh The Mesh to convert to CSG
  56464. * @returns A new CSG from the Mesh
  56465. */
  56466. static FromMesh(mesh: Mesh): CSG;
  56467. /**
  56468. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56469. * @param polygons Polygons used to construct a CSG solid
  56470. */
  56471. private static FromPolygons;
  56472. /**
  56473. * Clones, or makes a deep copy, of the CSG
  56474. * @returns A new CSG
  56475. */
  56476. clone(): CSG;
  56477. /**
  56478. * Unions this CSG with another CSG
  56479. * @param csg The CSG to union against this CSG
  56480. * @returns The unioned CSG
  56481. */
  56482. union(csg: CSG): CSG;
  56483. /**
  56484. * Unions this CSG with another CSG in place
  56485. * @param csg The CSG to union against this CSG
  56486. */
  56487. unionInPlace(csg: CSG): void;
  56488. /**
  56489. * Subtracts this CSG with another CSG
  56490. * @param csg The CSG to subtract against this CSG
  56491. * @returns A new CSG
  56492. */
  56493. subtract(csg: CSG): CSG;
  56494. /**
  56495. * Subtracts this CSG with another CSG in place
  56496. * @param csg The CSG to subtact against this CSG
  56497. */
  56498. subtractInPlace(csg: CSG): void;
  56499. /**
  56500. * Intersect this CSG with another CSG
  56501. * @param csg The CSG to intersect against this CSG
  56502. * @returns A new CSG
  56503. */
  56504. intersect(csg: CSG): CSG;
  56505. /**
  56506. * Intersects this CSG with another CSG in place
  56507. * @param csg The CSG to intersect against this CSG
  56508. */
  56509. intersectInPlace(csg: CSG): void;
  56510. /**
  56511. * Return a new CSG solid with solid and empty space switched. This solid is
  56512. * not modified.
  56513. * @returns A new CSG solid with solid and empty space switched
  56514. */
  56515. inverse(): CSG;
  56516. /**
  56517. * Inverses the CSG in place
  56518. */
  56519. inverseInPlace(): void;
  56520. /**
  56521. * This is used to keep meshes transformations so they can be restored
  56522. * when we build back a Babylon Mesh
  56523. * NB : All CSG operations are performed in world coordinates
  56524. * @param csg The CSG to copy the transform attributes from
  56525. * @returns This CSG
  56526. */
  56527. copyTransformAttributes(csg: CSG): CSG;
  56528. /**
  56529. * Build Raw mesh from CSG
  56530. * Coordinates here are in world space
  56531. * @param name The name of the mesh geometry
  56532. * @param scene The Scene
  56533. * @param keepSubMeshes Specifies if the submeshes should be kept
  56534. * @returns A new Mesh
  56535. */
  56536. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56537. /**
  56538. * Build Mesh from CSG taking material and transforms into account
  56539. * @param name The name of the Mesh
  56540. * @param material The material of the Mesh
  56541. * @param scene The Scene
  56542. * @param keepSubMeshes Specifies if submeshes should be kept
  56543. * @returns The new Mesh
  56544. */
  56545. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56546. }
  56547. }
  56548. declare module "babylonjs/Meshes/trailMesh" {
  56549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56550. import { Mesh } from "babylonjs/Meshes/mesh";
  56551. import { Scene } from "babylonjs/scene";
  56552. /**
  56553. * Class used to create a trail following a mesh
  56554. */
  56555. export class TrailMesh extends Mesh {
  56556. private _generator;
  56557. private _autoStart;
  56558. private _running;
  56559. private _diameter;
  56560. private _length;
  56561. private _sectionPolygonPointsCount;
  56562. private _sectionVectors;
  56563. private _sectionNormalVectors;
  56564. private _beforeRenderObserver;
  56565. /**
  56566. * @constructor
  56567. * @param name The value used by scene.getMeshByName() to do a lookup.
  56568. * @param generator The mesh to generate a trail.
  56569. * @param scene The scene to add this mesh to.
  56570. * @param diameter Diameter of trailing mesh. Default is 1.
  56571. * @param length Length of trailing mesh. Default is 60.
  56572. * @param autoStart Automatically start trailing mesh. Default true.
  56573. */
  56574. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56575. /**
  56576. * "TrailMesh"
  56577. * @returns "TrailMesh"
  56578. */
  56579. getClassName(): string;
  56580. private _createMesh;
  56581. /**
  56582. * Start trailing mesh.
  56583. */
  56584. start(): void;
  56585. /**
  56586. * Stop trailing mesh.
  56587. */
  56588. stop(): void;
  56589. /**
  56590. * Update trailing mesh geometry.
  56591. */
  56592. update(): void;
  56593. /**
  56594. * Returns a new TrailMesh object.
  56595. * @param name is a string, the name given to the new mesh
  56596. * @param newGenerator use new generator object for cloned trail mesh
  56597. * @returns a new mesh
  56598. */
  56599. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56600. /**
  56601. * Serializes this trail mesh
  56602. * @param serializationObject object to write serialization to
  56603. */
  56604. serialize(serializationObject: any): void;
  56605. /**
  56606. * Parses a serialized trail mesh
  56607. * @param parsedMesh the serialized mesh
  56608. * @param scene the scene to create the trail mesh in
  56609. * @returns the created trail mesh
  56610. */
  56611. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56612. }
  56613. }
  56614. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56615. import { Nullable } from "babylonjs/types";
  56616. import { Scene } from "babylonjs/scene";
  56617. import { Vector4 } from "babylonjs/Maths/math.vector";
  56618. import { Color4 } from "babylonjs/Maths/math.color";
  56619. import { Mesh } from "babylonjs/Meshes/mesh";
  56620. /**
  56621. * Class containing static functions to help procedurally build meshes
  56622. */
  56623. export class TiledBoxBuilder {
  56624. /**
  56625. * Creates a box mesh
  56626. * 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)
  56627. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56631. * @param name defines the name of the mesh
  56632. * @param options defines the options used to create the mesh
  56633. * @param scene defines the hosting scene
  56634. * @returns the box mesh
  56635. */
  56636. static CreateTiledBox(name: string, options: {
  56637. pattern?: number;
  56638. width?: number;
  56639. height?: number;
  56640. depth?: number;
  56641. tileSize?: number;
  56642. tileWidth?: number;
  56643. tileHeight?: number;
  56644. alignHorizontal?: number;
  56645. alignVertical?: number;
  56646. faceUV?: Vector4[];
  56647. faceColors?: Color4[];
  56648. sideOrientation?: number;
  56649. updatable?: boolean;
  56650. }, scene?: Nullable<Scene>): Mesh;
  56651. }
  56652. }
  56653. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56654. import { Vector4 } from "babylonjs/Maths/math.vector";
  56655. import { Mesh } from "babylonjs/Meshes/mesh";
  56656. /**
  56657. * Class containing static functions to help procedurally build meshes
  56658. */
  56659. export class TorusKnotBuilder {
  56660. /**
  56661. * Creates a torus knot mesh
  56662. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56663. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56664. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56665. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56669. * @param name defines the name of the mesh
  56670. * @param options defines the options used to create the mesh
  56671. * @param scene defines the hosting scene
  56672. * @returns the torus knot mesh
  56673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56674. */
  56675. static CreateTorusKnot(name: string, options: {
  56676. radius?: number;
  56677. tube?: number;
  56678. radialSegments?: number;
  56679. tubularSegments?: number;
  56680. p?: number;
  56681. q?: number;
  56682. updatable?: boolean;
  56683. sideOrientation?: number;
  56684. frontUVs?: Vector4;
  56685. backUVs?: Vector4;
  56686. }, scene: any): Mesh;
  56687. }
  56688. }
  56689. declare module "babylonjs/Meshes/polygonMesh" {
  56690. import { Scene } from "babylonjs/scene";
  56691. import { Vector2 } from "babylonjs/Maths/math.vector";
  56692. import { Mesh } from "babylonjs/Meshes/mesh";
  56693. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56694. import { Path2 } from "babylonjs/Maths/math.path";
  56695. /**
  56696. * Polygon
  56697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56698. */
  56699. export class Polygon {
  56700. /**
  56701. * Creates a rectangle
  56702. * @param xmin bottom X coord
  56703. * @param ymin bottom Y coord
  56704. * @param xmax top X coord
  56705. * @param ymax top Y coord
  56706. * @returns points that make the resulting rectation
  56707. */
  56708. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56709. /**
  56710. * Creates a circle
  56711. * @param radius radius of circle
  56712. * @param cx scale in x
  56713. * @param cy scale in y
  56714. * @param numberOfSides number of sides that make up the circle
  56715. * @returns points that make the resulting circle
  56716. */
  56717. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56718. /**
  56719. * Creates a polygon from input string
  56720. * @param input Input polygon data
  56721. * @returns the parsed points
  56722. */
  56723. static Parse(input: string): Vector2[];
  56724. /**
  56725. * Starts building a polygon from x and y coordinates
  56726. * @param x x coordinate
  56727. * @param y y coordinate
  56728. * @returns the started path2
  56729. */
  56730. static StartingAt(x: number, y: number): Path2;
  56731. }
  56732. /**
  56733. * Builds a polygon
  56734. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56735. */
  56736. export class PolygonMeshBuilder {
  56737. private _points;
  56738. private _outlinepoints;
  56739. private _holes;
  56740. private _name;
  56741. private _scene;
  56742. private _epoints;
  56743. private _eholes;
  56744. private _addToepoint;
  56745. /**
  56746. * Babylon reference to the earcut plugin.
  56747. */
  56748. bjsEarcut: any;
  56749. /**
  56750. * Creates a PolygonMeshBuilder
  56751. * @param name name of the builder
  56752. * @param contours Path of the polygon
  56753. * @param scene scene to add to when creating the mesh
  56754. * @param earcutInjection can be used to inject your own earcut reference
  56755. */
  56756. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56757. /**
  56758. * Adds a whole within the polygon
  56759. * @param hole Array of points defining the hole
  56760. * @returns this
  56761. */
  56762. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56763. /**
  56764. * Creates the polygon
  56765. * @param updatable If the mesh should be updatable
  56766. * @param depth The depth of the mesh created
  56767. * @returns the created mesh
  56768. */
  56769. build(updatable?: boolean, depth?: number): Mesh;
  56770. /**
  56771. * Creates the polygon
  56772. * @param depth The depth of the mesh created
  56773. * @returns the created VertexData
  56774. */
  56775. buildVertexData(depth?: number): VertexData;
  56776. /**
  56777. * Adds a side to the polygon
  56778. * @param positions points that make the polygon
  56779. * @param normals normals of the polygon
  56780. * @param uvs uvs of the polygon
  56781. * @param indices indices of the polygon
  56782. * @param bounds bounds of the polygon
  56783. * @param points points of the polygon
  56784. * @param depth depth of the polygon
  56785. * @param flip flip of the polygon
  56786. */
  56787. private addSide;
  56788. }
  56789. }
  56790. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56791. import { Scene } from "babylonjs/scene";
  56792. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56793. import { Color4 } from "babylonjs/Maths/math.color";
  56794. import { Mesh } from "babylonjs/Meshes/mesh";
  56795. import { Nullable } from "babylonjs/types";
  56796. /**
  56797. * Class containing static functions to help procedurally build meshes
  56798. */
  56799. export class PolygonBuilder {
  56800. /**
  56801. * Creates a polygon mesh
  56802. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56803. * * 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
  56804. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56807. * * Remember you can only change the shape positions, not their number when updating a polygon
  56808. * @param name defines the name of the mesh
  56809. * @param options defines the options used to create the mesh
  56810. * @param scene defines the hosting scene
  56811. * @param earcutInjection can be used to inject your own earcut reference
  56812. * @returns the polygon mesh
  56813. */
  56814. static CreatePolygon(name: string, options: {
  56815. shape: Vector3[];
  56816. holes?: Vector3[][];
  56817. depth?: number;
  56818. faceUV?: Vector4[];
  56819. faceColors?: Color4[];
  56820. updatable?: boolean;
  56821. sideOrientation?: number;
  56822. frontUVs?: Vector4;
  56823. backUVs?: Vector4;
  56824. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56825. /**
  56826. * Creates an extruded polygon mesh, with depth in the Y direction.
  56827. * * 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)
  56828. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56829. * @param name defines the name of the mesh
  56830. * @param options defines the options used to create the mesh
  56831. * @param scene defines the hosting scene
  56832. * @param earcutInjection can be used to inject your own earcut reference
  56833. * @returns the polygon mesh
  56834. */
  56835. static ExtrudePolygon(name: string, options: {
  56836. shape: Vector3[];
  56837. holes?: Vector3[][];
  56838. depth?: number;
  56839. faceUV?: Vector4[];
  56840. faceColors?: Color4[];
  56841. updatable?: boolean;
  56842. sideOrientation?: number;
  56843. frontUVs?: Vector4;
  56844. backUVs?: Vector4;
  56845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56846. }
  56847. }
  56848. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56849. import { Scene } from "babylonjs/scene";
  56850. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56851. import { Mesh } from "babylonjs/Meshes/mesh";
  56852. import { Nullable } from "babylonjs/types";
  56853. /**
  56854. * Class containing static functions to help procedurally build meshes
  56855. */
  56856. export class LatheBuilder {
  56857. /**
  56858. * Creates lathe mesh.
  56859. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56860. * * 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
  56861. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56862. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56863. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56864. * * 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
  56865. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56866. * * 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
  56867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56871. * @param name defines the name of the mesh
  56872. * @param options defines the options used to create the mesh
  56873. * @param scene defines the hosting scene
  56874. * @returns the lathe mesh
  56875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56876. */
  56877. static CreateLathe(name: string, options: {
  56878. shape: Vector3[];
  56879. radius?: number;
  56880. tessellation?: number;
  56881. clip?: number;
  56882. arc?: number;
  56883. closed?: boolean;
  56884. updatable?: boolean;
  56885. sideOrientation?: number;
  56886. frontUVs?: Vector4;
  56887. backUVs?: Vector4;
  56888. cap?: number;
  56889. invertUV?: boolean;
  56890. }, scene?: Nullable<Scene>): Mesh;
  56891. }
  56892. }
  56893. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56894. import { Nullable } from "babylonjs/types";
  56895. import { Scene } from "babylonjs/scene";
  56896. import { Vector4 } from "babylonjs/Maths/math.vector";
  56897. import { Mesh } from "babylonjs/Meshes/mesh";
  56898. /**
  56899. * Class containing static functions to help procedurally build meshes
  56900. */
  56901. export class TiledPlaneBuilder {
  56902. /**
  56903. * Creates a tiled plane mesh
  56904. * * The parameter `pattern` will, depending on value, do nothing or
  56905. * * * flip (reflect about central vertical) alternate tiles across and up
  56906. * * * flip every tile on alternate rows
  56907. * * * rotate (180 degs) alternate tiles across and up
  56908. * * * rotate every tile on alternate rows
  56909. * * * flip and rotate alternate tiles across and up
  56910. * * * flip and rotate every tile on alternate rows
  56911. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56912. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56915. * * 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)
  56916. * * 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)
  56917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56918. * @param name defines the name of the mesh
  56919. * @param options defines the options used to create the mesh
  56920. * @param scene defines the hosting scene
  56921. * @returns the box mesh
  56922. */
  56923. static CreateTiledPlane(name: string, options: {
  56924. pattern?: number;
  56925. tileSize?: number;
  56926. tileWidth?: number;
  56927. tileHeight?: number;
  56928. size?: number;
  56929. width?: number;
  56930. height?: number;
  56931. alignHorizontal?: number;
  56932. alignVertical?: number;
  56933. sideOrientation?: number;
  56934. frontUVs?: Vector4;
  56935. backUVs?: Vector4;
  56936. updatable?: boolean;
  56937. }, scene?: Nullable<Scene>): Mesh;
  56938. }
  56939. }
  56940. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56941. import { Nullable } from "babylonjs/types";
  56942. import { Scene } from "babylonjs/scene";
  56943. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56944. import { Mesh } from "babylonjs/Meshes/mesh";
  56945. /**
  56946. * Class containing static functions to help procedurally build meshes
  56947. */
  56948. export class TubeBuilder {
  56949. /**
  56950. * Creates a tube mesh.
  56951. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56952. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56953. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56954. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56955. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56956. * * 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)
  56957. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56958. * * 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
  56959. * * 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
  56960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56964. * @param name defines the name of the mesh
  56965. * @param options defines the options used to create the mesh
  56966. * @param scene defines the hosting scene
  56967. * @returns the tube mesh
  56968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56969. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56970. */
  56971. static CreateTube(name: string, options: {
  56972. path: Vector3[];
  56973. radius?: number;
  56974. tessellation?: number;
  56975. radiusFunction?: {
  56976. (i: number, distance: number): number;
  56977. };
  56978. cap?: number;
  56979. arc?: number;
  56980. updatable?: boolean;
  56981. sideOrientation?: number;
  56982. frontUVs?: Vector4;
  56983. backUVs?: Vector4;
  56984. instance?: Mesh;
  56985. invertUV?: boolean;
  56986. }, scene?: Nullable<Scene>): Mesh;
  56987. }
  56988. }
  56989. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56990. import { Scene } from "babylonjs/scene";
  56991. import { Vector4 } from "babylonjs/Maths/math.vector";
  56992. import { Mesh } from "babylonjs/Meshes/mesh";
  56993. import { Nullable } from "babylonjs/types";
  56994. /**
  56995. * Class containing static functions to help procedurally build meshes
  56996. */
  56997. export class IcoSphereBuilder {
  56998. /**
  56999. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57000. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57001. * * 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`)
  57002. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57003. * * 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
  57004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57007. * @param name defines the name of the mesh
  57008. * @param options defines the options used to create the mesh
  57009. * @param scene defines the hosting scene
  57010. * @returns the icosahedron mesh
  57011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57012. */
  57013. static CreateIcoSphere(name: string, options: {
  57014. radius?: number;
  57015. radiusX?: number;
  57016. radiusY?: number;
  57017. radiusZ?: number;
  57018. flat?: boolean;
  57019. subdivisions?: number;
  57020. sideOrientation?: number;
  57021. frontUVs?: Vector4;
  57022. backUVs?: Vector4;
  57023. updatable?: boolean;
  57024. }, scene?: Nullable<Scene>): Mesh;
  57025. }
  57026. }
  57027. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57028. import { Vector3 } from "babylonjs/Maths/math.vector";
  57029. import { Mesh } from "babylonjs/Meshes/mesh";
  57030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57031. /**
  57032. * Class containing static functions to help procedurally build meshes
  57033. */
  57034. export class DecalBuilder {
  57035. /**
  57036. * Creates a decal mesh.
  57037. * 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
  57038. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57039. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57040. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57041. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57042. * @param name defines the name of the mesh
  57043. * @param sourceMesh defines the mesh where the decal must be applied
  57044. * @param options defines the options used to create the mesh
  57045. * @param scene defines the hosting scene
  57046. * @returns the decal mesh
  57047. * @see https://doc.babylonjs.com/how_to/decals
  57048. */
  57049. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57050. position?: Vector3;
  57051. normal?: Vector3;
  57052. size?: Vector3;
  57053. angle?: number;
  57054. }): Mesh;
  57055. }
  57056. }
  57057. declare module "babylonjs/Meshes/meshBuilder" {
  57058. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57059. import { Nullable } from "babylonjs/types";
  57060. import { Scene } from "babylonjs/scene";
  57061. import { Mesh } from "babylonjs/Meshes/mesh";
  57062. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57063. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57065. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57066. import { Plane } from "babylonjs/Maths/math.plane";
  57067. /**
  57068. * Class containing static functions to help procedurally build meshes
  57069. */
  57070. export class MeshBuilder {
  57071. /**
  57072. * Creates a box mesh
  57073. * * The parameter `size` sets the size (float) of each box side (default 1)
  57074. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57075. * * 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)
  57076. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57081. * @param name defines the name of the mesh
  57082. * @param options defines the options used to create the mesh
  57083. * @param scene defines the hosting scene
  57084. * @returns the box mesh
  57085. */
  57086. static CreateBox(name: string, options: {
  57087. size?: number;
  57088. width?: number;
  57089. height?: number;
  57090. depth?: number;
  57091. faceUV?: Vector4[];
  57092. faceColors?: Color4[];
  57093. sideOrientation?: number;
  57094. frontUVs?: Vector4;
  57095. backUVs?: Vector4;
  57096. updatable?: boolean;
  57097. }, scene?: Nullable<Scene>): Mesh;
  57098. /**
  57099. * Creates a tiled box mesh
  57100. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57102. * @param name defines the name of the mesh
  57103. * @param options defines the options used to create the mesh
  57104. * @param scene defines the hosting scene
  57105. * @returns the tiled box mesh
  57106. */
  57107. static CreateTiledBox(name: string, options: {
  57108. pattern?: number;
  57109. size?: number;
  57110. width?: number;
  57111. height?: number;
  57112. depth: number;
  57113. tileSize?: number;
  57114. tileWidth?: number;
  57115. tileHeight?: number;
  57116. faceUV?: Vector4[];
  57117. faceColors?: Color4[];
  57118. alignHorizontal?: number;
  57119. alignVertical?: number;
  57120. sideOrientation?: number;
  57121. updatable?: boolean;
  57122. }, scene?: Nullable<Scene>): Mesh;
  57123. /**
  57124. * Creates a sphere mesh
  57125. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57126. * * 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`)
  57127. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57128. * * 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
  57129. * * 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)
  57130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57133. * @param name defines the name of the mesh
  57134. * @param options defines the options used to create the mesh
  57135. * @param scene defines the hosting scene
  57136. * @returns the sphere mesh
  57137. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57138. */
  57139. static CreateSphere(name: string, options: {
  57140. segments?: number;
  57141. diameter?: number;
  57142. diameterX?: number;
  57143. diameterY?: number;
  57144. diameterZ?: number;
  57145. arc?: number;
  57146. slice?: number;
  57147. sideOrientation?: number;
  57148. frontUVs?: Vector4;
  57149. backUVs?: Vector4;
  57150. updatable?: boolean;
  57151. }, scene?: Nullable<Scene>): Mesh;
  57152. /**
  57153. * Creates a plane polygonal mesh. By default, this is a disc
  57154. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57155. * * 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
  57156. * * 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
  57157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57160. * @param name defines the name of the mesh
  57161. * @param options defines the options used to create the mesh
  57162. * @param scene defines the hosting scene
  57163. * @returns the plane polygonal mesh
  57164. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57165. */
  57166. static CreateDisc(name: string, options: {
  57167. radius?: number;
  57168. tessellation?: number;
  57169. arc?: number;
  57170. updatable?: boolean;
  57171. sideOrientation?: number;
  57172. frontUVs?: Vector4;
  57173. backUVs?: Vector4;
  57174. }, scene?: Nullable<Scene>): Mesh;
  57175. /**
  57176. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57177. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57178. * * 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`)
  57179. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57180. * * 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
  57181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57184. * @param name defines the name of the mesh
  57185. * @param options defines the options used to create the mesh
  57186. * @param scene defines the hosting scene
  57187. * @returns the icosahedron mesh
  57188. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57189. */
  57190. static CreateIcoSphere(name: string, options: {
  57191. radius?: number;
  57192. radiusX?: number;
  57193. radiusY?: number;
  57194. radiusZ?: number;
  57195. flat?: boolean;
  57196. subdivisions?: number;
  57197. sideOrientation?: number;
  57198. frontUVs?: Vector4;
  57199. backUVs?: Vector4;
  57200. updatable?: boolean;
  57201. }, scene?: Nullable<Scene>): Mesh;
  57202. /**
  57203. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57204. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57205. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57206. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57207. * * 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
  57208. * * 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
  57209. * * 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
  57210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57212. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57213. * * 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
  57214. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57215. * * 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
  57216. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57218. * @param name defines the name of the mesh
  57219. * @param options defines the options used to create the mesh
  57220. * @param scene defines the hosting scene
  57221. * @returns the ribbon mesh
  57222. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57224. */
  57225. static CreateRibbon(name: string, options: {
  57226. pathArray: Vector3[][];
  57227. closeArray?: boolean;
  57228. closePath?: boolean;
  57229. offset?: number;
  57230. updatable?: boolean;
  57231. sideOrientation?: number;
  57232. frontUVs?: Vector4;
  57233. backUVs?: Vector4;
  57234. instance?: Mesh;
  57235. invertUV?: boolean;
  57236. uvs?: Vector2[];
  57237. colors?: Color4[];
  57238. }, scene?: Nullable<Scene>): Mesh;
  57239. /**
  57240. * Creates a cylinder or a cone mesh
  57241. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57242. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57243. * * 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.
  57244. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57245. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57246. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57247. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57248. * * 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).
  57249. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57250. * * 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).
  57251. * * 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
  57252. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57253. * * 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
  57254. * * 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.
  57255. * * If `enclose` is false, a ring surface is one element.
  57256. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57257. * * 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
  57258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57261. * @param name defines the name of the mesh
  57262. * @param options defines the options used to create the mesh
  57263. * @param scene defines the hosting scene
  57264. * @returns the cylinder mesh
  57265. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57266. */
  57267. static CreateCylinder(name: string, options: {
  57268. height?: number;
  57269. diameterTop?: number;
  57270. diameterBottom?: number;
  57271. diameter?: number;
  57272. tessellation?: number;
  57273. subdivisions?: number;
  57274. arc?: number;
  57275. faceColors?: Color4[];
  57276. faceUV?: Vector4[];
  57277. updatable?: boolean;
  57278. hasRings?: boolean;
  57279. enclose?: boolean;
  57280. cap?: number;
  57281. sideOrientation?: number;
  57282. frontUVs?: Vector4;
  57283. backUVs?: Vector4;
  57284. }, scene?: Nullable<Scene>): Mesh;
  57285. /**
  57286. * Creates a torus mesh
  57287. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57288. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57289. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57293. * @param name defines the name of the mesh
  57294. * @param options defines the options used to create the mesh
  57295. * @param scene defines the hosting scene
  57296. * @returns the torus mesh
  57297. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57298. */
  57299. static CreateTorus(name: string, options: {
  57300. diameter?: number;
  57301. thickness?: number;
  57302. tessellation?: number;
  57303. updatable?: boolean;
  57304. sideOrientation?: number;
  57305. frontUVs?: Vector4;
  57306. backUVs?: Vector4;
  57307. }, scene?: Nullable<Scene>): Mesh;
  57308. /**
  57309. * Creates a torus knot mesh
  57310. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57311. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57312. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57313. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57317. * @param name defines the name of the mesh
  57318. * @param options defines the options used to create the mesh
  57319. * @param scene defines the hosting scene
  57320. * @returns the torus knot mesh
  57321. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57322. */
  57323. static CreateTorusKnot(name: string, options: {
  57324. radius?: number;
  57325. tube?: number;
  57326. radialSegments?: number;
  57327. tubularSegments?: number;
  57328. p?: number;
  57329. q?: number;
  57330. updatable?: boolean;
  57331. sideOrientation?: number;
  57332. frontUVs?: Vector4;
  57333. backUVs?: Vector4;
  57334. }, scene?: Nullable<Scene>): Mesh;
  57335. /**
  57336. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57337. * * 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
  57338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57339. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57340. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57341. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57343. * * 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
  57344. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57347. * @param name defines the name of the new line system
  57348. * @param options defines the options used to create the line system
  57349. * @param scene defines the hosting scene
  57350. * @returns a new line system mesh
  57351. */
  57352. static CreateLineSystem(name: string, options: {
  57353. lines: Vector3[][];
  57354. updatable?: boolean;
  57355. instance?: Nullable<LinesMesh>;
  57356. colors?: Nullable<Color4[][]>;
  57357. useVertexAlpha?: boolean;
  57358. }, scene: Nullable<Scene>): LinesMesh;
  57359. /**
  57360. * Creates a line mesh
  57361. * 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
  57362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57363. * * The parameter `points` is an array successive Vector3
  57364. * * 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
  57365. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57367. * * When updating an instance, remember that only point positions can change, not the number of points
  57368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57370. * @param name defines the name of the new line system
  57371. * @param options defines the options used to create the line system
  57372. * @param scene defines the hosting scene
  57373. * @returns a new line mesh
  57374. */
  57375. static CreateLines(name: string, options: {
  57376. points: Vector3[];
  57377. updatable?: boolean;
  57378. instance?: Nullable<LinesMesh>;
  57379. colors?: Color4[];
  57380. useVertexAlpha?: boolean;
  57381. }, scene?: Nullable<Scene>): LinesMesh;
  57382. /**
  57383. * Creates a dashed line mesh
  57384. * * 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
  57385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57386. * * The parameter `points` is an array successive Vector3
  57387. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57388. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57389. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57390. * * 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
  57391. * * When updating an instance, remember that only point positions can change, not the number of points
  57392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57393. * @param name defines the name of the mesh
  57394. * @param options defines the options used to create the mesh
  57395. * @param scene defines the hosting scene
  57396. * @returns the dashed line mesh
  57397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57398. */
  57399. static CreateDashedLines(name: string, options: {
  57400. points: Vector3[];
  57401. dashSize?: number;
  57402. gapSize?: number;
  57403. dashNb?: number;
  57404. updatable?: boolean;
  57405. instance?: LinesMesh;
  57406. }, scene?: Nullable<Scene>): LinesMesh;
  57407. /**
  57408. * 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.
  57409. * * 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.
  57410. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57411. * * 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.
  57412. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57413. * * 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
  57414. * * 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
  57415. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57420. * @param name defines the name of the mesh
  57421. * @param options defines the options used to create the mesh
  57422. * @param scene defines the hosting scene
  57423. * @returns the extruded shape mesh
  57424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57426. */
  57427. static ExtrudeShape(name: string, options: {
  57428. shape: Vector3[];
  57429. path: Vector3[];
  57430. scale?: number;
  57431. rotation?: number;
  57432. cap?: number;
  57433. updatable?: boolean;
  57434. sideOrientation?: number;
  57435. frontUVs?: Vector4;
  57436. backUVs?: Vector4;
  57437. instance?: Mesh;
  57438. invertUV?: boolean;
  57439. }, scene?: Nullable<Scene>): Mesh;
  57440. /**
  57441. * Creates an custom extruded shape mesh.
  57442. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57443. * * 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.
  57444. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57445. * * 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
  57446. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57447. * * 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
  57448. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57449. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57450. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57451. * * 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
  57452. * * 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
  57453. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57458. * @param name defines the name of the mesh
  57459. * @param options defines the options used to create the mesh
  57460. * @param scene defines the hosting scene
  57461. * @returns the custom extruded shape mesh
  57462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57465. */
  57466. static ExtrudeShapeCustom(name: string, options: {
  57467. shape: Vector3[];
  57468. path: Vector3[];
  57469. scaleFunction?: any;
  57470. rotationFunction?: any;
  57471. ribbonCloseArray?: boolean;
  57472. ribbonClosePath?: boolean;
  57473. cap?: number;
  57474. updatable?: boolean;
  57475. sideOrientation?: number;
  57476. frontUVs?: Vector4;
  57477. backUVs?: Vector4;
  57478. instance?: Mesh;
  57479. invertUV?: boolean;
  57480. }, scene?: Nullable<Scene>): Mesh;
  57481. /**
  57482. * Creates lathe mesh.
  57483. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57484. * * 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
  57485. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57486. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57487. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57488. * * 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
  57489. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57490. * * 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
  57491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57495. * @param name defines the name of the mesh
  57496. * @param options defines the options used to create the mesh
  57497. * @param scene defines the hosting scene
  57498. * @returns the lathe mesh
  57499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57500. */
  57501. static CreateLathe(name: string, options: {
  57502. shape: Vector3[];
  57503. radius?: number;
  57504. tessellation?: number;
  57505. clip?: number;
  57506. arc?: number;
  57507. closed?: boolean;
  57508. updatable?: boolean;
  57509. sideOrientation?: number;
  57510. frontUVs?: Vector4;
  57511. backUVs?: Vector4;
  57512. cap?: number;
  57513. invertUV?: boolean;
  57514. }, scene?: Nullable<Scene>): Mesh;
  57515. /**
  57516. * Creates a tiled plane mesh
  57517. * * You can set a limited pattern arrangement with the tiles
  57518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57521. * @param name defines the name of the mesh
  57522. * @param options defines the options used to create the mesh
  57523. * @param scene defines the hosting scene
  57524. * @returns the plane mesh
  57525. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57526. */
  57527. static CreateTiledPlane(name: string, options: {
  57528. pattern?: number;
  57529. tileSize?: number;
  57530. tileWidth?: number;
  57531. tileHeight?: number;
  57532. size?: number;
  57533. width?: number;
  57534. height?: number;
  57535. alignHorizontal?: number;
  57536. alignVertical?: number;
  57537. sideOrientation?: number;
  57538. frontUVs?: Vector4;
  57539. backUVs?: Vector4;
  57540. updatable?: boolean;
  57541. }, scene?: Nullable<Scene>): Mesh;
  57542. /**
  57543. * Creates a plane mesh
  57544. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57545. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57546. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57550. * @param name defines the name of the mesh
  57551. * @param options defines the options used to create the mesh
  57552. * @param scene defines the hosting scene
  57553. * @returns the plane mesh
  57554. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57555. */
  57556. static CreatePlane(name: string, options: {
  57557. size?: number;
  57558. width?: number;
  57559. height?: number;
  57560. sideOrientation?: number;
  57561. frontUVs?: Vector4;
  57562. backUVs?: Vector4;
  57563. updatable?: boolean;
  57564. sourcePlane?: Plane;
  57565. }, scene?: Nullable<Scene>): Mesh;
  57566. /**
  57567. * Creates a ground mesh
  57568. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57569. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57571. * @param name defines the name of the mesh
  57572. * @param options defines the options used to create the mesh
  57573. * @param scene defines the hosting scene
  57574. * @returns the ground mesh
  57575. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57576. */
  57577. static CreateGround(name: string, options: {
  57578. width?: number;
  57579. height?: number;
  57580. subdivisions?: number;
  57581. subdivisionsX?: number;
  57582. subdivisionsY?: number;
  57583. updatable?: boolean;
  57584. }, scene?: Nullable<Scene>): Mesh;
  57585. /**
  57586. * Creates a tiled ground mesh
  57587. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57588. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57589. * * 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
  57590. * * 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
  57591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57592. * @param name defines the name of the mesh
  57593. * @param options defines the options used to create the mesh
  57594. * @param scene defines the hosting scene
  57595. * @returns the tiled ground mesh
  57596. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57597. */
  57598. static CreateTiledGround(name: string, options: {
  57599. xmin: number;
  57600. zmin: number;
  57601. xmax: number;
  57602. zmax: number;
  57603. subdivisions?: {
  57604. w: number;
  57605. h: number;
  57606. };
  57607. precision?: {
  57608. w: number;
  57609. h: number;
  57610. };
  57611. updatable?: boolean;
  57612. }, scene?: Nullable<Scene>): Mesh;
  57613. /**
  57614. * Creates a ground mesh from a height map
  57615. * * The parameter `url` sets the URL of the height map image resource.
  57616. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57617. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57618. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57619. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57620. * * 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.
  57621. * * 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).
  57622. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57624. * @param name defines the name of the mesh
  57625. * @param url defines the url to the height map
  57626. * @param options defines the options used to create the mesh
  57627. * @param scene defines the hosting scene
  57628. * @returns the ground mesh
  57629. * @see https://doc.babylonjs.com/babylon101/height_map
  57630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57631. */
  57632. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57633. width?: number;
  57634. height?: number;
  57635. subdivisions?: number;
  57636. minHeight?: number;
  57637. maxHeight?: number;
  57638. colorFilter?: Color3;
  57639. alphaFilter?: number;
  57640. updatable?: boolean;
  57641. onReady?: (mesh: GroundMesh) => void;
  57642. }, scene?: Nullable<Scene>): GroundMesh;
  57643. /**
  57644. * Creates a polygon mesh
  57645. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57646. * * 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
  57647. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57650. * * Remember you can only change the shape positions, not their number when updating a polygon
  57651. * @param name defines the name of the mesh
  57652. * @param options defines the options used to create the mesh
  57653. * @param scene defines the hosting scene
  57654. * @param earcutInjection can be used to inject your own earcut reference
  57655. * @returns the polygon mesh
  57656. */
  57657. static CreatePolygon(name: string, options: {
  57658. shape: Vector3[];
  57659. holes?: Vector3[][];
  57660. depth?: number;
  57661. faceUV?: Vector4[];
  57662. faceColors?: Color4[];
  57663. updatable?: boolean;
  57664. sideOrientation?: number;
  57665. frontUVs?: Vector4;
  57666. backUVs?: Vector4;
  57667. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57668. /**
  57669. * Creates an extruded polygon mesh, with depth in the Y direction.
  57670. * * 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)
  57671. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57672. * @param name defines the name of the mesh
  57673. * @param options defines the options used to create the mesh
  57674. * @param scene defines the hosting scene
  57675. * @param earcutInjection can be used to inject your own earcut reference
  57676. * @returns the polygon mesh
  57677. */
  57678. static ExtrudePolygon(name: string, options: {
  57679. shape: Vector3[];
  57680. holes?: Vector3[][];
  57681. depth?: number;
  57682. faceUV?: Vector4[];
  57683. faceColors?: Color4[];
  57684. updatable?: boolean;
  57685. sideOrientation?: number;
  57686. frontUVs?: Vector4;
  57687. backUVs?: Vector4;
  57688. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57689. /**
  57690. * Creates a tube mesh.
  57691. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57692. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57693. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57694. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57695. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57696. * * 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)
  57697. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57698. * * 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
  57699. * * 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
  57700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57704. * @param name defines the name of the mesh
  57705. * @param options defines the options used to create the mesh
  57706. * @param scene defines the hosting scene
  57707. * @returns the tube mesh
  57708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57709. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57710. */
  57711. static CreateTube(name: string, options: {
  57712. path: Vector3[];
  57713. radius?: number;
  57714. tessellation?: number;
  57715. radiusFunction?: {
  57716. (i: number, distance: number): number;
  57717. };
  57718. cap?: number;
  57719. arc?: number;
  57720. updatable?: boolean;
  57721. sideOrientation?: number;
  57722. frontUVs?: Vector4;
  57723. backUVs?: Vector4;
  57724. instance?: Mesh;
  57725. invertUV?: boolean;
  57726. }, scene?: Nullable<Scene>): Mesh;
  57727. /**
  57728. * Creates a polyhedron mesh
  57729. * * 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
  57730. * * The parameter `size` (positive float, default 1) sets the polygon size
  57731. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57732. * * 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`
  57733. * * 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
  57734. * * 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)`)
  57735. * * 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
  57736. * * 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
  57737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57740. * @param name defines the name of the mesh
  57741. * @param options defines the options used to create the mesh
  57742. * @param scene defines the hosting scene
  57743. * @returns the polyhedron mesh
  57744. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57745. */
  57746. static CreatePolyhedron(name: string, options: {
  57747. type?: number;
  57748. size?: number;
  57749. sizeX?: number;
  57750. sizeY?: number;
  57751. sizeZ?: number;
  57752. custom?: any;
  57753. faceUV?: Vector4[];
  57754. faceColors?: Color4[];
  57755. flat?: boolean;
  57756. updatable?: boolean;
  57757. sideOrientation?: number;
  57758. frontUVs?: Vector4;
  57759. backUVs?: Vector4;
  57760. }, scene?: Nullable<Scene>): Mesh;
  57761. /**
  57762. * Creates a decal mesh.
  57763. * 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
  57764. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57765. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57766. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57767. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57768. * @param name defines the name of the mesh
  57769. * @param sourceMesh defines the mesh where the decal must be applied
  57770. * @param options defines the options used to create the mesh
  57771. * @param scene defines the hosting scene
  57772. * @returns the decal mesh
  57773. * @see https://doc.babylonjs.com/how_to/decals
  57774. */
  57775. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57776. position?: Vector3;
  57777. normal?: Vector3;
  57778. size?: Vector3;
  57779. angle?: number;
  57780. }): Mesh;
  57781. }
  57782. }
  57783. declare module "babylonjs/Meshes/meshSimplification" {
  57784. import { Mesh } from "babylonjs/Meshes/mesh";
  57785. /**
  57786. * A simplifier interface for future simplification implementations
  57787. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57788. */
  57789. export interface ISimplifier {
  57790. /**
  57791. * Simplification of a given mesh according to the given settings.
  57792. * Since this requires computation, it is assumed that the function runs async.
  57793. * @param settings The settings of the simplification, including quality and distance
  57794. * @param successCallback A callback that will be called after the mesh was simplified.
  57795. * @param errorCallback in case of an error, this callback will be called. optional.
  57796. */
  57797. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57798. }
  57799. /**
  57800. * Expected simplification settings.
  57801. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57802. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57803. */
  57804. export interface ISimplificationSettings {
  57805. /**
  57806. * Gets or sets the expected quality
  57807. */
  57808. quality: number;
  57809. /**
  57810. * Gets or sets the distance when this optimized version should be used
  57811. */
  57812. distance: number;
  57813. /**
  57814. * Gets an already optimized mesh
  57815. */
  57816. optimizeMesh?: boolean;
  57817. }
  57818. /**
  57819. * Class used to specify simplification options
  57820. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57821. */
  57822. export class SimplificationSettings implements ISimplificationSettings {
  57823. /** expected quality */
  57824. quality: number;
  57825. /** distance when this optimized version should be used */
  57826. distance: number;
  57827. /** already optimized mesh */
  57828. optimizeMesh?: boolean | undefined;
  57829. /**
  57830. * Creates a SimplificationSettings
  57831. * @param quality expected quality
  57832. * @param distance distance when this optimized version should be used
  57833. * @param optimizeMesh already optimized mesh
  57834. */
  57835. constructor(
  57836. /** expected quality */
  57837. quality: number,
  57838. /** distance when this optimized version should be used */
  57839. distance: number,
  57840. /** already optimized mesh */
  57841. optimizeMesh?: boolean | undefined);
  57842. }
  57843. /**
  57844. * Interface used to define a simplification task
  57845. */
  57846. export interface ISimplificationTask {
  57847. /**
  57848. * Array of settings
  57849. */
  57850. settings: Array<ISimplificationSettings>;
  57851. /**
  57852. * Simplification type
  57853. */
  57854. simplificationType: SimplificationType;
  57855. /**
  57856. * Mesh to simplify
  57857. */
  57858. mesh: Mesh;
  57859. /**
  57860. * Callback called on success
  57861. */
  57862. successCallback?: () => void;
  57863. /**
  57864. * Defines if parallel processing can be used
  57865. */
  57866. parallelProcessing: boolean;
  57867. }
  57868. /**
  57869. * Queue used to order the simplification tasks
  57870. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57871. */
  57872. export class SimplificationQueue {
  57873. private _simplificationArray;
  57874. /**
  57875. * Gets a boolean indicating that the process is still running
  57876. */
  57877. running: boolean;
  57878. /**
  57879. * Creates a new queue
  57880. */
  57881. constructor();
  57882. /**
  57883. * Adds a new simplification task
  57884. * @param task defines a task to add
  57885. */
  57886. addTask(task: ISimplificationTask): void;
  57887. /**
  57888. * Execute next task
  57889. */
  57890. executeNext(): void;
  57891. /**
  57892. * Execute a simplification task
  57893. * @param task defines the task to run
  57894. */
  57895. runSimplification(task: ISimplificationTask): void;
  57896. private getSimplifier;
  57897. }
  57898. /**
  57899. * The implemented types of simplification
  57900. * At the moment only Quadratic Error Decimation is implemented
  57901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57902. */
  57903. export enum SimplificationType {
  57904. /** Quadratic error decimation */
  57905. QUADRATIC = 0
  57906. }
  57907. }
  57908. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57909. import { Scene } from "babylonjs/scene";
  57910. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57911. import { ISceneComponent } from "babylonjs/sceneComponent";
  57912. module "babylonjs/scene" {
  57913. interface Scene {
  57914. /** @hidden (Backing field) */
  57915. _simplificationQueue: SimplificationQueue;
  57916. /**
  57917. * Gets or sets the simplification queue attached to the scene
  57918. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57919. */
  57920. simplificationQueue: SimplificationQueue;
  57921. }
  57922. }
  57923. module "babylonjs/Meshes/mesh" {
  57924. interface Mesh {
  57925. /**
  57926. * Simplify the mesh according to the given array of settings.
  57927. * Function will return immediately and will simplify async
  57928. * @param settings a collection of simplification settings
  57929. * @param parallelProcessing should all levels calculate parallel or one after the other
  57930. * @param simplificationType the type of simplification to run
  57931. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57932. * @returns the current mesh
  57933. */
  57934. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57935. }
  57936. }
  57937. /**
  57938. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57939. * created in a scene
  57940. */
  57941. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57942. /**
  57943. * The component name helpfull to identify the component in the list of scene components.
  57944. */
  57945. readonly name: string;
  57946. /**
  57947. * The scene the component belongs to.
  57948. */
  57949. scene: Scene;
  57950. /**
  57951. * Creates a new instance of the component for the given scene
  57952. * @param scene Defines the scene to register the component in
  57953. */
  57954. constructor(scene: Scene);
  57955. /**
  57956. * Registers the component in a given scene
  57957. */
  57958. register(): void;
  57959. /**
  57960. * Rebuilds the elements related to this component in case of
  57961. * context lost for instance.
  57962. */
  57963. rebuild(): void;
  57964. /**
  57965. * Disposes the component and the associated ressources
  57966. */
  57967. dispose(): void;
  57968. private _beforeCameraUpdate;
  57969. }
  57970. }
  57971. declare module "babylonjs/Meshes/Builders/index" {
  57972. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57973. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57974. export * from "babylonjs/Meshes/Builders/discBuilder";
  57975. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57976. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57977. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57978. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57979. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57980. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57981. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57982. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57983. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57984. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57985. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57986. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57987. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57988. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57989. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57990. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57991. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57992. }
  57993. declare module "babylonjs/Meshes/index" {
  57994. export * from "babylonjs/Meshes/abstractMesh";
  57995. export * from "babylonjs/Meshes/buffer";
  57996. export * from "babylonjs/Meshes/Compression/index";
  57997. export * from "babylonjs/Meshes/csg";
  57998. export * from "babylonjs/Meshes/geometry";
  57999. export * from "babylonjs/Meshes/groundMesh";
  58000. export * from "babylonjs/Meshes/trailMesh";
  58001. export * from "babylonjs/Meshes/instancedMesh";
  58002. export * from "babylonjs/Meshes/linesMesh";
  58003. export * from "babylonjs/Meshes/mesh";
  58004. export * from "babylonjs/Meshes/mesh.vertexData";
  58005. export * from "babylonjs/Meshes/meshBuilder";
  58006. export * from "babylonjs/Meshes/meshSimplification";
  58007. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58008. export * from "babylonjs/Meshes/polygonMesh";
  58009. export * from "babylonjs/Meshes/subMesh";
  58010. export * from "babylonjs/Meshes/meshLODLevel";
  58011. export * from "babylonjs/Meshes/transformNode";
  58012. export * from "babylonjs/Meshes/Builders/index";
  58013. export * from "babylonjs/Meshes/dataBuffer";
  58014. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58015. }
  58016. declare module "babylonjs/Morph/index" {
  58017. export * from "babylonjs/Morph/morphTarget";
  58018. export * from "babylonjs/Morph/morphTargetManager";
  58019. }
  58020. declare module "babylonjs/Navigation/INavigationEngine" {
  58021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58022. import { Vector3 } from "babylonjs/Maths/math";
  58023. import { Mesh } from "babylonjs/Meshes/mesh";
  58024. import { Scene } from "babylonjs/scene";
  58025. /**
  58026. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58027. */
  58028. export interface INavigationEnginePlugin {
  58029. /**
  58030. * plugin name
  58031. */
  58032. name: string;
  58033. /**
  58034. * Creates a navigation mesh
  58035. * @param meshes array of all the geometry used to compute the navigatio mesh
  58036. * @param parameters bunch of parameters used to filter geometry
  58037. */
  58038. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58039. /**
  58040. * Create a navigation mesh debug mesh
  58041. * @param scene is where the mesh will be added
  58042. * @returns debug display mesh
  58043. */
  58044. createDebugNavMesh(scene: Scene): Mesh;
  58045. /**
  58046. * Get a navigation mesh constrained position, closest to the parameter position
  58047. * @param position world position
  58048. * @returns the closest point to position constrained by the navigation mesh
  58049. */
  58050. getClosestPoint(position: Vector3): Vector3;
  58051. /**
  58052. * Get a navigation mesh constrained position, within a particular radius
  58053. * @param position world position
  58054. * @param maxRadius the maximum distance to the constrained world position
  58055. * @returns the closest point to position constrained by the navigation mesh
  58056. */
  58057. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58058. /**
  58059. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58060. * @param start world position
  58061. * @param end world position
  58062. * @returns array containing world position composing the path
  58063. */
  58064. computePath(start: Vector3, end: Vector3): Vector3[];
  58065. /**
  58066. * If this plugin is supported
  58067. * @returns true if plugin is supported
  58068. */
  58069. isSupported(): boolean;
  58070. /**
  58071. * Create a new Crowd so you can add agents
  58072. * @param maxAgents the maximum agent count in the crowd
  58073. * @param maxAgentRadius the maximum radius an agent can have
  58074. * @param scene to attach the crowd to
  58075. * @returns the crowd you can add agents to
  58076. */
  58077. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58078. /**
  58079. * Release all resources
  58080. */
  58081. dispose(): void;
  58082. }
  58083. /**
  58084. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58085. */
  58086. export interface ICrowd {
  58087. /**
  58088. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58089. * You can attach anything to that node. The node position is updated in the scene update tick.
  58090. * @param pos world position that will be constrained by the navigation mesh
  58091. * @param parameters agent parameters
  58092. * @param transform hooked to the agent that will be update by the scene
  58093. * @returns agent index
  58094. */
  58095. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58096. /**
  58097. * Returns the agent position in world space
  58098. * @param index agent index returned by addAgent
  58099. * @returns world space position
  58100. */
  58101. getAgentPosition(index: number): Vector3;
  58102. /**
  58103. * Gets the agent velocity in world space
  58104. * @param index agent index returned by addAgent
  58105. * @returns world space velocity
  58106. */
  58107. getAgentVelocity(index: number): Vector3;
  58108. /**
  58109. * remove a particular agent previously created
  58110. * @param index agent index returned by addAgent
  58111. */
  58112. removeAgent(index: number): void;
  58113. /**
  58114. * get the list of all agents attached to this crowd
  58115. * @returns list of agent indices
  58116. */
  58117. getAgents(): number[];
  58118. /**
  58119. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58120. * @param deltaTime in seconds
  58121. */
  58122. update(deltaTime: number): void;
  58123. /**
  58124. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58125. * @param index agent index returned by addAgent
  58126. * @param destination targeted world position
  58127. */
  58128. agentGoto(index: number, destination: Vector3): void;
  58129. /**
  58130. * Release all resources
  58131. */
  58132. dispose(): void;
  58133. }
  58134. /**
  58135. * Configures an agent
  58136. */
  58137. export interface IAgentParameters {
  58138. /**
  58139. * Agent radius. [Limit: >= 0]
  58140. */
  58141. radius: number;
  58142. /**
  58143. * Agent height. [Limit: > 0]
  58144. */
  58145. height: number;
  58146. /**
  58147. * Maximum allowed acceleration. [Limit: >= 0]
  58148. */
  58149. maxAcceleration: number;
  58150. /**
  58151. * Maximum allowed speed. [Limit: >= 0]
  58152. */
  58153. maxSpeed: number;
  58154. /**
  58155. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58156. */
  58157. collisionQueryRange: number;
  58158. /**
  58159. * The path visibility optimization range. [Limit: > 0]
  58160. */
  58161. pathOptimizationRange: number;
  58162. /**
  58163. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58164. */
  58165. separationWeight: number;
  58166. }
  58167. /**
  58168. * Configures the navigation mesh creation
  58169. */
  58170. export interface INavMeshParameters {
  58171. /**
  58172. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58173. */
  58174. cs: number;
  58175. /**
  58176. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58177. */
  58178. ch: number;
  58179. /**
  58180. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58181. */
  58182. walkableSlopeAngle: number;
  58183. /**
  58184. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58185. * be considered walkable. [Limit: >= 3] [Units: vx]
  58186. */
  58187. walkableHeight: number;
  58188. /**
  58189. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58190. */
  58191. walkableClimb: number;
  58192. /**
  58193. * The distance to erode/shrink the walkable area of the heightfield away from
  58194. * obstructions. [Limit: >=0] [Units: vx]
  58195. */
  58196. walkableRadius: number;
  58197. /**
  58198. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58199. */
  58200. maxEdgeLen: number;
  58201. /**
  58202. * The maximum distance a simplfied contour's border edges should deviate
  58203. * the original raw contour. [Limit: >=0] [Units: vx]
  58204. */
  58205. maxSimplificationError: number;
  58206. /**
  58207. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58208. */
  58209. minRegionArea: number;
  58210. /**
  58211. * Any regions with a span count smaller than this value will, if possible,
  58212. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58213. */
  58214. mergeRegionArea: number;
  58215. /**
  58216. * The maximum number of vertices allowed for polygons generated during the
  58217. * contour to polygon conversion process. [Limit: >= 3]
  58218. */
  58219. maxVertsPerPoly: number;
  58220. /**
  58221. * Sets the sampling distance to use when generating the detail mesh.
  58222. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58223. */
  58224. detailSampleDist: number;
  58225. /**
  58226. * The maximum distance the detail mesh surface should deviate from heightfield
  58227. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58228. */
  58229. detailSampleMaxError: number;
  58230. }
  58231. }
  58232. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58233. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58234. import { Mesh } from "babylonjs/Meshes/mesh";
  58235. import { Scene } from "babylonjs/scene";
  58236. import { Vector3 } from "babylonjs/Maths/math";
  58237. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58238. /**
  58239. * RecastJS navigation plugin
  58240. */
  58241. export class RecastJSPlugin implements INavigationEnginePlugin {
  58242. /**
  58243. * Reference to the Recast library
  58244. */
  58245. bjsRECAST: any;
  58246. /**
  58247. * plugin name
  58248. */
  58249. name: string;
  58250. /**
  58251. * the first navmesh created. We might extend this to support multiple navmeshes
  58252. */
  58253. navMesh: any;
  58254. /**
  58255. * Initializes the recastJS plugin
  58256. * @param recastInjection can be used to inject your own recast reference
  58257. */
  58258. constructor(recastInjection?: any);
  58259. /**
  58260. * Creates a navigation mesh
  58261. * @param meshes array of all the geometry used to compute the navigatio mesh
  58262. * @param parameters bunch of parameters used to filter geometry
  58263. */
  58264. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58265. /**
  58266. * Create a navigation mesh debug mesh
  58267. * @param scene is where the mesh will be added
  58268. * @returns debug display mesh
  58269. */
  58270. createDebugNavMesh(scene: Scene): Mesh;
  58271. /**
  58272. * Get a navigation mesh constrained position, closest to the parameter position
  58273. * @param position world position
  58274. * @returns the closest point to position constrained by the navigation mesh
  58275. */
  58276. getClosestPoint(position: Vector3): Vector3;
  58277. /**
  58278. * Get a navigation mesh constrained position, within a particular radius
  58279. * @param position world position
  58280. * @param maxRadius the maximum distance to the constrained world position
  58281. * @returns the closest point to position constrained by the navigation mesh
  58282. */
  58283. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58284. /**
  58285. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58286. * @param start world position
  58287. * @param end world position
  58288. * @returns array containing world position composing the path
  58289. */
  58290. computePath(start: Vector3, end: Vector3): Vector3[];
  58291. /**
  58292. * Create a new Crowd so you can add agents
  58293. * @param maxAgents the maximum agent count in the crowd
  58294. * @param maxAgentRadius the maximum radius an agent can have
  58295. * @param scene to attach the crowd to
  58296. * @returns the crowd you can add agents to
  58297. */
  58298. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58299. /**
  58300. * Disposes
  58301. */
  58302. dispose(): void;
  58303. /**
  58304. * If this plugin is supported
  58305. * @returns true if plugin is supported
  58306. */
  58307. isSupported(): boolean;
  58308. }
  58309. /**
  58310. * Recast detour crowd implementation
  58311. */
  58312. export class RecastJSCrowd implements ICrowd {
  58313. /**
  58314. * Recast/detour plugin
  58315. */
  58316. bjsRECASTPlugin: RecastJSPlugin;
  58317. /**
  58318. * Link to the detour crowd
  58319. */
  58320. recastCrowd: any;
  58321. /**
  58322. * One transform per agent
  58323. */
  58324. transforms: TransformNode[];
  58325. /**
  58326. * All agents created
  58327. */
  58328. agents: number[];
  58329. /**
  58330. * Link to the scene is kept to unregister the crowd from the scene
  58331. */
  58332. private _scene;
  58333. /**
  58334. * Observer for crowd updates
  58335. */
  58336. private _onBeforeAnimationsObserver;
  58337. /**
  58338. * Constructor
  58339. * @param plugin recastJS plugin
  58340. * @param maxAgents the maximum agent count in the crowd
  58341. * @param maxAgentRadius the maximum radius an agent can have
  58342. * @param scene to attach the crowd to
  58343. * @returns the crowd you can add agents to
  58344. */
  58345. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58346. /**
  58347. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58348. * You can attach anything to that node. The node position is updated in the scene update tick.
  58349. * @param pos world position that will be constrained by the navigation mesh
  58350. * @param parameters agent parameters
  58351. * @param transform hooked to the agent that will be update by the scene
  58352. * @returns agent index
  58353. */
  58354. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58355. /**
  58356. * Returns the agent position in world space
  58357. * @param index agent index returned by addAgent
  58358. * @returns world space position
  58359. */
  58360. getAgentPosition(index: number): Vector3;
  58361. /**
  58362. * Returns the agent velocity in world space
  58363. * @param index agent index returned by addAgent
  58364. * @returns world space velocity
  58365. */
  58366. getAgentVelocity(index: number): Vector3;
  58367. /**
  58368. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58369. * @param index agent index returned by addAgent
  58370. * @param destination targeted world position
  58371. */
  58372. agentGoto(index: number, destination: Vector3): void;
  58373. /**
  58374. * remove a particular agent previously created
  58375. * @param index agent index returned by addAgent
  58376. */
  58377. removeAgent(index: number): void;
  58378. /**
  58379. * get the list of all agents attached to this crowd
  58380. * @returns list of agent indices
  58381. */
  58382. getAgents(): number[];
  58383. /**
  58384. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58385. * @param deltaTime in seconds
  58386. */
  58387. update(deltaTime: number): void;
  58388. /**
  58389. * Release all resources
  58390. */
  58391. dispose(): void;
  58392. }
  58393. }
  58394. declare module "babylonjs/Navigation/Plugins/index" {
  58395. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58396. }
  58397. declare module "babylonjs/Navigation/index" {
  58398. export * from "babylonjs/Navigation/INavigationEngine";
  58399. export * from "babylonjs/Navigation/Plugins/index";
  58400. }
  58401. declare module "babylonjs/Offline/database" {
  58402. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58403. /**
  58404. * Class used to enable access to IndexedDB
  58405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58406. */
  58407. export class Database implements IOfflineProvider {
  58408. private _callbackManifestChecked;
  58409. private _currentSceneUrl;
  58410. private _db;
  58411. private _enableSceneOffline;
  58412. private _enableTexturesOffline;
  58413. private _manifestVersionFound;
  58414. private _mustUpdateRessources;
  58415. private _hasReachedQuota;
  58416. private _isSupported;
  58417. private _idbFactory;
  58418. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58419. private static IsUASupportingBlobStorage;
  58420. /**
  58421. * Gets a boolean indicating if Database storate is enabled (off by default)
  58422. */
  58423. static IDBStorageEnabled: boolean;
  58424. /**
  58425. * Gets a boolean indicating if scene must be saved in the database
  58426. */
  58427. readonly enableSceneOffline: boolean;
  58428. /**
  58429. * Gets a boolean indicating if textures must be saved in the database
  58430. */
  58431. readonly enableTexturesOffline: boolean;
  58432. /**
  58433. * Creates a new Database
  58434. * @param urlToScene defines the url to load the scene
  58435. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58436. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58437. */
  58438. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58439. private static _ParseURL;
  58440. private static _ReturnFullUrlLocation;
  58441. private _checkManifestFile;
  58442. /**
  58443. * Open the database and make it available
  58444. * @param successCallback defines the callback to call on success
  58445. * @param errorCallback defines the callback to call on error
  58446. */
  58447. open(successCallback: () => void, errorCallback: () => void): void;
  58448. /**
  58449. * Loads an image from the database
  58450. * @param url defines the url to load from
  58451. * @param image defines the target DOM image
  58452. */
  58453. loadImage(url: string, image: HTMLImageElement): void;
  58454. private _loadImageFromDBAsync;
  58455. private _saveImageIntoDBAsync;
  58456. private _checkVersionFromDB;
  58457. private _loadVersionFromDBAsync;
  58458. private _saveVersionIntoDBAsync;
  58459. /**
  58460. * Loads a file from database
  58461. * @param url defines the URL to load from
  58462. * @param sceneLoaded defines a callback to call on success
  58463. * @param progressCallBack defines a callback to call when progress changed
  58464. * @param errorCallback defines a callback to call on error
  58465. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58466. */
  58467. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58468. private _loadFileAsync;
  58469. private _saveFileAsync;
  58470. /**
  58471. * Validates if xhr data is correct
  58472. * @param xhr defines the request to validate
  58473. * @param dataType defines the expected data type
  58474. * @returns true if data is correct
  58475. */
  58476. private static _ValidateXHRData;
  58477. }
  58478. }
  58479. declare module "babylonjs/Offline/index" {
  58480. export * from "babylonjs/Offline/database";
  58481. export * from "babylonjs/Offline/IOfflineProvider";
  58482. }
  58483. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58484. /** @hidden */
  58485. export var gpuUpdateParticlesPixelShader: {
  58486. name: string;
  58487. shader: string;
  58488. };
  58489. }
  58490. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58491. /** @hidden */
  58492. export var gpuUpdateParticlesVertexShader: {
  58493. name: string;
  58494. shader: string;
  58495. };
  58496. }
  58497. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58498. /** @hidden */
  58499. export var clipPlaneFragmentDeclaration2: {
  58500. name: string;
  58501. shader: string;
  58502. };
  58503. }
  58504. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58505. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58506. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58507. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58508. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58509. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58510. /** @hidden */
  58511. export var gpuRenderParticlesPixelShader: {
  58512. name: string;
  58513. shader: string;
  58514. };
  58515. }
  58516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58517. /** @hidden */
  58518. export var clipPlaneVertexDeclaration2: {
  58519. name: string;
  58520. shader: string;
  58521. };
  58522. }
  58523. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58524. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58526. /** @hidden */
  58527. export var gpuRenderParticlesVertexShader: {
  58528. name: string;
  58529. shader: string;
  58530. };
  58531. }
  58532. declare module "babylonjs/Particles/gpuParticleSystem" {
  58533. import { Nullable } from "babylonjs/types";
  58534. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58535. import { Observable } from "babylonjs/Misc/observable";
  58536. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58537. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58538. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58539. import { Scene, IDisposable } from "babylonjs/scene";
  58540. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58541. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58542. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58543. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58544. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58545. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58546. /**
  58547. * This represents a GPU particle system in Babylon
  58548. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58549. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58550. */
  58551. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58552. /**
  58553. * The layer mask we are rendering the particles through.
  58554. */
  58555. layerMask: number;
  58556. private _capacity;
  58557. private _activeCount;
  58558. private _currentActiveCount;
  58559. private _accumulatedCount;
  58560. private _renderEffect;
  58561. private _updateEffect;
  58562. private _buffer0;
  58563. private _buffer1;
  58564. private _spriteBuffer;
  58565. private _updateVAO;
  58566. private _renderVAO;
  58567. private _targetIndex;
  58568. private _sourceBuffer;
  58569. private _targetBuffer;
  58570. private _engine;
  58571. private _currentRenderId;
  58572. private _started;
  58573. private _stopped;
  58574. private _timeDelta;
  58575. private _randomTexture;
  58576. private _randomTexture2;
  58577. private _attributesStrideSize;
  58578. private _updateEffectOptions;
  58579. private _randomTextureSize;
  58580. private _actualFrame;
  58581. private readonly _rawTextureWidth;
  58582. /**
  58583. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58584. */
  58585. static readonly IsSupported: boolean;
  58586. /**
  58587. * An event triggered when the system is disposed.
  58588. */
  58589. onDisposeObservable: Observable<GPUParticleSystem>;
  58590. /**
  58591. * Gets the maximum number of particles active at the same time.
  58592. * @returns The max number of active particles.
  58593. */
  58594. getCapacity(): number;
  58595. /**
  58596. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58597. * to override the particles.
  58598. */
  58599. forceDepthWrite: boolean;
  58600. /**
  58601. * Gets or set the number of active particles
  58602. */
  58603. activeParticleCount: number;
  58604. private _preWarmDone;
  58605. /**
  58606. * Is this system ready to be used/rendered
  58607. * @return true if the system is ready
  58608. */
  58609. isReady(): boolean;
  58610. /**
  58611. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58612. * @returns True if it has been started, otherwise false.
  58613. */
  58614. isStarted(): boolean;
  58615. /**
  58616. * Starts the particle system and begins to emit
  58617. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58618. */
  58619. start(delay?: number): void;
  58620. /**
  58621. * Stops the particle system.
  58622. */
  58623. stop(): void;
  58624. /**
  58625. * Remove all active particles
  58626. */
  58627. reset(): void;
  58628. /**
  58629. * Returns the string "GPUParticleSystem"
  58630. * @returns a string containing the class name
  58631. */
  58632. getClassName(): string;
  58633. private _colorGradientsTexture;
  58634. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58635. /**
  58636. * Adds a new color gradient
  58637. * @param gradient defines the gradient to use (between 0 and 1)
  58638. * @param color1 defines the color to affect to the specified gradient
  58639. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58640. * @returns the current particle system
  58641. */
  58642. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58643. /**
  58644. * Remove a specific color gradient
  58645. * @param gradient defines the gradient to remove
  58646. * @returns the current particle system
  58647. */
  58648. removeColorGradient(gradient: number): GPUParticleSystem;
  58649. private _angularSpeedGradientsTexture;
  58650. private _sizeGradientsTexture;
  58651. private _velocityGradientsTexture;
  58652. private _limitVelocityGradientsTexture;
  58653. private _dragGradientsTexture;
  58654. private _addFactorGradient;
  58655. /**
  58656. * Adds a new size gradient
  58657. * @param gradient defines the gradient to use (between 0 and 1)
  58658. * @param factor defines the size factor to affect to the specified gradient
  58659. * @returns the current particle system
  58660. */
  58661. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58662. /**
  58663. * Remove a specific size gradient
  58664. * @param gradient defines the gradient to remove
  58665. * @returns the current particle system
  58666. */
  58667. removeSizeGradient(gradient: number): GPUParticleSystem;
  58668. /**
  58669. * Adds a new angular speed gradient
  58670. * @param gradient defines the gradient to use (between 0 and 1)
  58671. * @param factor defines the angular speed to affect to the specified gradient
  58672. * @returns the current particle system
  58673. */
  58674. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58675. /**
  58676. * Remove a specific angular speed gradient
  58677. * @param gradient defines the gradient to remove
  58678. * @returns the current particle system
  58679. */
  58680. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58681. /**
  58682. * Adds a new velocity gradient
  58683. * @param gradient defines the gradient to use (between 0 and 1)
  58684. * @param factor defines the velocity to affect to the specified gradient
  58685. * @returns the current particle system
  58686. */
  58687. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58688. /**
  58689. * Remove a specific velocity gradient
  58690. * @param gradient defines the gradient to remove
  58691. * @returns the current particle system
  58692. */
  58693. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58694. /**
  58695. * Adds a new limit velocity gradient
  58696. * @param gradient defines the gradient to use (between 0 and 1)
  58697. * @param factor defines the limit velocity value to affect to the specified gradient
  58698. * @returns the current particle system
  58699. */
  58700. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58701. /**
  58702. * Remove a specific limit velocity gradient
  58703. * @param gradient defines the gradient to remove
  58704. * @returns the current particle system
  58705. */
  58706. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58707. /**
  58708. * Adds a new drag gradient
  58709. * @param gradient defines the gradient to use (between 0 and 1)
  58710. * @param factor defines the drag value to affect to the specified gradient
  58711. * @returns the current particle system
  58712. */
  58713. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58714. /**
  58715. * Remove a specific drag gradient
  58716. * @param gradient defines the gradient to remove
  58717. * @returns the current particle system
  58718. */
  58719. removeDragGradient(gradient: number): GPUParticleSystem;
  58720. /**
  58721. * Not supported by GPUParticleSystem
  58722. * @param gradient defines the gradient to use (between 0 and 1)
  58723. * @param factor defines the emit rate value to affect to the specified gradient
  58724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58725. * @returns the current particle system
  58726. */
  58727. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58728. /**
  58729. * Not supported by GPUParticleSystem
  58730. * @param gradient defines the gradient to remove
  58731. * @returns the current particle system
  58732. */
  58733. removeEmitRateGradient(gradient: number): IParticleSystem;
  58734. /**
  58735. * Not supported by GPUParticleSystem
  58736. * @param gradient defines the gradient to use (between 0 and 1)
  58737. * @param factor defines the start size value to affect to the specified gradient
  58738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58739. * @returns the current particle system
  58740. */
  58741. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58742. /**
  58743. * Not supported by GPUParticleSystem
  58744. * @param gradient defines the gradient to remove
  58745. * @returns the current particle system
  58746. */
  58747. removeStartSizeGradient(gradient: number): IParticleSystem;
  58748. /**
  58749. * Not supported by GPUParticleSystem
  58750. * @param gradient defines the gradient to use (between 0 and 1)
  58751. * @param min defines the color remap minimal range
  58752. * @param max defines the color remap maximal range
  58753. * @returns the current particle system
  58754. */
  58755. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58756. /**
  58757. * Not supported by GPUParticleSystem
  58758. * @param gradient defines the gradient to remove
  58759. * @returns the current particle system
  58760. */
  58761. removeColorRemapGradient(): IParticleSystem;
  58762. /**
  58763. * Not supported by GPUParticleSystem
  58764. * @param gradient defines the gradient to use (between 0 and 1)
  58765. * @param min defines the alpha remap minimal range
  58766. * @param max defines the alpha remap maximal range
  58767. * @returns the current particle system
  58768. */
  58769. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58770. /**
  58771. * Not supported by GPUParticleSystem
  58772. * @param gradient defines the gradient to remove
  58773. * @returns the current particle system
  58774. */
  58775. removeAlphaRemapGradient(): IParticleSystem;
  58776. /**
  58777. * Not supported by GPUParticleSystem
  58778. * @param gradient defines the gradient to use (between 0 and 1)
  58779. * @param color defines the color to affect to the specified gradient
  58780. * @returns the current particle system
  58781. */
  58782. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58783. /**
  58784. * Not supported by GPUParticleSystem
  58785. * @param gradient defines the gradient to remove
  58786. * @returns the current particle system
  58787. */
  58788. removeRampGradient(): IParticleSystem;
  58789. /**
  58790. * Not supported by GPUParticleSystem
  58791. * @returns the list of ramp gradients
  58792. */
  58793. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58794. /**
  58795. * Not supported by GPUParticleSystem
  58796. * Gets or sets a boolean indicating that ramp gradients must be used
  58797. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58798. */
  58799. useRampGradients: boolean;
  58800. /**
  58801. * Not supported by GPUParticleSystem
  58802. * @param gradient defines the gradient to use (between 0 and 1)
  58803. * @param factor defines the life time factor to affect to the specified gradient
  58804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58805. * @returns the current particle system
  58806. */
  58807. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58808. /**
  58809. * Not supported by GPUParticleSystem
  58810. * @param gradient defines the gradient to remove
  58811. * @returns the current particle system
  58812. */
  58813. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58814. /**
  58815. * Instantiates a GPU particle system.
  58816. * 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.
  58817. * @param name The name of the particle system
  58818. * @param options The options used to create the system
  58819. * @param scene The scene the particle system belongs to
  58820. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58821. */
  58822. constructor(name: string, options: Partial<{
  58823. capacity: number;
  58824. randomTextureSize: number;
  58825. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58826. protected _reset(): void;
  58827. private _createUpdateVAO;
  58828. private _createRenderVAO;
  58829. private _initialize;
  58830. /** @hidden */
  58831. _recreateUpdateEffect(): void;
  58832. /** @hidden */
  58833. _recreateRenderEffect(): void;
  58834. /**
  58835. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58836. * @param preWarm defines if we are in the pre-warmimg phase
  58837. */
  58838. animate(preWarm?: boolean): void;
  58839. private _createFactorGradientTexture;
  58840. private _createSizeGradientTexture;
  58841. private _createAngularSpeedGradientTexture;
  58842. private _createVelocityGradientTexture;
  58843. private _createLimitVelocityGradientTexture;
  58844. private _createDragGradientTexture;
  58845. private _createColorGradientTexture;
  58846. /**
  58847. * Renders the particle system in its current state
  58848. * @param preWarm defines if the system should only update the particles but not render them
  58849. * @returns the current number of particles
  58850. */
  58851. render(preWarm?: boolean): number;
  58852. /**
  58853. * Rebuilds the particle system
  58854. */
  58855. rebuild(): void;
  58856. private _releaseBuffers;
  58857. private _releaseVAOs;
  58858. /**
  58859. * Disposes the particle system and free the associated resources
  58860. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58861. */
  58862. dispose(disposeTexture?: boolean): void;
  58863. /**
  58864. * Clones the particle system.
  58865. * @param name The name of the cloned object
  58866. * @param newEmitter The new emitter to use
  58867. * @returns the cloned particle system
  58868. */
  58869. clone(name: string, newEmitter: any): GPUParticleSystem;
  58870. /**
  58871. * Serializes the particle system to a JSON object.
  58872. * @returns the JSON object
  58873. */
  58874. serialize(): any;
  58875. /**
  58876. * Parses a JSON object to create a GPU particle system.
  58877. * @param parsedParticleSystem The JSON object to parse
  58878. * @param scene The scene to create the particle system in
  58879. * @param rootUrl The root url to use to load external dependencies like texture
  58880. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58881. * @returns the parsed GPU particle system
  58882. */
  58883. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58884. }
  58885. }
  58886. declare module "babylonjs/Particles/particleSystemSet" {
  58887. import { Nullable } from "babylonjs/types";
  58888. import { Color3 } from "babylonjs/Maths/math.color";
  58889. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58891. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58892. import { Scene, IDisposable } from "babylonjs/scene";
  58893. /**
  58894. * Represents a set of particle systems working together to create a specific effect
  58895. */
  58896. export class ParticleSystemSet implements IDisposable {
  58897. private _emitterCreationOptions;
  58898. private _emitterNode;
  58899. /**
  58900. * Gets the particle system list
  58901. */
  58902. systems: IParticleSystem[];
  58903. /**
  58904. * Gets the emitter node used with this set
  58905. */
  58906. readonly emitterNode: Nullable<TransformNode>;
  58907. /**
  58908. * Creates a new emitter mesh as a sphere
  58909. * @param options defines the options used to create the sphere
  58910. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58911. * @param scene defines the hosting scene
  58912. */
  58913. setEmitterAsSphere(options: {
  58914. diameter: number;
  58915. segments: number;
  58916. color: Color3;
  58917. }, renderingGroupId: number, scene: Scene): void;
  58918. /**
  58919. * Starts all particle systems of the set
  58920. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58921. */
  58922. start(emitter?: AbstractMesh): void;
  58923. /**
  58924. * Release all associated resources
  58925. */
  58926. dispose(): void;
  58927. /**
  58928. * Serialize the set into a JSON compatible object
  58929. * @returns a JSON compatible representation of the set
  58930. */
  58931. serialize(): any;
  58932. /**
  58933. * Parse a new ParticleSystemSet from a serialized source
  58934. * @param data defines a JSON compatible representation of the set
  58935. * @param scene defines the hosting scene
  58936. * @param gpu defines if we want GPU particles or CPU particles
  58937. * @returns a new ParticleSystemSet
  58938. */
  58939. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58940. }
  58941. }
  58942. declare module "babylonjs/Particles/particleHelper" {
  58943. import { Nullable } from "babylonjs/types";
  58944. import { Scene } from "babylonjs/scene";
  58945. import { Vector3 } from "babylonjs/Maths/math.vector";
  58946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58947. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58948. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58949. /**
  58950. * This class is made for on one-liner static method to help creating particle system set.
  58951. */
  58952. export class ParticleHelper {
  58953. /**
  58954. * Gets or sets base Assets URL
  58955. */
  58956. static BaseAssetsUrl: string;
  58957. /**
  58958. * Create a default particle system that you can tweak
  58959. * @param emitter defines the emitter to use
  58960. * @param capacity defines the system capacity (default is 500 particles)
  58961. * @param scene defines the hosting scene
  58962. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58963. * @returns the new Particle system
  58964. */
  58965. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58966. /**
  58967. * This is the main static method (one-liner) of this helper to create different particle systems
  58968. * @param type This string represents the type to the particle system to create
  58969. * @param scene The scene where the particle system should live
  58970. * @param gpu If the system will use gpu
  58971. * @returns the ParticleSystemSet created
  58972. */
  58973. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58974. /**
  58975. * Static function used to export a particle system to a ParticleSystemSet variable.
  58976. * Please note that the emitter shape is not exported
  58977. * @param systems defines the particle systems to export
  58978. * @returns the created particle system set
  58979. */
  58980. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58981. }
  58982. }
  58983. declare module "babylonjs/Particles/particleSystemComponent" {
  58984. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58985. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58986. import "babylonjs/Shaders/particles.vertex";
  58987. module "babylonjs/Engines/engine" {
  58988. interface Engine {
  58989. /**
  58990. * Create an effect to use with particle systems.
  58991. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58992. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58993. * @param uniformsNames defines a list of attribute names
  58994. * @param samplers defines an array of string used to represent textures
  58995. * @param defines defines the string containing the defines to use to compile the shaders
  58996. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58997. * @param onCompiled defines a function to call when the effect creation is successful
  58998. * @param onError defines a function to call when the effect creation has failed
  58999. * @returns the new Effect
  59000. */
  59001. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59002. }
  59003. }
  59004. module "babylonjs/Meshes/mesh" {
  59005. interface Mesh {
  59006. /**
  59007. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59008. * @returns an array of IParticleSystem
  59009. */
  59010. getEmittedParticleSystems(): IParticleSystem[];
  59011. /**
  59012. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59013. * @returns an array of IParticleSystem
  59014. */
  59015. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59016. }
  59017. }
  59018. /**
  59019. * @hidden
  59020. */
  59021. export var _IDoNeedToBeInTheBuild: number;
  59022. }
  59023. declare module "babylonjs/Particles/index" {
  59024. export * from "babylonjs/Particles/baseParticleSystem";
  59025. export * from "babylonjs/Particles/EmitterTypes/index";
  59026. export * from "babylonjs/Particles/gpuParticleSystem";
  59027. export * from "babylonjs/Particles/IParticleSystem";
  59028. export * from "babylonjs/Particles/particle";
  59029. export * from "babylonjs/Particles/particleHelper";
  59030. export * from "babylonjs/Particles/particleSystem";
  59031. export * from "babylonjs/Particles/particleSystemComponent";
  59032. export * from "babylonjs/Particles/particleSystemSet";
  59033. export * from "babylonjs/Particles/solidParticle";
  59034. export * from "babylonjs/Particles/solidParticleSystem";
  59035. export * from "babylonjs/Particles/subEmitter";
  59036. }
  59037. declare module "babylonjs/Physics/physicsEngineComponent" {
  59038. import { Nullable } from "babylonjs/types";
  59039. import { Observable, Observer } from "babylonjs/Misc/observable";
  59040. import { Vector3 } from "babylonjs/Maths/math.vector";
  59041. import { Mesh } from "babylonjs/Meshes/mesh";
  59042. import { ISceneComponent } from "babylonjs/sceneComponent";
  59043. import { Scene } from "babylonjs/scene";
  59044. import { Node } from "babylonjs/node";
  59045. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59046. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59047. module "babylonjs/scene" {
  59048. interface Scene {
  59049. /** @hidden (Backing field) */
  59050. _physicsEngine: Nullable<IPhysicsEngine>;
  59051. /**
  59052. * Gets the current physics engine
  59053. * @returns a IPhysicsEngine or null if none attached
  59054. */
  59055. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59056. /**
  59057. * Enables physics to the current scene
  59058. * @param gravity defines the scene's gravity for the physics engine
  59059. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59060. * @return a boolean indicating if the physics engine was initialized
  59061. */
  59062. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59063. /**
  59064. * Disables and disposes the physics engine associated with the scene
  59065. */
  59066. disablePhysicsEngine(): void;
  59067. /**
  59068. * Gets a boolean indicating if there is an active physics engine
  59069. * @returns a boolean indicating if there is an active physics engine
  59070. */
  59071. isPhysicsEnabled(): boolean;
  59072. /**
  59073. * Deletes a physics compound impostor
  59074. * @param compound defines the compound to delete
  59075. */
  59076. deleteCompoundImpostor(compound: any): void;
  59077. /**
  59078. * An event triggered when physic simulation is about to be run
  59079. */
  59080. onBeforePhysicsObservable: Observable<Scene>;
  59081. /**
  59082. * An event triggered when physic simulation has been done
  59083. */
  59084. onAfterPhysicsObservable: Observable<Scene>;
  59085. }
  59086. }
  59087. module "babylonjs/Meshes/abstractMesh" {
  59088. interface AbstractMesh {
  59089. /** @hidden */
  59090. _physicsImpostor: Nullable<PhysicsImpostor>;
  59091. /**
  59092. * Gets or sets impostor used for physic simulation
  59093. * @see http://doc.babylonjs.com/features/physics_engine
  59094. */
  59095. physicsImpostor: Nullable<PhysicsImpostor>;
  59096. /**
  59097. * Gets the current physics impostor
  59098. * @see http://doc.babylonjs.com/features/physics_engine
  59099. * @returns a physics impostor or null
  59100. */
  59101. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59102. /** Apply a physic impulse to the mesh
  59103. * @param force defines the force to apply
  59104. * @param contactPoint defines where to apply the force
  59105. * @returns the current mesh
  59106. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59107. */
  59108. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59109. /**
  59110. * Creates a physic joint between two meshes
  59111. * @param otherMesh defines the other mesh to use
  59112. * @param pivot1 defines the pivot to use on this mesh
  59113. * @param pivot2 defines the pivot to use on the other mesh
  59114. * @param options defines additional options (can be plugin dependent)
  59115. * @returns the current mesh
  59116. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59117. */
  59118. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59119. /** @hidden */
  59120. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59121. }
  59122. }
  59123. /**
  59124. * Defines the physics engine scene component responsible to manage a physics engine
  59125. */
  59126. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59127. /**
  59128. * The component name helpful to identify the component in the list of scene components.
  59129. */
  59130. readonly name: string;
  59131. /**
  59132. * The scene the component belongs to.
  59133. */
  59134. scene: Scene;
  59135. /**
  59136. * Creates a new instance of the component for the given scene
  59137. * @param scene Defines the scene to register the component in
  59138. */
  59139. constructor(scene: Scene);
  59140. /**
  59141. * Registers the component in a given scene
  59142. */
  59143. register(): void;
  59144. /**
  59145. * Rebuilds the elements related to this component in case of
  59146. * context lost for instance.
  59147. */
  59148. rebuild(): void;
  59149. /**
  59150. * Disposes the component and the associated ressources
  59151. */
  59152. dispose(): void;
  59153. }
  59154. }
  59155. declare module "babylonjs/Physics/physicsHelper" {
  59156. import { Nullable } from "babylonjs/types";
  59157. import { Vector3 } from "babylonjs/Maths/math.vector";
  59158. import { Mesh } from "babylonjs/Meshes/mesh";
  59159. import { Scene } from "babylonjs/scene";
  59160. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59161. /**
  59162. * A helper for physics simulations
  59163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59164. */
  59165. export class PhysicsHelper {
  59166. private _scene;
  59167. private _physicsEngine;
  59168. /**
  59169. * Initializes the Physics helper
  59170. * @param scene Babylon.js scene
  59171. */
  59172. constructor(scene: Scene);
  59173. /**
  59174. * Applies a radial explosion impulse
  59175. * @param origin the origin of the explosion
  59176. * @param radiusOrEventOptions the radius or the options of radial explosion
  59177. * @param strength the explosion strength
  59178. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59179. * @returns A physics radial explosion event, or null
  59180. */
  59181. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59182. /**
  59183. * Applies a radial explosion force
  59184. * @param origin the origin of the explosion
  59185. * @param radiusOrEventOptions the radius or the options of radial explosion
  59186. * @param strength the explosion strength
  59187. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59188. * @returns A physics radial explosion event, or null
  59189. */
  59190. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59191. /**
  59192. * Creates a gravitational field
  59193. * @param origin the origin of the explosion
  59194. * @param radiusOrEventOptions the radius or the options of radial explosion
  59195. * @param strength the explosion strength
  59196. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59197. * @returns A physics gravitational field event, or null
  59198. */
  59199. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59200. /**
  59201. * Creates a physics updraft event
  59202. * @param origin the origin of the updraft
  59203. * @param radiusOrEventOptions the radius or the options of the updraft
  59204. * @param strength the strength of the updraft
  59205. * @param height the height of the updraft
  59206. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59207. * @returns A physics updraft event, or null
  59208. */
  59209. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59210. /**
  59211. * Creates a physics vortex event
  59212. * @param origin the of the vortex
  59213. * @param radiusOrEventOptions the radius or the options of the vortex
  59214. * @param strength the strength of the vortex
  59215. * @param height the height of the vortex
  59216. * @returns a Physics vortex event, or null
  59217. * A physics vortex event or null
  59218. */
  59219. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59220. }
  59221. /**
  59222. * Represents a physics radial explosion event
  59223. */
  59224. class PhysicsRadialExplosionEvent {
  59225. private _scene;
  59226. private _options;
  59227. private _sphere;
  59228. private _dataFetched;
  59229. /**
  59230. * Initializes a radial explosioin event
  59231. * @param _scene BabylonJS scene
  59232. * @param _options The options for the vortex event
  59233. */
  59234. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59235. /**
  59236. * Returns the data related to the radial explosion event (sphere).
  59237. * @returns The radial explosion event data
  59238. */
  59239. getData(): PhysicsRadialExplosionEventData;
  59240. /**
  59241. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59242. * @param impostor A physics imposter
  59243. * @param origin the origin of the explosion
  59244. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59245. */
  59246. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59247. /**
  59248. * Triggers affecterd impostors callbacks
  59249. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59250. */
  59251. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59252. /**
  59253. * Disposes the sphere.
  59254. * @param force Specifies if the sphere should be disposed by force
  59255. */
  59256. dispose(force?: boolean): void;
  59257. /*** Helpers ***/
  59258. private _prepareSphere;
  59259. private _intersectsWithSphere;
  59260. }
  59261. /**
  59262. * Represents a gravitational field event
  59263. */
  59264. class PhysicsGravitationalFieldEvent {
  59265. private _physicsHelper;
  59266. private _scene;
  59267. private _origin;
  59268. private _options;
  59269. private _tickCallback;
  59270. private _sphere;
  59271. private _dataFetched;
  59272. /**
  59273. * Initializes the physics gravitational field event
  59274. * @param _physicsHelper A physics helper
  59275. * @param _scene BabylonJS scene
  59276. * @param _origin The origin position of the gravitational field event
  59277. * @param _options The options for the vortex event
  59278. */
  59279. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59280. /**
  59281. * Returns the data related to the gravitational field event (sphere).
  59282. * @returns A gravitational field event
  59283. */
  59284. getData(): PhysicsGravitationalFieldEventData;
  59285. /**
  59286. * Enables the gravitational field.
  59287. */
  59288. enable(): void;
  59289. /**
  59290. * Disables the gravitational field.
  59291. */
  59292. disable(): void;
  59293. /**
  59294. * Disposes the sphere.
  59295. * @param force The force to dispose from the gravitational field event
  59296. */
  59297. dispose(force?: boolean): void;
  59298. private _tick;
  59299. }
  59300. /**
  59301. * Represents a physics updraft event
  59302. */
  59303. class PhysicsUpdraftEvent {
  59304. private _scene;
  59305. private _origin;
  59306. private _options;
  59307. private _physicsEngine;
  59308. private _originTop;
  59309. private _originDirection;
  59310. private _tickCallback;
  59311. private _cylinder;
  59312. private _cylinderPosition;
  59313. private _dataFetched;
  59314. /**
  59315. * Initializes the physics updraft event
  59316. * @param _scene BabylonJS scene
  59317. * @param _origin The origin position of the updraft
  59318. * @param _options The options for the updraft event
  59319. */
  59320. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59321. /**
  59322. * Returns the data related to the updraft event (cylinder).
  59323. * @returns A physics updraft event
  59324. */
  59325. getData(): PhysicsUpdraftEventData;
  59326. /**
  59327. * Enables the updraft.
  59328. */
  59329. enable(): void;
  59330. /**
  59331. * Disables the updraft.
  59332. */
  59333. disable(): void;
  59334. /**
  59335. * Disposes the cylinder.
  59336. * @param force Specifies if the updraft should be disposed by force
  59337. */
  59338. dispose(force?: boolean): void;
  59339. private getImpostorHitData;
  59340. private _tick;
  59341. /*** Helpers ***/
  59342. private _prepareCylinder;
  59343. private _intersectsWithCylinder;
  59344. }
  59345. /**
  59346. * Represents a physics vortex event
  59347. */
  59348. class PhysicsVortexEvent {
  59349. private _scene;
  59350. private _origin;
  59351. private _options;
  59352. private _physicsEngine;
  59353. private _originTop;
  59354. private _tickCallback;
  59355. private _cylinder;
  59356. private _cylinderPosition;
  59357. private _dataFetched;
  59358. /**
  59359. * Initializes the physics vortex event
  59360. * @param _scene The BabylonJS scene
  59361. * @param _origin The origin position of the vortex
  59362. * @param _options The options for the vortex event
  59363. */
  59364. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59365. /**
  59366. * Returns the data related to the vortex event (cylinder).
  59367. * @returns The physics vortex event data
  59368. */
  59369. getData(): PhysicsVortexEventData;
  59370. /**
  59371. * Enables the vortex.
  59372. */
  59373. enable(): void;
  59374. /**
  59375. * Disables the cortex.
  59376. */
  59377. disable(): void;
  59378. /**
  59379. * Disposes the sphere.
  59380. * @param force
  59381. */
  59382. dispose(force?: boolean): void;
  59383. private getImpostorHitData;
  59384. private _tick;
  59385. /*** Helpers ***/
  59386. private _prepareCylinder;
  59387. private _intersectsWithCylinder;
  59388. }
  59389. /**
  59390. * Options fot the radial explosion event
  59391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59392. */
  59393. export class PhysicsRadialExplosionEventOptions {
  59394. /**
  59395. * The radius of the sphere for the radial explosion.
  59396. */
  59397. radius: number;
  59398. /**
  59399. * The strenth of the explosion.
  59400. */
  59401. strength: number;
  59402. /**
  59403. * The strenght of the force in correspondence to the distance of the affected object
  59404. */
  59405. falloff: PhysicsRadialImpulseFalloff;
  59406. /**
  59407. * Sphere options for the radial explosion.
  59408. */
  59409. sphere: {
  59410. segments: number;
  59411. diameter: number;
  59412. };
  59413. /**
  59414. * Sphere options for the radial explosion.
  59415. */
  59416. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59417. }
  59418. /**
  59419. * Options fot the updraft event
  59420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59421. */
  59422. export class PhysicsUpdraftEventOptions {
  59423. /**
  59424. * The radius of the cylinder for the vortex
  59425. */
  59426. radius: number;
  59427. /**
  59428. * The strenth of the updraft.
  59429. */
  59430. strength: number;
  59431. /**
  59432. * The height of the cylinder for the updraft.
  59433. */
  59434. height: number;
  59435. /**
  59436. * The mode for the the updraft.
  59437. */
  59438. updraftMode: PhysicsUpdraftMode;
  59439. }
  59440. /**
  59441. * Options fot the vortex event
  59442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59443. */
  59444. export class PhysicsVortexEventOptions {
  59445. /**
  59446. * The radius of the cylinder for the vortex
  59447. */
  59448. radius: number;
  59449. /**
  59450. * The strenth of the vortex.
  59451. */
  59452. strength: number;
  59453. /**
  59454. * The height of the cylinder for the vortex.
  59455. */
  59456. height: number;
  59457. /**
  59458. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59459. */
  59460. centripetalForceThreshold: number;
  59461. /**
  59462. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59463. */
  59464. centripetalForceMultiplier: number;
  59465. /**
  59466. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59467. */
  59468. centrifugalForceMultiplier: number;
  59469. /**
  59470. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59471. */
  59472. updraftForceMultiplier: number;
  59473. }
  59474. /**
  59475. * The strenght of the force in correspondence to the distance of the affected object
  59476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59477. */
  59478. export enum PhysicsRadialImpulseFalloff {
  59479. /** Defines that impulse is constant in strength across it's whole radius */
  59480. Constant = 0,
  59481. /** Defines that impulse gets weaker if it's further from the origin */
  59482. Linear = 1
  59483. }
  59484. /**
  59485. * The strength of the force in correspondence to the distance of the affected object
  59486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59487. */
  59488. export enum PhysicsUpdraftMode {
  59489. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59490. Center = 0,
  59491. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59492. Perpendicular = 1
  59493. }
  59494. /**
  59495. * Interface for a physics hit data
  59496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59497. */
  59498. export interface PhysicsHitData {
  59499. /**
  59500. * The force applied at the contact point
  59501. */
  59502. force: Vector3;
  59503. /**
  59504. * The contact point
  59505. */
  59506. contactPoint: Vector3;
  59507. /**
  59508. * The distance from the origin to the contact point
  59509. */
  59510. distanceFromOrigin: number;
  59511. }
  59512. /**
  59513. * Interface for radial explosion event data
  59514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59515. */
  59516. export interface PhysicsRadialExplosionEventData {
  59517. /**
  59518. * A sphere used for the radial explosion event
  59519. */
  59520. sphere: Mesh;
  59521. }
  59522. /**
  59523. * Interface for gravitational field event data
  59524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59525. */
  59526. export interface PhysicsGravitationalFieldEventData {
  59527. /**
  59528. * A sphere mesh used for the gravitational field event
  59529. */
  59530. sphere: Mesh;
  59531. }
  59532. /**
  59533. * Interface for updraft event data
  59534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59535. */
  59536. export interface PhysicsUpdraftEventData {
  59537. /**
  59538. * A cylinder used for the updraft event
  59539. */
  59540. cylinder: Mesh;
  59541. }
  59542. /**
  59543. * Interface for vortex event data
  59544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59545. */
  59546. export interface PhysicsVortexEventData {
  59547. /**
  59548. * A cylinder used for the vortex event
  59549. */
  59550. cylinder: Mesh;
  59551. }
  59552. /**
  59553. * Interface for an affected physics impostor
  59554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59555. */
  59556. export interface PhysicsAffectedImpostorWithData {
  59557. /**
  59558. * The impostor affected by the effect
  59559. */
  59560. impostor: PhysicsImpostor;
  59561. /**
  59562. * The data about the hit/horce from the explosion
  59563. */
  59564. hitData: PhysicsHitData;
  59565. }
  59566. }
  59567. declare module "babylonjs/Physics/Plugins/index" {
  59568. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59569. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59570. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59571. }
  59572. declare module "babylonjs/Physics/index" {
  59573. export * from "babylonjs/Physics/IPhysicsEngine";
  59574. export * from "babylonjs/Physics/physicsEngine";
  59575. export * from "babylonjs/Physics/physicsEngineComponent";
  59576. export * from "babylonjs/Physics/physicsHelper";
  59577. export * from "babylonjs/Physics/physicsImpostor";
  59578. export * from "babylonjs/Physics/physicsJoint";
  59579. export * from "babylonjs/Physics/Plugins/index";
  59580. }
  59581. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59582. /** @hidden */
  59583. export var blackAndWhitePixelShader: {
  59584. name: string;
  59585. shader: string;
  59586. };
  59587. }
  59588. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59590. import { Camera } from "babylonjs/Cameras/camera";
  59591. import { Engine } from "babylonjs/Engines/engine";
  59592. import "babylonjs/Shaders/blackAndWhite.fragment";
  59593. /**
  59594. * Post process used to render in black and white
  59595. */
  59596. export class BlackAndWhitePostProcess extends PostProcess {
  59597. /**
  59598. * Linear about to convert he result to black and white (default: 1)
  59599. */
  59600. degree: number;
  59601. /**
  59602. * Creates a black and white post process
  59603. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59604. * @param name The name of the effect.
  59605. * @param options The required width/height ratio to downsize to before computing the render pass.
  59606. * @param camera The camera to apply the render pass to.
  59607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59608. * @param engine The engine which the post process will be applied. (default: current engine)
  59609. * @param reusable If the post process can be reused on the same frame. (default: false)
  59610. */
  59611. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59612. }
  59613. }
  59614. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59615. import { Nullable } from "babylonjs/types";
  59616. import { Camera } from "babylonjs/Cameras/camera";
  59617. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59618. import { Engine } from "babylonjs/Engines/engine";
  59619. /**
  59620. * This represents a set of one or more post processes in Babylon.
  59621. * A post process can be used to apply a shader to a texture after it is rendered.
  59622. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59623. */
  59624. export class PostProcessRenderEffect {
  59625. private _postProcesses;
  59626. private _getPostProcesses;
  59627. private _singleInstance;
  59628. private _cameras;
  59629. private _indicesForCamera;
  59630. /**
  59631. * Name of the effect
  59632. * @hidden
  59633. */
  59634. _name: string;
  59635. /**
  59636. * Instantiates a post process render effect.
  59637. * A post process can be used to apply a shader to a texture after it is rendered.
  59638. * @param engine The engine the effect is tied to
  59639. * @param name The name of the effect
  59640. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59641. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59642. */
  59643. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59644. /**
  59645. * Checks if all the post processes in the effect are supported.
  59646. */
  59647. readonly isSupported: boolean;
  59648. /**
  59649. * Updates the current state of the effect
  59650. * @hidden
  59651. */
  59652. _update(): void;
  59653. /**
  59654. * Attaches the effect on cameras
  59655. * @param cameras The camera to attach to.
  59656. * @hidden
  59657. */
  59658. _attachCameras(cameras: Camera): void;
  59659. /**
  59660. * Attaches the effect on cameras
  59661. * @param cameras The camera to attach to.
  59662. * @hidden
  59663. */
  59664. _attachCameras(cameras: Camera[]): void;
  59665. /**
  59666. * Detaches the effect on cameras
  59667. * @param cameras The camera to detatch from.
  59668. * @hidden
  59669. */
  59670. _detachCameras(cameras: Camera): void;
  59671. /**
  59672. * Detatches the effect on cameras
  59673. * @param cameras The camera to detatch from.
  59674. * @hidden
  59675. */
  59676. _detachCameras(cameras: Camera[]): void;
  59677. /**
  59678. * Enables the effect on given cameras
  59679. * @param cameras The camera to enable.
  59680. * @hidden
  59681. */
  59682. _enable(cameras: Camera): void;
  59683. /**
  59684. * Enables the effect on given cameras
  59685. * @param cameras The camera to enable.
  59686. * @hidden
  59687. */
  59688. _enable(cameras: Nullable<Camera[]>): void;
  59689. /**
  59690. * Disables the effect on the given cameras
  59691. * @param cameras The camera to disable.
  59692. * @hidden
  59693. */
  59694. _disable(cameras: Camera): void;
  59695. /**
  59696. * Disables the effect on the given cameras
  59697. * @param cameras The camera to disable.
  59698. * @hidden
  59699. */
  59700. _disable(cameras: Nullable<Camera[]>): void;
  59701. /**
  59702. * Gets a list of the post processes contained in the effect.
  59703. * @param camera The camera to get the post processes on.
  59704. * @returns The list of the post processes in the effect.
  59705. */
  59706. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59707. }
  59708. }
  59709. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59710. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59711. /** @hidden */
  59712. export var extractHighlightsPixelShader: {
  59713. name: string;
  59714. shader: string;
  59715. };
  59716. }
  59717. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59718. import { Nullable } from "babylonjs/types";
  59719. import { Camera } from "babylonjs/Cameras/camera";
  59720. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59721. import { Engine } from "babylonjs/Engines/engine";
  59722. import "babylonjs/Shaders/extractHighlights.fragment";
  59723. /**
  59724. * 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.
  59725. */
  59726. export class ExtractHighlightsPostProcess extends PostProcess {
  59727. /**
  59728. * The luminance threshold, pixels below this value will be set to black.
  59729. */
  59730. threshold: number;
  59731. /** @hidden */
  59732. _exposure: number;
  59733. /**
  59734. * Post process which has the input texture to be used when performing highlight extraction
  59735. * @hidden
  59736. */
  59737. _inputPostProcess: Nullable<PostProcess>;
  59738. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59739. }
  59740. }
  59741. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59742. /** @hidden */
  59743. export var bloomMergePixelShader: {
  59744. name: string;
  59745. shader: string;
  59746. };
  59747. }
  59748. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59750. import { Nullable } from "babylonjs/types";
  59751. import { Engine } from "babylonjs/Engines/engine";
  59752. import { Camera } from "babylonjs/Cameras/camera";
  59753. import "babylonjs/Shaders/bloomMerge.fragment";
  59754. /**
  59755. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59756. */
  59757. export class BloomMergePostProcess extends PostProcess {
  59758. /** Weight of the bloom to be added to the original input. */
  59759. weight: number;
  59760. /**
  59761. * Creates a new instance of @see BloomMergePostProcess
  59762. * @param name The name of the effect.
  59763. * @param originalFromInput Post process which's input will be used for the merge.
  59764. * @param blurred Blurred highlights post process which's output will be used.
  59765. * @param weight Weight of the bloom to be added to the original input.
  59766. * @param options The required width/height ratio to downsize to before computing the render pass.
  59767. * @param camera The camera to apply the render pass to.
  59768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59769. * @param engine The engine which the post process will be applied. (default: current engine)
  59770. * @param reusable If the post process can be reused on the same frame. (default: false)
  59771. * @param textureType Type of textures used when performing the post process. (default: 0)
  59772. * @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)
  59773. */
  59774. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59775. /** Weight of the bloom to be added to the original input. */
  59776. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59777. }
  59778. }
  59779. declare module "babylonjs/PostProcesses/bloomEffect" {
  59780. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59781. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59782. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59783. import { Camera } from "babylonjs/Cameras/camera";
  59784. import { Scene } from "babylonjs/scene";
  59785. /**
  59786. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59787. */
  59788. export class BloomEffect extends PostProcessRenderEffect {
  59789. private bloomScale;
  59790. /**
  59791. * @hidden Internal
  59792. */
  59793. _effects: Array<PostProcess>;
  59794. /**
  59795. * @hidden Internal
  59796. */
  59797. _downscale: ExtractHighlightsPostProcess;
  59798. private _blurX;
  59799. private _blurY;
  59800. private _merge;
  59801. /**
  59802. * The luminance threshold to find bright areas of the image to bloom.
  59803. */
  59804. threshold: number;
  59805. /**
  59806. * The strength of the bloom.
  59807. */
  59808. weight: number;
  59809. /**
  59810. * Specifies the size of the bloom blur kernel, relative to the final output size
  59811. */
  59812. kernel: number;
  59813. /**
  59814. * Creates a new instance of @see BloomEffect
  59815. * @param scene The scene the effect belongs to.
  59816. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59817. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59818. * @param bloomWeight The the strength of bloom.
  59819. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59820. * @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)
  59821. */
  59822. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59823. /**
  59824. * Disposes each of the internal effects for a given camera.
  59825. * @param camera The camera to dispose the effect on.
  59826. */
  59827. disposeEffects(camera: Camera): void;
  59828. /**
  59829. * @hidden Internal
  59830. */
  59831. _updateEffects(): void;
  59832. /**
  59833. * Internal
  59834. * @returns if all the contained post processes are ready.
  59835. * @hidden
  59836. */
  59837. _isReady(): boolean;
  59838. }
  59839. }
  59840. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59841. /** @hidden */
  59842. export var chromaticAberrationPixelShader: {
  59843. name: string;
  59844. shader: string;
  59845. };
  59846. }
  59847. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59848. import { Vector2 } from "babylonjs/Maths/math.vector";
  59849. import { Nullable } from "babylonjs/types";
  59850. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59851. import { Camera } from "babylonjs/Cameras/camera";
  59852. import { Engine } from "babylonjs/Engines/engine";
  59853. import "babylonjs/Shaders/chromaticAberration.fragment";
  59854. /**
  59855. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59856. */
  59857. export class ChromaticAberrationPostProcess extends PostProcess {
  59858. /**
  59859. * The amount of seperation of rgb channels (default: 30)
  59860. */
  59861. aberrationAmount: number;
  59862. /**
  59863. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59864. */
  59865. radialIntensity: number;
  59866. /**
  59867. * 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))
  59868. */
  59869. direction: Vector2;
  59870. /**
  59871. * 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))
  59872. */
  59873. centerPosition: Vector2;
  59874. /**
  59875. * Creates a new instance ChromaticAberrationPostProcess
  59876. * @param name The name of the effect.
  59877. * @param screenWidth The width of the screen to apply the effect on.
  59878. * @param screenHeight The height of the screen to apply the effect on.
  59879. * @param options The required width/height ratio to downsize to before computing the render pass.
  59880. * @param camera The camera to apply the render pass to.
  59881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59882. * @param engine The engine which the post process will be applied. (default: current engine)
  59883. * @param reusable If the post process can be reused on the same frame. (default: false)
  59884. * @param textureType Type of textures used when performing the post process. (default: 0)
  59885. * @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)
  59886. */
  59887. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59888. }
  59889. }
  59890. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59891. /** @hidden */
  59892. export var circleOfConfusionPixelShader: {
  59893. name: string;
  59894. shader: string;
  59895. };
  59896. }
  59897. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59898. import { Nullable } from "babylonjs/types";
  59899. import { Engine } from "babylonjs/Engines/engine";
  59900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59902. import { Camera } from "babylonjs/Cameras/camera";
  59903. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59904. /**
  59905. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59906. */
  59907. export class CircleOfConfusionPostProcess extends PostProcess {
  59908. /**
  59909. * 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.
  59910. */
  59911. lensSize: number;
  59912. /**
  59913. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59914. */
  59915. fStop: number;
  59916. /**
  59917. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59918. */
  59919. focusDistance: number;
  59920. /**
  59921. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59922. */
  59923. focalLength: number;
  59924. private _depthTexture;
  59925. /**
  59926. * Creates a new instance CircleOfConfusionPostProcess
  59927. * @param name The name of the effect.
  59928. * @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.
  59929. * @param options The required width/height ratio to downsize to before computing the render pass.
  59930. * @param camera The camera to apply the render pass to.
  59931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59932. * @param engine The engine which the post process will be applied. (default: current engine)
  59933. * @param reusable If the post process can be reused on the same frame. (default: false)
  59934. * @param textureType Type of textures used when performing the post process. (default: 0)
  59935. * @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)
  59936. */
  59937. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59938. /**
  59939. * 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.
  59940. */
  59941. depthTexture: RenderTargetTexture;
  59942. }
  59943. }
  59944. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59945. /** @hidden */
  59946. export var colorCorrectionPixelShader: {
  59947. name: string;
  59948. shader: string;
  59949. };
  59950. }
  59951. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59953. import { Engine } from "babylonjs/Engines/engine";
  59954. import { Camera } from "babylonjs/Cameras/camera";
  59955. import "babylonjs/Shaders/colorCorrection.fragment";
  59956. /**
  59957. *
  59958. * This post-process allows the modification of rendered colors by using
  59959. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59960. *
  59961. * The object needs to be provided an url to a texture containing the color
  59962. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59963. * Use an image editing software to tweak the LUT to match your needs.
  59964. *
  59965. * For an example of a color LUT, see here:
  59966. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59967. * For explanations on color grading, see here:
  59968. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59969. *
  59970. */
  59971. export class ColorCorrectionPostProcess extends PostProcess {
  59972. private _colorTableTexture;
  59973. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59974. }
  59975. }
  59976. declare module "babylonjs/Shaders/convolution.fragment" {
  59977. /** @hidden */
  59978. export var convolutionPixelShader: {
  59979. name: string;
  59980. shader: string;
  59981. };
  59982. }
  59983. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59984. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59985. import { Nullable } from "babylonjs/types";
  59986. import { Camera } from "babylonjs/Cameras/camera";
  59987. import { Engine } from "babylonjs/Engines/engine";
  59988. import "babylonjs/Shaders/convolution.fragment";
  59989. /**
  59990. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59991. * input texture to perform effects such as edge detection or sharpening
  59992. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59993. */
  59994. export class ConvolutionPostProcess extends PostProcess {
  59995. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59996. kernel: number[];
  59997. /**
  59998. * Creates a new instance ConvolutionPostProcess
  59999. * @param name The name of the effect.
  60000. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60001. * @param options The required width/height ratio to downsize to before computing the render pass.
  60002. * @param camera The camera to apply the render pass to.
  60003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60004. * @param engine The engine which the post process will be applied. (default: current engine)
  60005. * @param reusable If the post process can be reused on the same frame. (default: false)
  60006. * @param textureType Type of textures used when performing the post process. (default: 0)
  60007. */
  60008. constructor(name: string,
  60009. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60010. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60011. /**
  60012. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60013. */
  60014. static EdgeDetect0Kernel: number[];
  60015. /**
  60016. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60017. */
  60018. static EdgeDetect1Kernel: number[];
  60019. /**
  60020. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60021. */
  60022. static EdgeDetect2Kernel: number[];
  60023. /**
  60024. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60025. */
  60026. static SharpenKernel: number[];
  60027. /**
  60028. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60029. */
  60030. static EmbossKernel: number[];
  60031. /**
  60032. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60033. */
  60034. static GaussianKernel: number[];
  60035. }
  60036. }
  60037. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60038. import { Nullable } from "babylonjs/types";
  60039. import { Vector2 } from "babylonjs/Maths/math.vector";
  60040. import { Camera } from "babylonjs/Cameras/camera";
  60041. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60042. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60043. import { Engine } from "babylonjs/Engines/engine";
  60044. import { Scene } from "babylonjs/scene";
  60045. /**
  60046. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60047. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60048. * based on samples that have a large difference in distance than the center pixel.
  60049. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60050. */
  60051. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60052. direction: Vector2;
  60053. /**
  60054. * Creates a new instance CircleOfConfusionPostProcess
  60055. * @param name The name of the effect.
  60056. * @param scene The scene the effect belongs to.
  60057. * @param direction The direction the blur should be applied.
  60058. * @param kernel The size of the kernel used to blur.
  60059. * @param options The required width/height ratio to downsize to before computing the render pass.
  60060. * @param camera The camera to apply the render pass to.
  60061. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60062. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60064. * @param engine The engine which the post process will be applied. (default: current engine)
  60065. * @param reusable If the post process can be reused on the same frame. (default: false)
  60066. * @param textureType Type of textures used when performing the post process. (default: 0)
  60067. * @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)
  60068. */
  60069. 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);
  60070. }
  60071. }
  60072. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60073. /** @hidden */
  60074. export var depthOfFieldMergePixelShader: {
  60075. name: string;
  60076. shader: string;
  60077. };
  60078. }
  60079. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60080. import { Nullable } from "babylonjs/types";
  60081. import { Camera } from "babylonjs/Cameras/camera";
  60082. import { Effect } from "babylonjs/Materials/effect";
  60083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60084. import { Engine } from "babylonjs/Engines/engine";
  60085. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60086. /**
  60087. * Options to be set when merging outputs from the default pipeline.
  60088. */
  60089. export class DepthOfFieldMergePostProcessOptions {
  60090. /**
  60091. * The original image to merge on top of
  60092. */
  60093. originalFromInput: PostProcess;
  60094. /**
  60095. * Parameters to perform the merge of the depth of field effect
  60096. */
  60097. depthOfField?: {
  60098. circleOfConfusion: PostProcess;
  60099. blurSteps: Array<PostProcess>;
  60100. };
  60101. /**
  60102. * Parameters to perform the merge of bloom effect
  60103. */
  60104. bloom?: {
  60105. blurred: PostProcess;
  60106. weight: number;
  60107. };
  60108. }
  60109. /**
  60110. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60111. */
  60112. export class DepthOfFieldMergePostProcess extends PostProcess {
  60113. private blurSteps;
  60114. /**
  60115. * Creates a new instance of DepthOfFieldMergePostProcess
  60116. * @param name The name of the effect.
  60117. * @param originalFromInput Post process which's input will be used for the merge.
  60118. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60119. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60120. * @param options The required width/height ratio to downsize to before computing the render pass.
  60121. * @param camera The camera to apply the render pass to.
  60122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60123. * @param engine The engine which the post process will be applied. (default: current engine)
  60124. * @param reusable If the post process can be reused on the same frame. (default: false)
  60125. * @param textureType Type of textures used when performing the post process. (default: 0)
  60126. * @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)
  60127. */
  60128. 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);
  60129. /**
  60130. * Updates the effect with the current post process compile time values and recompiles the shader.
  60131. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60132. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60133. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60134. * @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
  60135. * @param onCompiled Called when the shader has been compiled.
  60136. * @param onError Called if there is an error when compiling a shader.
  60137. */
  60138. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60139. }
  60140. }
  60141. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60142. import { Nullable } from "babylonjs/types";
  60143. import { Camera } from "babylonjs/Cameras/camera";
  60144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60146. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60147. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60148. import { Scene } from "babylonjs/scene";
  60149. /**
  60150. * Specifies the level of max blur that should be applied when using the depth of field effect
  60151. */
  60152. export enum DepthOfFieldEffectBlurLevel {
  60153. /**
  60154. * Subtle blur
  60155. */
  60156. Low = 0,
  60157. /**
  60158. * Medium blur
  60159. */
  60160. Medium = 1,
  60161. /**
  60162. * Large blur
  60163. */
  60164. High = 2
  60165. }
  60166. /**
  60167. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60168. */
  60169. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60170. private _circleOfConfusion;
  60171. /**
  60172. * @hidden Internal, blurs from high to low
  60173. */
  60174. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60175. private _depthOfFieldBlurY;
  60176. private _dofMerge;
  60177. /**
  60178. * @hidden Internal post processes in depth of field effect
  60179. */
  60180. _effects: Array<PostProcess>;
  60181. /**
  60182. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60183. */
  60184. focalLength: number;
  60185. /**
  60186. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60187. */
  60188. fStop: number;
  60189. /**
  60190. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60191. */
  60192. focusDistance: number;
  60193. /**
  60194. * 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.
  60195. */
  60196. lensSize: number;
  60197. /**
  60198. * Creates a new instance DepthOfFieldEffect
  60199. * @param scene The scene the effect belongs to.
  60200. * @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.
  60201. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60202. * @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)
  60203. */
  60204. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60205. /**
  60206. * Get the current class name of the current effet
  60207. * @returns "DepthOfFieldEffect"
  60208. */
  60209. getClassName(): string;
  60210. /**
  60211. * 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.
  60212. */
  60213. depthTexture: RenderTargetTexture;
  60214. /**
  60215. * Disposes each of the internal effects for a given camera.
  60216. * @param camera The camera to dispose the effect on.
  60217. */
  60218. disposeEffects(camera: Camera): void;
  60219. /**
  60220. * @hidden Internal
  60221. */
  60222. _updateEffects(): void;
  60223. /**
  60224. * Internal
  60225. * @returns if all the contained post processes are ready.
  60226. * @hidden
  60227. */
  60228. _isReady(): boolean;
  60229. }
  60230. }
  60231. declare module "babylonjs/Shaders/displayPass.fragment" {
  60232. /** @hidden */
  60233. export var displayPassPixelShader: {
  60234. name: string;
  60235. shader: string;
  60236. };
  60237. }
  60238. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60239. import { Nullable } from "babylonjs/types";
  60240. import { Camera } from "babylonjs/Cameras/camera";
  60241. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60242. import { Engine } from "babylonjs/Engines/engine";
  60243. import "babylonjs/Shaders/displayPass.fragment";
  60244. /**
  60245. * DisplayPassPostProcess which produces an output the same as it's input
  60246. */
  60247. export class DisplayPassPostProcess extends PostProcess {
  60248. /**
  60249. * Creates the DisplayPassPostProcess
  60250. * @param name The name of the effect.
  60251. * @param options The required width/height ratio to downsize to before computing the render pass.
  60252. * @param camera The camera to apply the render pass to.
  60253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60254. * @param engine The engine which the post process will be applied. (default: current engine)
  60255. * @param reusable If the post process can be reused on the same frame. (default: false)
  60256. */
  60257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60258. }
  60259. }
  60260. declare module "babylonjs/Shaders/filter.fragment" {
  60261. /** @hidden */
  60262. export var filterPixelShader: {
  60263. name: string;
  60264. shader: string;
  60265. };
  60266. }
  60267. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60268. import { Nullable } from "babylonjs/types";
  60269. import { Matrix } from "babylonjs/Maths/math.vector";
  60270. import { Camera } from "babylonjs/Cameras/camera";
  60271. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60272. import { Engine } from "babylonjs/Engines/engine";
  60273. import "babylonjs/Shaders/filter.fragment";
  60274. /**
  60275. * Applies a kernel filter to the image
  60276. */
  60277. export class FilterPostProcess extends PostProcess {
  60278. /** The matrix to be applied to the image */
  60279. kernelMatrix: Matrix;
  60280. /**
  60281. *
  60282. * @param name The name of the effect.
  60283. * @param kernelMatrix The matrix to be applied to the image
  60284. * @param options The required width/height ratio to downsize to before computing the render pass.
  60285. * @param camera The camera to apply the render pass to.
  60286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60287. * @param engine The engine which the post process will be applied. (default: current engine)
  60288. * @param reusable If the post process can be reused on the same frame. (default: false)
  60289. */
  60290. constructor(name: string,
  60291. /** The matrix to be applied to the image */
  60292. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60293. }
  60294. }
  60295. declare module "babylonjs/Shaders/fxaa.fragment" {
  60296. /** @hidden */
  60297. export var fxaaPixelShader: {
  60298. name: string;
  60299. shader: string;
  60300. };
  60301. }
  60302. declare module "babylonjs/Shaders/fxaa.vertex" {
  60303. /** @hidden */
  60304. export var fxaaVertexShader: {
  60305. name: string;
  60306. shader: string;
  60307. };
  60308. }
  60309. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60310. import { Nullable } from "babylonjs/types";
  60311. import { Camera } from "babylonjs/Cameras/camera";
  60312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60313. import { Engine } from "babylonjs/Engines/engine";
  60314. import "babylonjs/Shaders/fxaa.fragment";
  60315. import "babylonjs/Shaders/fxaa.vertex";
  60316. /**
  60317. * Fxaa post process
  60318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60319. */
  60320. export class FxaaPostProcess extends PostProcess {
  60321. /** @hidden */
  60322. texelWidth: number;
  60323. /** @hidden */
  60324. texelHeight: number;
  60325. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60326. private _getDefines;
  60327. }
  60328. }
  60329. declare module "babylonjs/Shaders/grain.fragment" {
  60330. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60331. /** @hidden */
  60332. export var grainPixelShader: {
  60333. name: string;
  60334. shader: string;
  60335. };
  60336. }
  60337. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60338. import { Nullable } from "babylonjs/types";
  60339. import { Camera } from "babylonjs/Cameras/camera";
  60340. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60341. import { Engine } from "babylonjs/Engines/engine";
  60342. import "babylonjs/Shaders/grain.fragment";
  60343. /**
  60344. * The GrainPostProcess adds noise to the image at mid luminance levels
  60345. */
  60346. export class GrainPostProcess extends PostProcess {
  60347. /**
  60348. * The intensity of the grain added (default: 30)
  60349. */
  60350. intensity: number;
  60351. /**
  60352. * If the grain should be randomized on every frame
  60353. */
  60354. animated: boolean;
  60355. /**
  60356. * Creates a new instance of @see GrainPostProcess
  60357. * @param name The name of the effect.
  60358. * @param options The required width/height ratio to downsize to before computing the render pass.
  60359. * @param camera The camera to apply the render pass to.
  60360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60361. * @param engine The engine which the post process will be applied. (default: current engine)
  60362. * @param reusable If the post process can be reused on the same frame. (default: false)
  60363. * @param textureType Type of textures used when performing the post process. (default: 0)
  60364. * @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)
  60365. */
  60366. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60367. }
  60368. }
  60369. declare module "babylonjs/Shaders/highlights.fragment" {
  60370. /** @hidden */
  60371. export var highlightsPixelShader: {
  60372. name: string;
  60373. shader: string;
  60374. };
  60375. }
  60376. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60377. import { Nullable } from "babylonjs/types";
  60378. import { Camera } from "babylonjs/Cameras/camera";
  60379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60380. import { Engine } from "babylonjs/Engines/engine";
  60381. import "babylonjs/Shaders/highlights.fragment";
  60382. /**
  60383. * Extracts highlights from the image
  60384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60385. */
  60386. export class HighlightsPostProcess extends PostProcess {
  60387. /**
  60388. * Extracts highlights from the image
  60389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60390. * @param name The name of the effect.
  60391. * @param options The required width/height ratio to downsize to before computing the render pass.
  60392. * @param camera The camera to apply the render pass to.
  60393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60394. * @param engine The engine which the post process will be applied. (default: current engine)
  60395. * @param reusable If the post process can be reused on the same frame. (default: false)
  60396. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60397. */
  60398. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60399. }
  60400. }
  60401. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60402. /** @hidden */
  60403. export var mrtFragmentDeclaration: {
  60404. name: string;
  60405. shader: string;
  60406. };
  60407. }
  60408. declare module "babylonjs/Shaders/geometry.fragment" {
  60409. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60410. /** @hidden */
  60411. export var geometryPixelShader: {
  60412. name: string;
  60413. shader: string;
  60414. };
  60415. }
  60416. declare module "babylonjs/Shaders/geometry.vertex" {
  60417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60420. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60422. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60423. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60424. /** @hidden */
  60425. export var geometryVertexShader: {
  60426. name: string;
  60427. shader: string;
  60428. };
  60429. }
  60430. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60431. import { Matrix } from "babylonjs/Maths/math.vector";
  60432. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60433. import { Mesh } from "babylonjs/Meshes/mesh";
  60434. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60435. import { Effect } from "babylonjs/Materials/effect";
  60436. import { Scene } from "babylonjs/scene";
  60437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60438. import "babylonjs/Shaders/geometry.fragment";
  60439. import "babylonjs/Shaders/geometry.vertex";
  60440. /** @hidden */
  60441. interface ISavedTransformationMatrix {
  60442. world: Matrix;
  60443. viewProjection: Matrix;
  60444. }
  60445. /**
  60446. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60447. */
  60448. export class GeometryBufferRenderer {
  60449. /**
  60450. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60451. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60452. */
  60453. static readonly POSITION_TEXTURE_TYPE: number;
  60454. /**
  60455. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60456. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60457. */
  60458. static readonly VELOCITY_TEXTURE_TYPE: number;
  60459. /**
  60460. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60461. * in order to compute objects velocities when enableVelocity is set to "true"
  60462. * @hidden
  60463. */
  60464. _previousTransformationMatrices: {
  60465. [index: number]: ISavedTransformationMatrix;
  60466. };
  60467. /**
  60468. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60469. * in order to compute objects velocities when enableVelocity is set to "true"
  60470. * @hidden
  60471. */
  60472. _previousBonesTransformationMatrices: {
  60473. [index: number]: Float32Array;
  60474. };
  60475. /**
  60476. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60477. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60478. */
  60479. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60480. private _scene;
  60481. private _multiRenderTarget;
  60482. private _ratio;
  60483. private _enablePosition;
  60484. private _enableVelocity;
  60485. private _positionIndex;
  60486. private _velocityIndex;
  60487. protected _effect: Effect;
  60488. protected _cachedDefines: string;
  60489. /**
  60490. * Set the render list (meshes to be rendered) used in the G buffer.
  60491. */
  60492. renderList: Mesh[];
  60493. /**
  60494. * Gets wether or not G buffer are supported by the running hardware.
  60495. * This requires draw buffer supports
  60496. */
  60497. readonly isSupported: boolean;
  60498. /**
  60499. * Returns the index of the given texture type in the G-Buffer textures array
  60500. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60501. * @returns the index of the given texture type in the G-Buffer textures array
  60502. */
  60503. getTextureIndex(textureType: number): number;
  60504. /**
  60505. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60506. */
  60507. /**
  60508. * Sets whether or not objects positions are enabled for the G buffer.
  60509. */
  60510. enablePosition: boolean;
  60511. /**
  60512. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60513. */
  60514. /**
  60515. * Sets wether or not objects velocities are enabled for the G buffer.
  60516. */
  60517. enableVelocity: boolean;
  60518. /**
  60519. * Gets the scene associated with the buffer.
  60520. */
  60521. readonly scene: Scene;
  60522. /**
  60523. * Gets the ratio used by the buffer during its creation.
  60524. * How big is the buffer related to the main canvas.
  60525. */
  60526. readonly ratio: number;
  60527. /** @hidden */
  60528. static _SceneComponentInitialization: (scene: Scene) => void;
  60529. /**
  60530. * Creates a new G Buffer for the scene
  60531. * @param scene The scene the buffer belongs to
  60532. * @param ratio How big is the buffer related to the main canvas.
  60533. */
  60534. constructor(scene: Scene, ratio?: number);
  60535. /**
  60536. * Checks wether everything is ready to render a submesh to the G buffer.
  60537. * @param subMesh the submesh to check readiness for
  60538. * @param useInstances is the mesh drawn using instance or not
  60539. * @returns true if ready otherwise false
  60540. */
  60541. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60542. /**
  60543. * Gets the current underlying G Buffer.
  60544. * @returns the buffer
  60545. */
  60546. getGBuffer(): MultiRenderTarget;
  60547. /**
  60548. * Gets the number of samples used to render the buffer (anti aliasing).
  60549. */
  60550. /**
  60551. * Sets the number of samples used to render the buffer (anti aliasing).
  60552. */
  60553. samples: number;
  60554. /**
  60555. * Disposes the renderer and frees up associated resources.
  60556. */
  60557. dispose(): void;
  60558. protected _createRenderTargets(): void;
  60559. private _copyBonesTransformationMatrices;
  60560. }
  60561. }
  60562. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60563. import { Nullable } from "babylonjs/types";
  60564. import { Scene } from "babylonjs/scene";
  60565. import { ISceneComponent } from "babylonjs/sceneComponent";
  60566. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60567. module "babylonjs/scene" {
  60568. interface Scene {
  60569. /** @hidden (Backing field) */
  60570. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60571. /**
  60572. * Gets or Sets the current geometry buffer associated to the scene.
  60573. */
  60574. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60575. /**
  60576. * Enables a GeometryBufferRender and associates it with the scene
  60577. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60578. * @returns the GeometryBufferRenderer
  60579. */
  60580. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60581. /**
  60582. * Disables the GeometryBufferRender associated with the scene
  60583. */
  60584. disableGeometryBufferRenderer(): void;
  60585. }
  60586. }
  60587. /**
  60588. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60589. * in several rendering techniques.
  60590. */
  60591. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60592. /**
  60593. * The component name helpful to identify the component in the list of scene components.
  60594. */
  60595. readonly name: string;
  60596. /**
  60597. * The scene the component belongs to.
  60598. */
  60599. scene: Scene;
  60600. /**
  60601. * Creates a new instance of the component for the given scene
  60602. * @param scene Defines the scene to register the component in
  60603. */
  60604. constructor(scene: Scene);
  60605. /**
  60606. * Registers the component in a given scene
  60607. */
  60608. register(): void;
  60609. /**
  60610. * Rebuilds the elements related to this component in case of
  60611. * context lost for instance.
  60612. */
  60613. rebuild(): void;
  60614. /**
  60615. * Disposes the component and the associated ressources
  60616. */
  60617. dispose(): void;
  60618. private _gatherRenderTargets;
  60619. }
  60620. }
  60621. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60622. /** @hidden */
  60623. export var motionBlurPixelShader: {
  60624. name: string;
  60625. shader: string;
  60626. };
  60627. }
  60628. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60629. import { Nullable } from "babylonjs/types";
  60630. import { Camera } from "babylonjs/Cameras/camera";
  60631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60632. import { Scene } from "babylonjs/scene";
  60633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60634. import "babylonjs/Animations/animatable";
  60635. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60636. import "babylonjs/Shaders/motionBlur.fragment";
  60637. import { Engine } from "babylonjs/Engines/engine";
  60638. /**
  60639. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60640. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60641. * As an example, all you have to do is to create the post-process:
  60642. * var mb = new BABYLON.MotionBlurPostProcess(
  60643. * 'mb', // The name of the effect.
  60644. * scene, // The scene containing the objects to blur according to their velocity.
  60645. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60646. * camera // The camera to apply the render pass to.
  60647. * );
  60648. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60649. */
  60650. export class MotionBlurPostProcess extends PostProcess {
  60651. /**
  60652. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60653. */
  60654. motionStrength: number;
  60655. /**
  60656. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60657. */
  60658. /**
  60659. * Sets the number of iterations to be used for motion blur quality
  60660. */
  60661. motionBlurSamples: number;
  60662. private _motionBlurSamples;
  60663. private _geometryBufferRenderer;
  60664. /**
  60665. * Creates a new instance MotionBlurPostProcess
  60666. * @param name The name of the effect.
  60667. * @param scene The scene containing the objects to blur according to their velocity.
  60668. * @param options The required width/height ratio to downsize to before computing the render pass.
  60669. * @param camera The camera to apply the render pass to.
  60670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60671. * @param engine The engine which the post process will be applied. (default: current engine)
  60672. * @param reusable If the post process can be reused on the same frame. (default: false)
  60673. * @param textureType Type of textures used when performing the post process. (default: 0)
  60674. * @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)
  60675. */
  60676. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60677. /**
  60678. * Excludes the given skinned mesh from computing bones velocities.
  60679. * 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.
  60680. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60681. */
  60682. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60683. /**
  60684. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60685. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60686. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60687. */
  60688. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60689. /**
  60690. * Disposes the post process.
  60691. * @param camera The camera to dispose the post process on.
  60692. */
  60693. dispose(camera?: Camera): void;
  60694. }
  60695. }
  60696. declare module "babylonjs/Shaders/refraction.fragment" {
  60697. /** @hidden */
  60698. export var refractionPixelShader: {
  60699. name: string;
  60700. shader: string;
  60701. };
  60702. }
  60703. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60704. import { Color3 } from "babylonjs/Maths/math.color";
  60705. import { Camera } from "babylonjs/Cameras/camera";
  60706. import { Texture } from "babylonjs/Materials/Textures/texture";
  60707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60708. import { Engine } from "babylonjs/Engines/engine";
  60709. import "babylonjs/Shaders/refraction.fragment";
  60710. /**
  60711. * Post process which applies a refractin texture
  60712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60713. */
  60714. export class RefractionPostProcess extends PostProcess {
  60715. /** the base color of the refraction (used to taint the rendering) */
  60716. color: Color3;
  60717. /** simulated refraction depth */
  60718. depth: number;
  60719. /** the coefficient of the base color (0 to remove base color tainting) */
  60720. colorLevel: number;
  60721. private _refTexture;
  60722. private _ownRefractionTexture;
  60723. /**
  60724. * Gets or sets the refraction texture
  60725. * Please note that you are responsible for disposing the texture if you set it manually
  60726. */
  60727. refractionTexture: Texture;
  60728. /**
  60729. * Initializes the RefractionPostProcess
  60730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60731. * @param name The name of the effect.
  60732. * @param refractionTextureUrl Url of the refraction texture to use
  60733. * @param color the base color of the refraction (used to taint the rendering)
  60734. * @param depth simulated refraction depth
  60735. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60736. * @param camera The camera to apply the render pass to.
  60737. * @param options The required width/height ratio to downsize to before computing the render pass.
  60738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60739. * @param engine The engine which the post process will be applied. (default: current engine)
  60740. * @param reusable If the post process can be reused on the same frame. (default: false)
  60741. */
  60742. constructor(name: string, refractionTextureUrl: string,
  60743. /** the base color of the refraction (used to taint the rendering) */
  60744. color: Color3,
  60745. /** simulated refraction depth */
  60746. depth: number,
  60747. /** the coefficient of the base color (0 to remove base color tainting) */
  60748. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60749. /**
  60750. * Disposes of the post process
  60751. * @param camera Camera to dispose post process on
  60752. */
  60753. dispose(camera: Camera): void;
  60754. }
  60755. }
  60756. declare module "babylonjs/Shaders/sharpen.fragment" {
  60757. /** @hidden */
  60758. export var sharpenPixelShader: {
  60759. name: string;
  60760. shader: string;
  60761. };
  60762. }
  60763. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60764. import { Nullable } from "babylonjs/types";
  60765. import { Camera } from "babylonjs/Cameras/camera";
  60766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60767. import "babylonjs/Shaders/sharpen.fragment";
  60768. import { Engine } from "babylonjs/Engines/engine";
  60769. /**
  60770. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60771. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60772. */
  60773. export class SharpenPostProcess extends PostProcess {
  60774. /**
  60775. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60776. */
  60777. colorAmount: number;
  60778. /**
  60779. * How much sharpness should be applied (default: 0.3)
  60780. */
  60781. edgeAmount: number;
  60782. /**
  60783. * Creates a new instance ConvolutionPostProcess
  60784. * @param name The name of the effect.
  60785. * @param options The required width/height ratio to downsize to before computing the render pass.
  60786. * @param camera The camera to apply the render pass to.
  60787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60788. * @param engine The engine which the post process will be applied. (default: current engine)
  60789. * @param reusable If the post process can be reused on the same frame. (default: false)
  60790. * @param textureType Type of textures used when performing the post process. (default: 0)
  60791. * @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)
  60792. */
  60793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60794. }
  60795. }
  60796. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60797. import { Nullable } from "babylonjs/types";
  60798. import { Camera } from "babylonjs/Cameras/camera";
  60799. import { Engine } from "babylonjs/Engines/engine";
  60800. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60801. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60802. /**
  60803. * PostProcessRenderPipeline
  60804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60805. */
  60806. export class PostProcessRenderPipeline {
  60807. private engine;
  60808. private _renderEffects;
  60809. private _renderEffectsForIsolatedPass;
  60810. /**
  60811. * List of inspectable custom properties (used by the Inspector)
  60812. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60813. */
  60814. inspectableCustomProperties: IInspectable[];
  60815. /**
  60816. * @hidden
  60817. */
  60818. protected _cameras: Camera[];
  60819. /** @hidden */
  60820. _name: string;
  60821. /**
  60822. * Gets pipeline name
  60823. */
  60824. readonly name: string;
  60825. /**
  60826. * Initializes a PostProcessRenderPipeline
  60827. * @param engine engine to add the pipeline to
  60828. * @param name name of the pipeline
  60829. */
  60830. constructor(engine: Engine, name: string);
  60831. /**
  60832. * Gets the class name
  60833. * @returns "PostProcessRenderPipeline"
  60834. */
  60835. getClassName(): string;
  60836. /**
  60837. * If all the render effects in the pipeline are supported
  60838. */
  60839. readonly isSupported: boolean;
  60840. /**
  60841. * Adds an effect to the pipeline
  60842. * @param renderEffect the effect to add
  60843. */
  60844. addEffect(renderEffect: PostProcessRenderEffect): void;
  60845. /** @hidden */
  60846. _rebuild(): void;
  60847. /** @hidden */
  60848. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60849. /** @hidden */
  60850. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60851. /** @hidden */
  60852. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60853. /** @hidden */
  60854. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60855. /** @hidden */
  60856. _attachCameras(cameras: Camera, unique: boolean): void;
  60857. /** @hidden */
  60858. _attachCameras(cameras: Camera[], unique: boolean): void;
  60859. /** @hidden */
  60860. _detachCameras(cameras: Camera): void;
  60861. /** @hidden */
  60862. _detachCameras(cameras: Nullable<Camera[]>): void;
  60863. /** @hidden */
  60864. _update(): void;
  60865. /** @hidden */
  60866. _reset(): void;
  60867. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60868. /**
  60869. * Disposes of the pipeline
  60870. */
  60871. dispose(): void;
  60872. }
  60873. }
  60874. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60875. import { Camera } from "babylonjs/Cameras/camera";
  60876. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60877. /**
  60878. * PostProcessRenderPipelineManager class
  60879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60880. */
  60881. export class PostProcessRenderPipelineManager {
  60882. private _renderPipelines;
  60883. /**
  60884. * Initializes a PostProcessRenderPipelineManager
  60885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60886. */
  60887. constructor();
  60888. /**
  60889. * Gets the list of supported render pipelines
  60890. */
  60891. readonly supportedPipelines: PostProcessRenderPipeline[];
  60892. /**
  60893. * Adds a pipeline to the manager
  60894. * @param renderPipeline The pipeline to add
  60895. */
  60896. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60897. /**
  60898. * Attaches a camera to the pipeline
  60899. * @param renderPipelineName The name of the pipeline to attach to
  60900. * @param cameras the camera to attach
  60901. * @param unique if the camera can be attached multiple times to the pipeline
  60902. */
  60903. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60904. /**
  60905. * Detaches a camera from the pipeline
  60906. * @param renderPipelineName The name of the pipeline to detach from
  60907. * @param cameras the camera to detach
  60908. */
  60909. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60910. /**
  60911. * Enables an effect by name on a pipeline
  60912. * @param renderPipelineName the name of the pipeline to enable the effect in
  60913. * @param renderEffectName the name of the effect to enable
  60914. * @param cameras the cameras that the effect should be enabled on
  60915. */
  60916. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60917. /**
  60918. * Disables an effect by name on a pipeline
  60919. * @param renderPipelineName the name of the pipeline to disable the effect in
  60920. * @param renderEffectName the name of the effect to disable
  60921. * @param cameras the cameras that the effect should be disabled on
  60922. */
  60923. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60924. /**
  60925. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60926. */
  60927. update(): void;
  60928. /** @hidden */
  60929. _rebuild(): void;
  60930. /**
  60931. * Disposes of the manager and pipelines
  60932. */
  60933. dispose(): void;
  60934. }
  60935. }
  60936. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60937. import { ISceneComponent } from "babylonjs/sceneComponent";
  60938. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60939. import { Scene } from "babylonjs/scene";
  60940. module "babylonjs/scene" {
  60941. interface Scene {
  60942. /** @hidden (Backing field) */
  60943. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60944. /**
  60945. * Gets the postprocess render pipeline manager
  60946. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60947. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60948. */
  60949. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60950. }
  60951. }
  60952. /**
  60953. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60954. */
  60955. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60956. /**
  60957. * The component name helpfull to identify the component in the list of scene components.
  60958. */
  60959. readonly name: string;
  60960. /**
  60961. * The scene the component belongs to.
  60962. */
  60963. scene: Scene;
  60964. /**
  60965. * Creates a new instance of the component for the given scene
  60966. * @param scene Defines the scene to register the component in
  60967. */
  60968. constructor(scene: Scene);
  60969. /**
  60970. * Registers the component in a given scene
  60971. */
  60972. register(): void;
  60973. /**
  60974. * Rebuilds the elements related to this component in case of
  60975. * context lost for instance.
  60976. */
  60977. rebuild(): void;
  60978. /**
  60979. * Disposes the component and the associated ressources
  60980. */
  60981. dispose(): void;
  60982. private _gatherRenderTargets;
  60983. }
  60984. }
  60985. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60986. import { Nullable } from "babylonjs/types";
  60987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60988. import { Camera } from "babylonjs/Cameras/camera";
  60989. import { IDisposable } from "babylonjs/scene";
  60990. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60991. import { Scene } from "babylonjs/scene";
  60992. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60993. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60994. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60995. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60996. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60997. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60998. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60999. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61000. import { Animation } from "babylonjs/Animations/animation";
  61001. /**
  61002. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61003. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61004. */
  61005. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61006. private _scene;
  61007. private _camerasToBeAttached;
  61008. /**
  61009. * ID of the sharpen post process,
  61010. */
  61011. private readonly SharpenPostProcessId;
  61012. /**
  61013. * @ignore
  61014. * ID of the image processing post process;
  61015. */
  61016. readonly ImageProcessingPostProcessId: string;
  61017. /**
  61018. * @ignore
  61019. * ID of the Fast Approximate Anti-Aliasing post process;
  61020. */
  61021. readonly FxaaPostProcessId: string;
  61022. /**
  61023. * ID of the chromatic aberration post process,
  61024. */
  61025. private readonly ChromaticAberrationPostProcessId;
  61026. /**
  61027. * ID of the grain post process
  61028. */
  61029. private readonly GrainPostProcessId;
  61030. /**
  61031. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61032. */
  61033. sharpen: SharpenPostProcess;
  61034. private _sharpenEffect;
  61035. private bloom;
  61036. /**
  61037. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61038. */
  61039. depthOfField: DepthOfFieldEffect;
  61040. /**
  61041. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61042. */
  61043. fxaa: FxaaPostProcess;
  61044. /**
  61045. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61046. */
  61047. imageProcessing: ImageProcessingPostProcess;
  61048. /**
  61049. * Chromatic aberration post process which will shift rgb colors in the image
  61050. */
  61051. chromaticAberration: ChromaticAberrationPostProcess;
  61052. private _chromaticAberrationEffect;
  61053. /**
  61054. * Grain post process which add noise to the image
  61055. */
  61056. grain: GrainPostProcess;
  61057. private _grainEffect;
  61058. /**
  61059. * Glow post process which adds a glow to emissive areas of the image
  61060. */
  61061. private _glowLayer;
  61062. /**
  61063. * Animations which can be used to tweak settings over a period of time
  61064. */
  61065. animations: Animation[];
  61066. private _imageProcessingConfigurationObserver;
  61067. private _sharpenEnabled;
  61068. private _bloomEnabled;
  61069. private _depthOfFieldEnabled;
  61070. private _depthOfFieldBlurLevel;
  61071. private _fxaaEnabled;
  61072. private _imageProcessingEnabled;
  61073. private _defaultPipelineTextureType;
  61074. private _bloomScale;
  61075. private _chromaticAberrationEnabled;
  61076. private _grainEnabled;
  61077. private _buildAllowed;
  61078. /**
  61079. * Gets active scene
  61080. */
  61081. readonly scene: Scene;
  61082. /**
  61083. * Enable or disable the sharpen process from the pipeline
  61084. */
  61085. sharpenEnabled: boolean;
  61086. private _resizeObserver;
  61087. private _hardwareScaleLevel;
  61088. private _bloomKernel;
  61089. /**
  61090. * Specifies the size of the bloom blur kernel, relative to the final output size
  61091. */
  61092. bloomKernel: number;
  61093. /**
  61094. * Specifies the weight of the bloom in the final rendering
  61095. */
  61096. private _bloomWeight;
  61097. /**
  61098. * Specifies the luma threshold for the area that will be blurred by the bloom
  61099. */
  61100. private _bloomThreshold;
  61101. private _hdr;
  61102. /**
  61103. * The strength of the bloom.
  61104. */
  61105. bloomWeight: number;
  61106. /**
  61107. * The strength of the bloom.
  61108. */
  61109. bloomThreshold: number;
  61110. /**
  61111. * The scale of the bloom, lower value will provide better performance.
  61112. */
  61113. bloomScale: number;
  61114. /**
  61115. * Enable or disable the bloom from the pipeline
  61116. */
  61117. bloomEnabled: boolean;
  61118. private _rebuildBloom;
  61119. /**
  61120. * If the depth of field is enabled.
  61121. */
  61122. depthOfFieldEnabled: boolean;
  61123. /**
  61124. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61125. */
  61126. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61127. /**
  61128. * If the anti aliasing is enabled.
  61129. */
  61130. fxaaEnabled: boolean;
  61131. private _samples;
  61132. /**
  61133. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61134. */
  61135. samples: number;
  61136. /**
  61137. * If image processing is enabled.
  61138. */
  61139. imageProcessingEnabled: boolean;
  61140. /**
  61141. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61142. */
  61143. glowLayerEnabled: boolean;
  61144. /**
  61145. * Gets the glow layer (or null if not defined)
  61146. */
  61147. readonly glowLayer: Nullable<GlowLayer>;
  61148. /**
  61149. * Enable or disable the chromaticAberration process from the pipeline
  61150. */
  61151. chromaticAberrationEnabled: boolean;
  61152. /**
  61153. * Enable or disable the grain process from the pipeline
  61154. */
  61155. grainEnabled: boolean;
  61156. /**
  61157. * @constructor
  61158. * @param name - The rendering pipeline name (default: "")
  61159. * @param hdr - If high dynamic range textures should be used (default: true)
  61160. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61161. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61162. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61163. */
  61164. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61165. /**
  61166. * Get the class name
  61167. * @returns "DefaultRenderingPipeline"
  61168. */
  61169. getClassName(): string;
  61170. /**
  61171. * Force the compilation of the entire pipeline.
  61172. */
  61173. prepare(): void;
  61174. private _hasCleared;
  61175. private _prevPostProcess;
  61176. private _prevPrevPostProcess;
  61177. private _setAutoClearAndTextureSharing;
  61178. private _depthOfFieldSceneObserver;
  61179. private _buildPipeline;
  61180. private _disposePostProcesses;
  61181. /**
  61182. * Adds a camera to the pipeline
  61183. * @param camera the camera to be added
  61184. */
  61185. addCamera(camera: Camera): void;
  61186. /**
  61187. * Removes a camera from the pipeline
  61188. * @param camera the camera to remove
  61189. */
  61190. removeCamera(camera: Camera): void;
  61191. /**
  61192. * Dispose of the pipeline and stop all post processes
  61193. */
  61194. dispose(): void;
  61195. /**
  61196. * Serialize the rendering pipeline (Used when exporting)
  61197. * @returns the serialized object
  61198. */
  61199. serialize(): any;
  61200. /**
  61201. * Parse the serialized pipeline
  61202. * @param source Source pipeline.
  61203. * @param scene The scene to load the pipeline to.
  61204. * @param rootUrl The URL of the serialized pipeline.
  61205. * @returns An instantiated pipeline from the serialized object.
  61206. */
  61207. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61208. }
  61209. }
  61210. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61211. /** @hidden */
  61212. export var lensHighlightsPixelShader: {
  61213. name: string;
  61214. shader: string;
  61215. };
  61216. }
  61217. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61218. /** @hidden */
  61219. export var depthOfFieldPixelShader: {
  61220. name: string;
  61221. shader: string;
  61222. };
  61223. }
  61224. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61225. import { Camera } from "babylonjs/Cameras/camera";
  61226. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61227. import { Scene } from "babylonjs/scene";
  61228. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61229. import "babylonjs/Shaders/chromaticAberration.fragment";
  61230. import "babylonjs/Shaders/lensHighlights.fragment";
  61231. import "babylonjs/Shaders/depthOfField.fragment";
  61232. /**
  61233. * BABYLON.JS Chromatic Aberration GLSL Shader
  61234. * Author: Olivier Guyot
  61235. * Separates very slightly R, G and B colors on the edges of the screen
  61236. * Inspired by Francois Tarlier & Martins Upitis
  61237. */
  61238. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61239. /**
  61240. * @ignore
  61241. * The chromatic aberration PostProcess id in the pipeline
  61242. */
  61243. LensChromaticAberrationEffect: string;
  61244. /**
  61245. * @ignore
  61246. * The highlights enhancing PostProcess id in the pipeline
  61247. */
  61248. HighlightsEnhancingEffect: string;
  61249. /**
  61250. * @ignore
  61251. * The depth-of-field PostProcess id in the pipeline
  61252. */
  61253. LensDepthOfFieldEffect: string;
  61254. private _scene;
  61255. private _depthTexture;
  61256. private _grainTexture;
  61257. private _chromaticAberrationPostProcess;
  61258. private _highlightsPostProcess;
  61259. private _depthOfFieldPostProcess;
  61260. private _edgeBlur;
  61261. private _grainAmount;
  61262. private _chromaticAberration;
  61263. private _distortion;
  61264. private _highlightsGain;
  61265. private _highlightsThreshold;
  61266. private _dofDistance;
  61267. private _dofAperture;
  61268. private _dofDarken;
  61269. private _dofPentagon;
  61270. private _blurNoise;
  61271. /**
  61272. * @constructor
  61273. *
  61274. * Effect parameters are as follow:
  61275. * {
  61276. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61277. * edge_blur: number; // from 0 to x (1 for realism)
  61278. * distortion: number; // from 0 to x (1 for realism)
  61279. * grain_amount: number; // from 0 to 1
  61280. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61281. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61282. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61283. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61284. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61285. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61286. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61287. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61288. * }
  61289. * Note: if an effect parameter is unset, effect is disabled
  61290. *
  61291. * @param name The rendering pipeline name
  61292. * @param parameters - An object containing all parameters (see above)
  61293. * @param scene The scene linked to this pipeline
  61294. * @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)
  61295. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61296. */
  61297. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61298. /**
  61299. * Get the class name
  61300. * @returns "LensRenderingPipeline"
  61301. */
  61302. getClassName(): string;
  61303. /**
  61304. * Gets associated scene
  61305. */
  61306. readonly scene: Scene;
  61307. /**
  61308. * Gets or sets the edge blur
  61309. */
  61310. edgeBlur: number;
  61311. /**
  61312. * Gets or sets the grain amount
  61313. */
  61314. grainAmount: number;
  61315. /**
  61316. * Gets or sets the chromatic aberration amount
  61317. */
  61318. chromaticAberration: number;
  61319. /**
  61320. * Gets or sets the depth of field aperture
  61321. */
  61322. dofAperture: number;
  61323. /**
  61324. * Gets or sets the edge distortion
  61325. */
  61326. edgeDistortion: number;
  61327. /**
  61328. * Gets or sets the depth of field distortion
  61329. */
  61330. dofDistortion: number;
  61331. /**
  61332. * Gets or sets the darken out of focus amount
  61333. */
  61334. darkenOutOfFocus: number;
  61335. /**
  61336. * Gets or sets a boolean indicating if blur noise is enabled
  61337. */
  61338. blurNoise: boolean;
  61339. /**
  61340. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61341. */
  61342. pentagonBokeh: boolean;
  61343. /**
  61344. * Gets or sets the highlight grain amount
  61345. */
  61346. highlightsGain: number;
  61347. /**
  61348. * Gets or sets the highlight threshold
  61349. */
  61350. highlightsThreshold: number;
  61351. /**
  61352. * Sets the amount of blur at the edges
  61353. * @param amount blur amount
  61354. */
  61355. setEdgeBlur(amount: number): void;
  61356. /**
  61357. * Sets edge blur to 0
  61358. */
  61359. disableEdgeBlur(): void;
  61360. /**
  61361. * Sets the amout of grain
  61362. * @param amount Amount of grain
  61363. */
  61364. setGrainAmount(amount: number): void;
  61365. /**
  61366. * Set grain amount to 0
  61367. */
  61368. disableGrain(): void;
  61369. /**
  61370. * Sets the chromatic aberration amount
  61371. * @param amount amount of chromatic aberration
  61372. */
  61373. setChromaticAberration(amount: number): void;
  61374. /**
  61375. * Sets chromatic aberration amount to 0
  61376. */
  61377. disableChromaticAberration(): void;
  61378. /**
  61379. * Sets the EdgeDistortion amount
  61380. * @param amount amount of EdgeDistortion
  61381. */
  61382. setEdgeDistortion(amount: number): void;
  61383. /**
  61384. * Sets edge distortion to 0
  61385. */
  61386. disableEdgeDistortion(): void;
  61387. /**
  61388. * Sets the FocusDistance amount
  61389. * @param amount amount of FocusDistance
  61390. */
  61391. setFocusDistance(amount: number): void;
  61392. /**
  61393. * Disables depth of field
  61394. */
  61395. disableDepthOfField(): void;
  61396. /**
  61397. * Sets the Aperture amount
  61398. * @param amount amount of Aperture
  61399. */
  61400. setAperture(amount: number): void;
  61401. /**
  61402. * Sets the DarkenOutOfFocus amount
  61403. * @param amount amount of DarkenOutOfFocus
  61404. */
  61405. setDarkenOutOfFocus(amount: number): void;
  61406. private _pentagonBokehIsEnabled;
  61407. /**
  61408. * Creates a pentagon bokeh effect
  61409. */
  61410. enablePentagonBokeh(): void;
  61411. /**
  61412. * Disables the pentagon bokeh effect
  61413. */
  61414. disablePentagonBokeh(): void;
  61415. /**
  61416. * Enables noise blur
  61417. */
  61418. enableNoiseBlur(): void;
  61419. /**
  61420. * Disables noise blur
  61421. */
  61422. disableNoiseBlur(): void;
  61423. /**
  61424. * Sets the HighlightsGain amount
  61425. * @param amount amount of HighlightsGain
  61426. */
  61427. setHighlightsGain(amount: number): void;
  61428. /**
  61429. * Sets the HighlightsThreshold amount
  61430. * @param amount amount of HighlightsThreshold
  61431. */
  61432. setHighlightsThreshold(amount: number): void;
  61433. /**
  61434. * Disables highlights
  61435. */
  61436. disableHighlights(): void;
  61437. /**
  61438. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61439. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61440. */
  61441. dispose(disableDepthRender?: boolean): void;
  61442. private _createChromaticAberrationPostProcess;
  61443. private _createHighlightsPostProcess;
  61444. private _createDepthOfFieldPostProcess;
  61445. private _createGrainTexture;
  61446. }
  61447. }
  61448. declare module "babylonjs/Shaders/ssao2.fragment" {
  61449. /** @hidden */
  61450. export var ssao2PixelShader: {
  61451. name: string;
  61452. shader: string;
  61453. };
  61454. }
  61455. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61456. /** @hidden */
  61457. export var ssaoCombinePixelShader: {
  61458. name: string;
  61459. shader: string;
  61460. };
  61461. }
  61462. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61463. import { Camera } from "babylonjs/Cameras/camera";
  61464. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61465. import { Scene } from "babylonjs/scene";
  61466. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61467. import "babylonjs/Shaders/ssao2.fragment";
  61468. import "babylonjs/Shaders/ssaoCombine.fragment";
  61469. /**
  61470. * Render pipeline to produce ssao effect
  61471. */
  61472. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61473. /**
  61474. * @ignore
  61475. * The PassPostProcess id in the pipeline that contains the original scene color
  61476. */
  61477. SSAOOriginalSceneColorEffect: string;
  61478. /**
  61479. * @ignore
  61480. * The SSAO PostProcess id in the pipeline
  61481. */
  61482. SSAORenderEffect: string;
  61483. /**
  61484. * @ignore
  61485. * The horizontal blur PostProcess id in the pipeline
  61486. */
  61487. SSAOBlurHRenderEffect: string;
  61488. /**
  61489. * @ignore
  61490. * The vertical blur PostProcess id in the pipeline
  61491. */
  61492. SSAOBlurVRenderEffect: string;
  61493. /**
  61494. * @ignore
  61495. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61496. */
  61497. SSAOCombineRenderEffect: string;
  61498. /**
  61499. * The output strength of the SSAO post-process. Default value is 1.0.
  61500. */
  61501. totalStrength: number;
  61502. /**
  61503. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61504. */
  61505. maxZ: number;
  61506. /**
  61507. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61508. */
  61509. minZAspect: number;
  61510. private _samples;
  61511. /**
  61512. * Number of samples used for the SSAO calculations. Default value is 8
  61513. */
  61514. samples: number;
  61515. private _textureSamples;
  61516. /**
  61517. * Number of samples to use for antialiasing
  61518. */
  61519. textureSamples: number;
  61520. /**
  61521. * Ratio object used for SSAO ratio and blur ratio
  61522. */
  61523. private _ratio;
  61524. /**
  61525. * Dynamically generated sphere sampler.
  61526. */
  61527. private _sampleSphere;
  61528. /**
  61529. * Blur filter offsets
  61530. */
  61531. private _samplerOffsets;
  61532. private _expensiveBlur;
  61533. /**
  61534. * If bilateral blur should be used
  61535. */
  61536. expensiveBlur: boolean;
  61537. /**
  61538. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61539. */
  61540. radius: number;
  61541. /**
  61542. * The base color of the SSAO post-process
  61543. * The final result is "base + ssao" between [0, 1]
  61544. */
  61545. base: number;
  61546. /**
  61547. * Support test.
  61548. */
  61549. static readonly IsSupported: boolean;
  61550. private _scene;
  61551. private _depthTexture;
  61552. private _normalTexture;
  61553. private _randomTexture;
  61554. private _originalColorPostProcess;
  61555. private _ssaoPostProcess;
  61556. private _blurHPostProcess;
  61557. private _blurVPostProcess;
  61558. private _ssaoCombinePostProcess;
  61559. private _firstUpdate;
  61560. /**
  61561. * Gets active scene
  61562. */
  61563. readonly scene: Scene;
  61564. /**
  61565. * @constructor
  61566. * @param name The rendering pipeline name
  61567. * @param scene The scene linked to this pipeline
  61568. * @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 }
  61569. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61570. */
  61571. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61572. /**
  61573. * Get the class name
  61574. * @returns "SSAO2RenderingPipeline"
  61575. */
  61576. getClassName(): string;
  61577. /**
  61578. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61579. */
  61580. dispose(disableGeometryBufferRenderer?: boolean): void;
  61581. private _createBlurPostProcess;
  61582. /** @hidden */
  61583. _rebuild(): void;
  61584. private _bits;
  61585. private _radicalInverse_VdC;
  61586. private _hammersley;
  61587. private _hemisphereSample_uniform;
  61588. private _generateHemisphere;
  61589. private _createSSAOPostProcess;
  61590. private _createSSAOCombinePostProcess;
  61591. private _createRandomTexture;
  61592. /**
  61593. * Serialize the rendering pipeline (Used when exporting)
  61594. * @returns the serialized object
  61595. */
  61596. serialize(): any;
  61597. /**
  61598. * Parse the serialized pipeline
  61599. * @param source Source pipeline.
  61600. * @param scene The scene to load the pipeline to.
  61601. * @param rootUrl The URL of the serialized pipeline.
  61602. * @returns An instantiated pipeline from the serialized object.
  61603. */
  61604. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61605. }
  61606. }
  61607. declare module "babylonjs/Shaders/ssao.fragment" {
  61608. /** @hidden */
  61609. export var ssaoPixelShader: {
  61610. name: string;
  61611. shader: string;
  61612. };
  61613. }
  61614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61615. import { Camera } from "babylonjs/Cameras/camera";
  61616. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61617. import { Scene } from "babylonjs/scene";
  61618. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61619. import "babylonjs/Shaders/ssao.fragment";
  61620. import "babylonjs/Shaders/ssaoCombine.fragment";
  61621. /**
  61622. * Render pipeline to produce ssao effect
  61623. */
  61624. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61625. /**
  61626. * @ignore
  61627. * The PassPostProcess id in the pipeline that contains the original scene color
  61628. */
  61629. SSAOOriginalSceneColorEffect: string;
  61630. /**
  61631. * @ignore
  61632. * The SSAO PostProcess id in the pipeline
  61633. */
  61634. SSAORenderEffect: string;
  61635. /**
  61636. * @ignore
  61637. * The horizontal blur PostProcess id in the pipeline
  61638. */
  61639. SSAOBlurHRenderEffect: string;
  61640. /**
  61641. * @ignore
  61642. * The vertical blur PostProcess id in the pipeline
  61643. */
  61644. SSAOBlurVRenderEffect: string;
  61645. /**
  61646. * @ignore
  61647. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61648. */
  61649. SSAOCombineRenderEffect: string;
  61650. /**
  61651. * The output strength of the SSAO post-process. Default value is 1.0.
  61652. */
  61653. totalStrength: number;
  61654. /**
  61655. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61656. */
  61657. radius: number;
  61658. /**
  61659. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61660. * Must not be equal to fallOff and superior to fallOff.
  61661. * Default value is 0.0075
  61662. */
  61663. area: number;
  61664. /**
  61665. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61666. * Must not be equal to area and inferior to area.
  61667. * Default value is 0.000001
  61668. */
  61669. fallOff: number;
  61670. /**
  61671. * The base color of the SSAO post-process
  61672. * The final result is "base + ssao" between [0, 1]
  61673. */
  61674. base: number;
  61675. private _scene;
  61676. private _depthTexture;
  61677. private _randomTexture;
  61678. private _originalColorPostProcess;
  61679. private _ssaoPostProcess;
  61680. private _blurHPostProcess;
  61681. private _blurVPostProcess;
  61682. private _ssaoCombinePostProcess;
  61683. private _firstUpdate;
  61684. /**
  61685. * Gets active scene
  61686. */
  61687. readonly scene: Scene;
  61688. /**
  61689. * @constructor
  61690. * @param name - The rendering pipeline name
  61691. * @param scene - The scene linked to this pipeline
  61692. * @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 }
  61693. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61694. */
  61695. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61696. /**
  61697. * Get the class name
  61698. * @returns "SSAORenderingPipeline"
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61703. */
  61704. dispose(disableDepthRender?: boolean): void;
  61705. private _createBlurPostProcess;
  61706. /** @hidden */
  61707. _rebuild(): void;
  61708. private _createSSAOPostProcess;
  61709. private _createSSAOCombinePostProcess;
  61710. private _createRandomTexture;
  61711. }
  61712. }
  61713. declare module "babylonjs/Shaders/standard.fragment" {
  61714. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61715. /** @hidden */
  61716. export var standardPixelShader: {
  61717. name: string;
  61718. shader: string;
  61719. };
  61720. }
  61721. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61722. import { Nullable } from "babylonjs/types";
  61723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61724. import { Camera } from "babylonjs/Cameras/camera";
  61725. import { Texture } from "babylonjs/Materials/Textures/texture";
  61726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61727. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61728. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61729. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61730. import { IDisposable } from "babylonjs/scene";
  61731. import { SpotLight } from "babylonjs/Lights/spotLight";
  61732. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61733. import { Scene } from "babylonjs/scene";
  61734. import { Animation } from "babylonjs/Animations/animation";
  61735. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61736. import "babylonjs/Shaders/standard.fragment";
  61737. /**
  61738. * Standard rendering pipeline
  61739. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61740. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61741. */
  61742. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61743. /**
  61744. * Public members
  61745. */
  61746. /**
  61747. * Post-process which contains the original scene color before the pipeline applies all the effects
  61748. */
  61749. originalPostProcess: Nullable<PostProcess>;
  61750. /**
  61751. * Post-process used to down scale an image x4
  61752. */
  61753. downSampleX4PostProcess: Nullable<PostProcess>;
  61754. /**
  61755. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61756. */
  61757. brightPassPostProcess: Nullable<PostProcess>;
  61758. /**
  61759. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61760. */
  61761. blurHPostProcesses: PostProcess[];
  61762. /**
  61763. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61764. */
  61765. blurVPostProcesses: PostProcess[];
  61766. /**
  61767. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61768. */
  61769. textureAdderPostProcess: Nullable<PostProcess>;
  61770. /**
  61771. * Post-process used to create volumetric lighting effect
  61772. */
  61773. volumetricLightPostProcess: Nullable<PostProcess>;
  61774. /**
  61775. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61776. */
  61777. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61778. /**
  61779. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61780. */
  61781. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61782. /**
  61783. * Post-process used to merge the volumetric light effect and the real scene color
  61784. */
  61785. volumetricLightMergePostProces: Nullable<PostProcess>;
  61786. /**
  61787. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61788. */
  61789. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61790. /**
  61791. * Base post-process used to calculate the average luminance of the final image for HDR
  61792. */
  61793. luminancePostProcess: Nullable<PostProcess>;
  61794. /**
  61795. * Post-processes used to create down sample post-processes in order to get
  61796. * the average luminance of the final image for HDR
  61797. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61798. */
  61799. luminanceDownSamplePostProcesses: PostProcess[];
  61800. /**
  61801. * Post-process used to create a HDR effect (light adaptation)
  61802. */
  61803. hdrPostProcess: Nullable<PostProcess>;
  61804. /**
  61805. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61806. */
  61807. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61808. /**
  61809. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61810. */
  61811. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61812. /**
  61813. * Post-process used to merge the final HDR post-process and the real scene color
  61814. */
  61815. hdrFinalPostProcess: Nullable<PostProcess>;
  61816. /**
  61817. * Post-process used to create a lens flare effect
  61818. */
  61819. lensFlarePostProcess: Nullable<PostProcess>;
  61820. /**
  61821. * Post-process that merges the result of the lens flare post-process and the real scene color
  61822. */
  61823. lensFlareComposePostProcess: Nullable<PostProcess>;
  61824. /**
  61825. * Post-process used to create a motion blur effect
  61826. */
  61827. motionBlurPostProcess: Nullable<PostProcess>;
  61828. /**
  61829. * Post-process used to create a depth of field effect
  61830. */
  61831. depthOfFieldPostProcess: Nullable<PostProcess>;
  61832. /**
  61833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61834. */
  61835. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61836. /**
  61837. * Represents the brightness threshold in order to configure the illuminated surfaces
  61838. */
  61839. brightThreshold: number;
  61840. /**
  61841. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61842. */
  61843. blurWidth: number;
  61844. /**
  61845. * Sets if the blur for highlighted surfaces must be only horizontal
  61846. */
  61847. horizontalBlur: boolean;
  61848. /**
  61849. * Gets the overall exposure used by the pipeline
  61850. */
  61851. /**
  61852. * Sets the overall exposure used by the pipeline
  61853. */
  61854. exposure: number;
  61855. /**
  61856. * Texture used typically to simulate "dirty" on camera lens
  61857. */
  61858. lensTexture: Nullable<Texture>;
  61859. /**
  61860. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61861. */
  61862. volumetricLightCoefficient: number;
  61863. /**
  61864. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61865. */
  61866. volumetricLightPower: number;
  61867. /**
  61868. * Used the set the blur intensity to smooth the volumetric lights
  61869. */
  61870. volumetricLightBlurScale: number;
  61871. /**
  61872. * Light (spot or directional) used to generate the volumetric lights rays
  61873. * The source light must have a shadow generate so the pipeline can get its
  61874. * depth map
  61875. */
  61876. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61877. /**
  61878. * For eye adaptation, represents the minimum luminance the eye can see
  61879. */
  61880. hdrMinimumLuminance: number;
  61881. /**
  61882. * For eye adaptation, represents the decrease luminance speed
  61883. */
  61884. hdrDecreaseRate: number;
  61885. /**
  61886. * For eye adaptation, represents the increase luminance speed
  61887. */
  61888. hdrIncreaseRate: number;
  61889. /**
  61890. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61891. */
  61892. /**
  61893. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61894. */
  61895. hdrAutoExposure: boolean;
  61896. /**
  61897. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61898. */
  61899. lensColorTexture: Nullable<Texture>;
  61900. /**
  61901. * The overall strengh for the lens flare effect
  61902. */
  61903. lensFlareStrength: number;
  61904. /**
  61905. * Dispersion coefficient for lens flare ghosts
  61906. */
  61907. lensFlareGhostDispersal: number;
  61908. /**
  61909. * Main lens flare halo width
  61910. */
  61911. lensFlareHaloWidth: number;
  61912. /**
  61913. * Based on the lens distortion effect, defines how much the lens flare result
  61914. * is distorted
  61915. */
  61916. lensFlareDistortionStrength: number;
  61917. /**
  61918. * Lens star texture must be used to simulate rays on the flares and is available
  61919. * in the documentation
  61920. */
  61921. lensStarTexture: Nullable<Texture>;
  61922. /**
  61923. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61924. * flare effect by taking account of the dirt texture
  61925. */
  61926. lensFlareDirtTexture: Nullable<Texture>;
  61927. /**
  61928. * Represents the focal length for the depth of field effect
  61929. */
  61930. depthOfFieldDistance: number;
  61931. /**
  61932. * Represents the blur intensity for the blurred part of the depth of field effect
  61933. */
  61934. depthOfFieldBlurWidth: number;
  61935. /**
  61936. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61937. */
  61938. /**
  61939. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61940. */
  61941. motionStrength: number;
  61942. /**
  61943. * Gets wether or not the motion blur post-process is object based or screen based.
  61944. */
  61945. /**
  61946. * Sets wether or not the motion blur post-process should be object based or screen based
  61947. */
  61948. objectBasedMotionBlur: boolean;
  61949. /**
  61950. * List of animations for the pipeline (IAnimatable implementation)
  61951. */
  61952. animations: Animation[];
  61953. /**
  61954. * Private members
  61955. */
  61956. private _scene;
  61957. private _currentDepthOfFieldSource;
  61958. private _basePostProcess;
  61959. private _fixedExposure;
  61960. private _currentExposure;
  61961. private _hdrAutoExposure;
  61962. private _hdrCurrentLuminance;
  61963. private _motionStrength;
  61964. private _isObjectBasedMotionBlur;
  61965. private _floatTextureType;
  61966. private _ratio;
  61967. private _bloomEnabled;
  61968. private _depthOfFieldEnabled;
  61969. private _vlsEnabled;
  61970. private _lensFlareEnabled;
  61971. private _hdrEnabled;
  61972. private _motionBlurEnabled;
  61973. private _fxaaEnabled;
  61974. private _motionBlurSamples;
  61975. private _volumetricLightStepsCount;
  61976. private _samples;
  61977. /**
  61978. * @ignore
  61979. * Specifies if the bloom pipeline is enabled
  61980. */
  61981. BloomEnabled: boolean;
  61982. /**
  61983. * @ignore
  61984. * Specifies if the depth of field pipeline is enabed
  61985. */
  61986. DepthOfFieldEnabled: boolean;
  61987. /**
  61988. * @ignore
  61989. * Specifies if the lens flare pipeline is enabed
  61990. */
  61991. LensFlareEnabled: boolean;
  61992. /**
  61993. * @ignore
  61994. * Specifies if the HDR pipeline is enabled
  61995. */
  61996. HDREnabled: boolean;
  61997. /**
  61998. * @ignore
  61999. * Specifies if the volumetric lights scattering effect is enabled
  62000. */
  62001. VLSEnabled: boolean;
  62002. /**
  62003. * @ignore
  62004. * Specifies if the motion blur effect is enabled
  62005. */
  62006. MotionBlurEnabled: boolean;
  62007. /**
  62008. * Specifies if anti-aliasing is enabled
  62009. */
  62010. fxaaEnabled: boolean;
  62011. /**
  62012. * Specifies the number of steps used to calculate the volumetric lights
  62013. * Typically in interval [50, 200]
  62014. */
  62015. volumetricLightStepsCount: number;
  62016. /**
  62017. * Specifies the number of samples used for the motion blur effect
  62018. * Typically in interval [16, 64]
  62019. */
  62020. motionBlurSamples: number;
  62021. /**
  62022. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62023. */
  62024. samples: number;
  62025. /**
  62026. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62027. * @constructor
  62028. * @param name The rendering pipeline name
  62029. * @param scene The scene linked to this pipeline
  62030. * @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)
  62031. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62032. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62033. */
  62034. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62035. private _buildPipeline;
  62036. private _createDownSampleX4PostProcess;
  62037. private _createBrightPassPostProcess;
  62038. private _createBlurPostProcesses;
  62039. private _createTextureAdderPostProcess;
  62040. private _createVolumetricLightPostProcess;
  62041. private _createLuminancePostProcesses;
  62042. private _createHdrPostProcess;
  62043. private _createLensFlarePostProcess;
  62044. private _createDepthOfFieldPostProcess;
  62045. private _createMotionBlurPostProcess;
  62046. private _getDepthTexture;
  62047. private _disposePostProcesses;
  62048. /**
  62049. * Dispose of the pipeline and stop all post processes
  62050. */
  62051. dispose(): void;
  62052. /**
  62053. * Serialize the rendering pipeline (Used when exporting)
  62054. * @returns the serialized object
  62055. */
  62056. serialize(): any;
  62057. /**
  62058. * Parse the serialized pipeline
  62059. * @param source Source pipeline.
  62060. * @param scene The scene to load the pipeline to.
  62061. * @param rootUrl The URL of the serialized pipeline.
  62062. * @returns An instantiated pipeline from the serialized object.
  62063. */
  62064. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62065. /**
  62066. * Luminance steps
  62067. */
  62068. static LuminanceSteps: number;
  62069. }
  62070. }
  62071. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62072. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62073. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62074. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62075. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62076. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62077. }
  62078. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62079. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62080. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62081. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62082. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62083. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62084. }
  62085. declare module "babylonjs/Shaders/tonemap.fragment" {
  62086. /** @hidden */
  62087. export var tonemapPixelShader: {
  62088. name: string;
  62089. shader: string;
  62090. };
  62091. }
  62092. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62093. import { Camera } from "babylonjs/Cameras/camera";
  62094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62095. import "babylonjs/Shaders/tonemap.fragment";
  62096. import { Engine } from "babylonjs/Engines/engine";
  62097. /** Defines operator used for tonemapping */
  62098. export enum TonemappingOperator {
  62099. /** Hable */
  62100. Hable = 0,
  62101. /** Reinhard */
  62102. Reinhard = 1,
  62103. /** HejiDawson */
  62104. HejiDawson = 2,
  62105. /** Photographic */
  62106. Photographic = 3
  62107. }
  62108. /**
  62109. * Defines a post process to apply tone mapping
  62110. */
  62111. export class TonemapPostProcess extends PostProcess {
  62112. private _operator;
  62113. /** Defines the required exposure adjustement */
  62114. exposureAdjustment: number;
  62115. /**
  62116. * Creates a new TonemapPostProcess
  62117. * @param name defines the name of the postprocess
  62118. * @param _operator defines the operator to use
  62119. * @param exposureAdjustment defines the required exposure adjustement
  62120. * @param camera defines the camera to use (can be null)
  62121. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62122. * @param engine defines the hosting engine (can be ignore if camera is set)
  62123. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62124. */
  62125. constructor(name: string, _operator: TonemappingOperator,
  62126. /** Defines the required exposure adjustement */
  62127. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62128. }
  62129. }
  62130. declare module "babylonjs/Shaders/depth.vertex" {
  62131. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62133. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62134. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62135. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62136. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62137. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62138. /** @hidden */
  62139. export var depthVertexShader: {
  62140. name: string;
  62141. shader: string;
  62142. };
  62143. }
  62144. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62145. /** @hidden */
  62146. export var volumetricLightScatteringPixelShader: {
  62147. name: string;
  62148. shader: string;
  62149. };
  62150. }
  62151. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62152. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62154. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62155. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62157. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62158. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62159. /** @hidden */
  62160. export var volumetricLightScatteringPassVertexShader: {
  62161. name: string;
  62162. shader: string;
  62163. };
  62164. }
  62165. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62166. /** @hidden */
  62167. export var volumetricLightScatteringPassPixelShader: {
  62168. name: string;
  62169. shader: string;
  62170. };
  62171. }
  62172. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62173. import { Vector3 } from "babylonjs/Maths/math.vector";
  62174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62175. import { Mesh } from "babylonjs/Meshes/mesh";
  62176. import { Camera } from "babylonjs/Cameras/camera";
  62177. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62178. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62179. import { Scene } from "babylonjs/scene";
  62180. import "babylonjs/Meshes/Builders/planeBuilder";
  62181. import "babylonjs/Shaders/depth.vertex";
  62182. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62183. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62184. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62185. import { Engine } from "babylonjs/Engines/engine";
  62186. /**
  62187. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62188. */
  62189. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62190. private _volumetricLightScatteringPass;
  62191. private _volumetricLightScatteringRTT;
  62192. private _viewPort;
  62193. private _screenCoordinates;
  62194. private _cachedDefines;
  62195. /**
  62196. * If not undefined, the mesh position is computed from the attached node position
  62197. */
  62198. attachedNode: {
  62199. position: Vector3;
  62200. };
  62201. /**
  62202. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62203. */
  62204. customMeshPosition: Vector3;
  62205. /**
  62206. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62207. */
  62208. useCustomMeshPosition: boolean;
  62209. /**
  62210. * If the post-process should inverse the light scattering direction
  62211. */
  62212. invert: boolean;
  62213. /**
  62214. * The internal mesh used by the post-process
  62215. */
  62216. mesh: Mesh;
  62217. /**
  62218. * @hidden
  62219. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62220. */
  62221. useDiffuseColor: boolean;
  62222. /**
  62223. * Array containing the excluded meshes not rendered in the internal pass
  62224. */
  62225. excludedMeshes: AbstractMesh[];
  62226. /**
  62227. * Controls the overall intensity of the post-process
  62228. */
  62229. exposure: number;
  62230. /**
  62231. * Dissipates each sample's contribution in range [0, 1]
  62232. */
  62233. decay: number;
  62234. /**
  62235. * Controls the overall intensity of each sample
  62236. */
  62237. weight: number;
  62238. /**
  62239. * Controls the density of each sample
  62240. */
  62241. density: number;
  62242. /**
  62243. * @constructor
  62244. * @param name The post-process name
  62245. * @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)
  62246. * @param camera The camera that the post-process will be attached to
  62247. * @param mesh The mesh used to create the light scattering
  62248. * @param samples The post-process quality, default 100
  62249. * @param samplingModeThe post-process filtering mode
  62250. * @param engine The babylon engine
  62251. * @param reusable If the post-process is reusable
  62252. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62253. */
  62254. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62255. /**
  62256. * Returns the string "VolumetricLightScatteringPostProcess"
  62257. * @returns "VolumetricLightScatteringPostProcess"
  62258. */
  62259. getClassName(): string;
  62260. private _isReady;
  62261. /**
  62262. * Sets the new light position for light scattering effect
  62263. * @param position The new custom light position
  62264. */
  62265. setCustomMeshPosition(position: Vector3): void;
  62266. /**
  62267. * Returns the light position for light scattering effect
  62268. * @return Vector3 The custom light position
  62269. */
  62270. getCustomMeshPosition(): Vector3;
  62271. /**
  62272. * Disposes the internal assets and detaches the post-process from the camera
  62273. */
  62274. dispose(camera: Camera): void;
  62275. /**
  62276. * Returns the render target texture used by the post-process
  62277. * @return the render target texture used by the post-process
  62278. */
  62279. getPass(): RenderTargetTexture;
  62280. private _meshExcluded;
  62281. private _createPass;
  62282. private _updateMeshScreenCoordinates;
  62283. /**
  62284. * Creates a default mesh for the Volumeric Light Scattering post-process
  62285. * @param name The mesh name
  62286. * @param scene The scene where to create the mesh
  62287. * @return the default mesh
  62288. */
  62289. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62290. }
  62291. }
  62292. declare module "babylonjs/PostProcesses/index" {
  62293. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62294. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62295. export * from "babylonjs/PostProcesses/bloomEffect";
  62296. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62297. export * from "babylonjs/PostProcesses/blurPostProcess";
  62298. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62299. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62300. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62301. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62302. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62303. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62304. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62305. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62306. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62307. export * from "babylonjs/PostProcesses/filterPostProcess";
  62308. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62309. export * from "babylonjs/PostProcesses/grainPostProcess";
  62310. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62311. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62312. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62313. export * from "babylonjs/PostProcesses/passPostProcess";
  62314. export * from "babylonjs/PostProcesses/postProcess";
  62315. export * from "babylonjs/PostProcesses/postProcessManager";
  62316. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62317. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62318. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62319. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62320. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62321. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62322. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62323. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62324. }
  62325. declare module "babylonjs/Probes/index" {
  62326. export * from "babylonjs/Probes/reflectionProbe";
  62327. }
  62328. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62329. import { Scene } from "babylonjs/scene";
  62330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62331. import { SmartArray } from "babylonjs/Misc/smartArray";
  62332. import { ISceneComponent } from "babylonjs/sceneComponent";
  62333. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62334. import "babylonjs/Meshes/Builders/boxBuilder";
  62335. import "babylonjs/Shaders/color.fragment";
  62336. import "babylonjs/Shaders/color.vertex";
  62337. import { Color3 } from "babylonjs/Maths/math.color";
  62338. module "babylonjs/scene" {
  62339. interface Scene {
  62340. /** @hidden (Backing field) */
  62341. _boundingBoxRenderer: BoundingBoxRenderer;
  62342. /** @hidden (Backing field) */
  62343. _forceShowBoundingBoxes: boolean;
  62344. /**
  62345. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62346. */
  62347. forceShowBoundingBoxes: boolean;
  62348. /**
  62349. * Gets the bounding box renderer associated with the scene
  62350. * @returns a BoundingBoxRenderer
  62351. */
  62352. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62353. }
  62354. }
  62355. module "babylonjs/Meshes/abstractMesh" {
  62356. interface AbstractMesh {
  62357. /** @hidden (Backing field) */
  62358. _showBoundingBox: boolean;
  62359. /**
  62360. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62361. */
  62362. showBoundingBox: boolean;
  62363. }
  62364. }
  62365. /**
  62366. * Component responsible of rendering the bounding box of the meshes in a scene.
  62367. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62368. */
  62369. export class BoundingBoxRenderer implements ISceneComponent {
  62370. /**
  62371. * The component name helpfull to identify the component in the list of scene components.
  62372. */
  62373. readonly name: string;
  62374. /**
  62375. * The scene the component belongs to.
  62376. */
  62377. scene: Scene;
  62378. /**
  62379. * Color of the bounding box lines placed in front of an object
  62380. */
  62381. frontColor: Color3;
  62382. /**
  62383. * Color of the bounding box lines placed behind an object
  62384. */
  62385. backColor: Color3;
  62386. /**
  62387. * Defines if the renderer should show the back lines or not
  62388. */
  62389. showBackLines: boolean;
  62390. /**
  62391. * @hidden
  62392. */
  62393. renderList: SmartArray<BoundingBox>;
  62394. private _colorShader;
  62395. private _vertexBuffers;
  62396. private _indexBuffer;
  62397. private _fillIndexBuffer;
  62398. private _fillIndexData;
  62399. /**
  62400. * Instantiates a new bounding box renderer in a scene.
  62401. * @param scene the scene the renderer renders in
  62402. */
  62403. constructor(scene: Scene);
  62404. /**
  62405. * Registers the component in a given scene
  62406. */
  62407. register(): void;
  62408. private _evaluateSubMesh;
  62409. private _activeMesh;
  62410. private _prepareRessources;
  62411. private _createIndexBuffer;
  62412. /**
  62413. * Rebuilds the elements related to this component in case of
  62414. * context lost for instance.
  62415. */
  62416. rebuild(): void;
  62417. /**
  62418. * @hidden
  62419. */
  62420. reset(): void;
  62421. /**
  62422. * Render the bounding boxes of a specific rendering group
  62423. * @param renderingGroupId defines the rendering group to render
  62424. */
  62425. render(renderingGroupId: number): void;
  62426. /**
  62427. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62428. * @param mesh Define the mesh to render the occlusion bounding box for
  62429. */
  62430. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62431. /**
  62432. * Dispose and release the resources attached to this renderer.
  62433. */
  62434. dispose(): void;
  62435. }
  62436. }
  62437. declare module "babylonjs/Shaders/depth.fragment" {
  62438. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62439. /** @hidden */
  62440. export var depthPixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module "babylonjs/Rendering/depthRenderer" {
  62446. import { Nullable } from "babylonjs/types";
  62447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62448. import { Scene } from "babylonjs/scene";
  62449. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62450. import { Camera } from "babylonjs/Cameras/camera";
  62451. import "babylonjs/Shaders/depth.fragment";
  62452. import "babylonjs/Shaders/depth.vertex";
  62453. /**
  62454. * This represents a depth renderer in Babylon.
  62455. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62456. */
  62457. export class DepthRenderer {
  62458. private _scene;
  62459. private _depthMap;
  62460. private _effect;
  62461. private readonly _storeNonLinearDepth;
  62462. private readonly _clearColor;
  62463. /** Get if the depth renderer is using packed depth or not */
  62464. readonly isPacked: boolean;
  62465. private _cachedDefines;
  62466. private _camera;
  62467. /**
  62468. * Specifiess that the depth renderer will only be used within
  62469. * the camera it is created for.
  62470. * This can help forcing its rendering during the camera processing.
  62471. */
  62472. useOnlyInActiveCamera: boolean;
  62473. /** @hidden */
  62474. static _SceneComponentInitialization: (scene: Scene) => void;
  62475. /**
  62476. * Instantiates a depth renderer
  62477. * @param scene The scene the renderer belongs to
  62478. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62479. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62480. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62481. */
  62482. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62483. /**
  62484. * Creates the depth rendering effect and checks if the effect is ready.
  62485. * @param subMesh The submesh to be used to render the depth map of
  62486. * @param useInstances If multiple world instances should be used
  62487. * @returns if the depth renderer is ready to render the depth map
  62488. */
  62489. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62490. /**
  62491. * Gets the texture which the depth map will be written to.
  62492. * @returns The depth map texture
  62493. */
  62494. getDepthMap(): RenderTargetTexture;
  62495. /**
  62496. * Disposes of the depth renderer.
  62497. */
  62498. dispose(): void;
  62499. }
  62500. }
  62501. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62502. import { Nullable } from "babylonjs/types";
  62503. import { Scene } from "babylonjs/scene";
  62504. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62505. import { Camera } from "babylonjs/Cameras/camera";
  62506. import { ISceneComponent } from "babylonjs/sceneComponent";
  62507. module "babylonjs/scene" {
  62508. interface Scene {
  62509. /** @hidden (Backing field) */
  62510. _depthRenderer: {
  62511. [id: string]: DepthRenderer;
  62512. };
  62513. /**
  62514. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62515. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62516. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62517. * @returns the created depth renderer
  62518. */
  62519. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62520. /**
  62521. * Disables a depth renderer for a given camera
  62522. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62523. */
  62524. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62525. }
  62526. }
  62527. /**
  62528. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62529. * in several rendering techniques.
  62530. */
  62531. export class DepthRendererSceneComponent implements ISceneComponent {
  62532. /**
  62533. * The component name helpfull to identify the component in the list of scene components.
  62534. */
  62535. readonly name: string;
  62536. /**
  62537. * The scene the component belongs to.
  62538. */
  62539. scene: Scene;
  62540. /**
  62541. * Creates a new instance of the component for the given scene
  62542. * @param scene Defines the scene to register the component in
  62543. */
  62544. constructor(scene: Scene);
  62545. /**
  62546. * Registers the component in a given scene
  62547. */
  62548. register(): void;
  62549. /**
  62550. * Rebuilds the elements related to this component in case of
  62551. * context lost for instance.
  62552. */
  62553. rebuild(): void;
  62554. /**
  62555. * Disposes the component and the associated ressources
  62556. */
  62557. dispose(): void;
  62558. private _gatherRenderTargets;
  62559. private _gatherActiveCameraRenderTargets;
  62560. }
  62561. }
  62562. declare module "babylonjs/Shaders/outline.fragment" {
  62563. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62564. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62565. /** @hidden */
  62566. export var outlinePixelShader: {
  62567. name: string;
  62568. shader: string;
  62569. };
  62570. }
  62571. declare module "babylonjs/Shaders/outline.vertex" {
  62572. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62575. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62576. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62578. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62579. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62580. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62581. /** @hidden */
  62582. export var outlineVertexShader: {
  62583. name: string;
  62584. shader: string;
  62585. };
  62586. }
  62587. declare module "babylonjs/Rendering/outlineRenderer" {
  62588. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62589. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62590. import { Scene } from "babylonjs/scene";
  62591. import { ISceneComponent } from "babylonjs/sceneComponent";
  62592. import "babylonjs/Shaders/outline.fragment";
  62593. import "babylonjs/Shaders/outline.vertex";
  62594. module "babylonjs/scene" {
  62595. interface Scene {
  62596. /** @hidden */
  62597. _outlineRenderer: OutlineRenderer;
  62598. /**
  62599. * Gets the outline renderer associated with the scene
  62600. * @returns a OutlineRenderer
  62601. */
  62602. getOutlineRenderer(): OutlineRenderer;
  62603. }
  62604. }
  62605. module "babylonjs/Meshes/abstractMesh" {
  62606. interface AbstractMesh {
  62607. /** @hidden (Backing field) */
  62608. _renderOutline: boolean;
  62609. /**
  62610. * Gets or sets a boolean indicating if the outline must be rendered as well
  62611. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62612. */
  62613. renderOutline: boolean;
  62614. /** @hidden (Backing field) */
  62615. _renderOverlay: boolean;
  62616. /**
  62617. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62618. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62619. */
  62620. renderOverlay: boolean;
  62621. }
  62622. }
  62623. /**
  62624. * This class is responsible to draw bothe outline/overlay of meshes.
  62625. * It should not be used directly but through the available method on mesh.
  62626. */
  62627. export class OutlineRenderer implements ISceneComponent {
  62628. /**
  62629. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62630. */
  62631. private static _StencilReference;
  62632. /**
  62633. * The name of the component. Each component must have a unique name.
  62634. */
  62635. name: string;
  62636. /**
  62637. * The scene the component belongs to.
  62638. */
  62639. scene: Scene;
  62640. /**
  62641. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62642. */
  62643. zOffset: number;
  62644. private _engine;
  62645. private _effect;
  62646. private _cachedDefines;
  62647. private _savedDepthWrite;
  62648. /**
  62649. * Instantiates a new outline renderer. (There could be only one per scene).
  62650. * @param scene Defines the scene it belongs to
  62651. */
  62652. constructor(scene: Scene);
  62653. /**
  62654. * Register the component to one instance of a scene.
  62655. */
  62656. register(): void;
  62657. /**
  62658. * Rebuilds the elements related to this component in case of
  62659. * context lost for instance.
  62660. */
  62661. rebuild(): void;
  62662. /**
  62663. * Disposes the component and the associated ressources.
  62664. */
  62665. dispose(): void;
  62666. /**
  62667. * Renders the outline in the canvas.
  62668. * @param subMesh Defines the sumesh to render
  62669. * @param batch Defines the batch of meshes in case of instances
  62670. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62671. */
  62672. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62673. /**
  62674. * Returns whether or not the outline renderer is ready for a given submesh.
  62675. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62676. * @param subMesh Defines the submesh to check readyness for
  62677. * @param useInstances Defines wheter wee are trying to render instances or not
  62678. * @returns true if ready otherwise false
  62679. */
  62680. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62681. private _beforeRenderingMesh;
  62682. private _afterRenderingMesh;
  62683. }
  62684. }
  62685. declare module "babylonjs/Rendering/index" {
  62686. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62687. export * from "babylonjs/Rendering/depthRenderer";
  62688. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62689. export * from "babylonjs/Rendering/edgesRenderer";
  62690. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62691. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62692. export * from "babylonjs/Rendering/outlineRenderer";
  62693. export * from "babylonjs/Rendering/renderingGroup";
  62694. export * from "babylonjs/Rendering/renderingManager";
  62695. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62696. }
  62697. declare module "babylonjs/Sprites/spritePackedManager" {
  62698. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  62699. import { Scene } from "babylonjs/scene";
  62700. /**
  62701. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62702. * @see http://doc.babylonjs.com/babylon101/sprites
  62703. */
  62704. export class SpritePackedManager extends SpriteManager {
  62705. /** defines the packed manager's name */
  62706. name: string;
  62707. /**
  62708. * Creates a new sprite manager from a packed sprite sheet
  62709. * @param name defines the manager's name
  62710. * @param imgUrl defines the sprite sheet url
  62711. * @param capacity defines the maximum allowed number of sprites
  62712. * @param scene defines the hosting scene
  62713. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62714. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62715. * @param samplingMode defines the smapling mode to use with spritesheet
  62716. * @param fromPacked set to true; do not alter
  62717. */
  62718. constructor(
  62719. /** defines the packed manager's name */
  62720. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62721. }
  62722. }
  62723. declare module "babylonjs/Sprites/index" {
  62724. export * from "babylonjs/Sprites/sprite";
  62725. export * from "babylonjs/Sprites/spriteManager";
  62726. export * from "babylonjs/Sprites/spritePackedManager";
  62727. export * from "babylonjs/Sprites/spriteSceneComponent";
  62728. }
  62729. declare module "babylonjs/Misc/assetsManager" {
  62730. import { Scene } from "babylonjs/scene";
  62731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62732. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62733. import { Skeleton } from "babylonjs/Bones/skeleton";
  62734. import { Observable } from "babylonjs/Misc/observable";
  62735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62736. import { Texture } from "babylonjs/Materials/Textures/texture";
  62737. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62738. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62739. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62740. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62741. /**
  62742. * Defines the list of states available for a task inside a AssetsManager
  62743. */
  62744. export enum AssetTaskState {
  62745. /**
  62746. * Initialization
  62747. */
  62748. INIT = 0,
  62749. /**
  62750. * Running
  62751. */
  62752. RUNNING = 1,
  62753. /**
  62754. * Done
  62755. */
  62756. DONE = 2,
  62757. /**
  62758. * Error
  62759. */
  62760. ERROR = 3
  62761. }
  62762. /**
  62763. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62764. */
  62765. export abstract class AbstractAssetTask {
  62766. /**
  62767. * Task name
  62768. */ name: string;
  62769. /**
  62770. * Callback called when the task is successful
  62771. */
  62772. onSuccess: (task: any) => void;
  62773. /**
  62774. * Callback called when the task is not successful
  62775. */
  62776. onError: (task: any, message?: string, exception?: any) => void;
  62777. /**
  62778. * Creates a new AssetsManager
  62779. * @param name defines the name of the task
  62780. */
  62781. constructor(
  62782. /**
  62783. * Task name
  62784. */ name: string);
  62785. private _isCompleted;
  62786. private _taskState;
  62787. private _errorObject;
  62788. /**
  62789. * Get if the task is completed
  62790. */
  62791. readonly isCompleted: boolean;
  62792. /**
  62793. * Gets the current state of the task
  62794. */
  62795. readonly taskState: AssetTaskState;
  62796. /**
  62797. * Gets the current error object (if task is in error)
  62798. */
  62799. readonly errorObject: {
  62800. message?: string;
  62801. exception?: any;
  62802. };
  62803. /**
  62804. * Internal only
  62805. * @hidden
  62806. */
  62807. _setErrorObject(message?: string, exception?: any): void;
  62808. /**
  62809. * Execute the current task
  62810. * @param scene defines the scene where you want your assets to be loaded
  62811. * @param onSuccess is a callback called when the task is successfully executed
  62812. * @param onError is a callback called if an error occurs
  62813. */
  62814. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62815. /**
  62816. * Execute the current task
  62817. * @param scene defines the scene where you want your assets to be loaded
  62818. * @param onSuccess is a callback called when the task is successfully executed
  62819. * @param onError is a callback called if an error occurs
  62820. */
  62821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62822. /**
  62823. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62824. * This can be used with failed tasks that have the reason for failure fixed.
  62825. */
  62826. reset(): void;
  62827. private onErrorCallback;
  62828. private onDoneCallback;
  62829. }
  62830. /**
  62831. * Define the interface used by progress events raised during assets loading
  62832. */
  62833. export interface IAssetsProgressEvent {
  62834. /**
  62835. * Defines the number of remaining tasks to process
  62836. */
  62837. remainingCount: number;
  62838. /**
  62839. * Defines the total number of tasks
  62840. */
  62841. totalCount: number;
  62842. /**
  62843. * Defines the task that was just processed
  62844. */
  62845. task: AbstractAssetTask;
  62846. }
  62847. /**
  62848. * Class used to share progress information about assets loading
  62849. */
  62850. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62851. /**
  62852. * Defines the number of remaining tasks to process
  62853. */
  62854. remainingCount: number;
  62855. /**
  62856. * Defines the total number of tasks
  62857. */
  62858. totalCount: number;
  62859. /**
  62860. * Defines the task that was just processed
  62861. */
  62862. task: AbstractAssetTask;
  62863. /**
  62864. * Creates a AssetsProgressEvent
  62865. * @param remainingCount defines the number of remaining tasks to process
  62866. * @param totalCount defines the total number of tasks
  62867. * @param task defines the task that was just processed
  62868. */
  62869. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62870. }
  62871. /**
  62872. * Define a task used by AssetsManager to load meshes
  62873. */
  62874. export class MeshAssetTask extends AbstractAssetTask {
  62875. /**
  62876. * Defines the name of the task
  62877. */
  62878. name: string;
  62879. /**
  62880. * Defines the list of mesh's names you want to load
  62881. */
  62882. meshesNames: any;
  62883. /**
  62884. * Defines the root url to use as a base to load your meshes and associated resources
  62885. */
  62886. rootUrl: string;
  62887. /**
  62888. * Defines the filename of the scene to load from
  62889. */
  62890. sceneFilename: string;
  62891. /**
  62892. * Gets the list of loaded meshes
  62893. */
  62894. loadedMeshes: Array<AbstractMesh>;
  62895. /**
  62896. * Gets the list of loaded particle systems
  62897. */
  62898. loadedParticleSystems: Array<IParticleSystem>;
  62899. /**
  62900. * Gets the list of loaded skeletons
  62901. */
  62902. loadedSkeletons: Array<Skeleton>;
  62903. /**
  62904. * Gets the list of loaded animation groups
  62905. */
  62906. loadedAnimationGroups: Array<AnimationGroup>;
  62907. /**
  62908. * Callback called when the task is successful
  62909. */
  62910. onSuccess: (task: MeshAssetTask) => void;
  62911. /**
  62912. * Callback called when the task is successful
  62913. */
  62914. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62915. /**
  62916. * Creates a new MeshAssetTask
  62917. * @param name defines the name of the task
  62918. * @param meshesNames defines the list of mesh's names you want to load
  62919. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62920. * @param sceneFilename defines the filename of the scene to load from
  62921. */
  62922. constructor(
  62923. /**
  62924. * Defines the name of the task
  62925. */
  62926. name: string,
  62927. /**
  62928. * Defines the list of mesh's names you want to load
  62929. */
  62930. meshesNames: any,
  62931. /**
  62932. * Defines the root url to use as a base to load your meshes and associated resources
  62933. */
  62934. rootUrl: string,
  62935. /**
  62936. * Defines the filename of the scene to load from
  62937. */
  62938. sceneFilename: string);
  62939. /**
  62940. * Execute the current task
  62941. * @param scene defines the scene where you want your assets to be loaded
  62942. * @param onSuccess is a callback called when the task is successfully executed
  62943. * @param onError is a callback called if an error occurs
  62944. */
  62945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62946. }
  62947. /**
  62948. * Define a task used by AssetsManager to load text content
  62949. */
  62950. export class TextFileAssetTask extends AbstractAssetTask {
  62951. /**
  62952. * Defines the name of the task
  62953. */
  62954. name: string;
  62955. /**
  62956. * Defines the location of the file to load
  62957. */
  62958. url: string;
  62959. /**
  62960. * Gets the loaded text string
  62961. */
  62962. text: string;
  62963. /**
  62964. * Callback called when the task is successful
  62965. */
  62966. onSuccess: (task: TextFileAssetTask) => void;
  62967. /**
  62968. * Callback called when the task is successful
  62969. */
  62970. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62971. /**
  62972. * Creates a new TextFileAssetTask object
  62973. * @param name defines the name of the task
  62974. * @param url defines the location of the file to load
  62975. */
  62976. constructor(
  62977. /**
  62978. * Defines the name of the task
  62979. */
  62980. name: string,
  62981. /**
  62982. * Defines the location of the file to load
  62983. */
  62984. url: string);
  62985. /**
  62986. * Execute the current task
  62987. * @param scene defines the scene where you want your assets to be loaded
  62988. * @param onSuccess is a callback called when the task is successfully executed
  62989. * @param onError is a callback called if an error occurs
  62990. */
  62991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62992. }
  62993. /**
  62994. * Define a task used by AssetsManager to load binary data
  62995. */
  62996. export class BinaryFileAssetTask extends AbstractAssetTask {
  62997. /**
  62998. * Defines the name of the task
  62999. */
  63000. name: string;
  63001. /**
  63002. * Defines the location of the file to load
  63003. */
  63004. url: string;
  63005. /**
  63006. * Gets the lodaded data (as an array buffer)
  63007. */
  63008. data: ArrayBuffer;
  63009. /**
  63010. * Callback called when the task is successful
  63011. */
  63012. onSuccess: (task: BinaryFileAssetTask) => void;
  63013. /**
  63014. * Callback called when the task is successful
  63015. */
  63016. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63017. /**
  63018. * Creates a new BinaryFileAssetTask object
  63019. * @param name defines the name of the new task
  63020. * @param url defines the location of the file to load
  63021. */
  63022. constructor(
  63023. /**
  63024. * Defines the name of the task
  63025. */
  63026. name: string,
  63027. /**
  63028. * Defines the location of the file to load
  63029. */
  63030. url: string);
  63031. /**
  63032. * Execute the current task
  63033. * @param scene defines the scene where you want your assets to be loaded
  63034. * @param onSuccess is a callback called when the task is successfully executed
  63035. * @param onError is a callback called if an error occurs
  63036. */
  63037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63038. }
  63039. /**
  63040. * Define a task used by AssetsManager to load images
  63041. */
  63042. export class ImageAssetTask extends AbstractAssetTask {
  63043. /**
  63044. * Defines the name of the task
  63045. */
  63046. name: string;
  63047. /**
  63048. * Defines the location of the image to load
  63049. */
  63050. url: string;
  63051. /**
  63052. * Gets the loaded images
  63053. */
  63054. image: HTMLImageElement;
  63055. /**
  63056. * Callback called when the task is successful
  63057. */
  63058. onSuccess: (task: ImageAssetTask) => void;
  63059. /**
  63060. * Callback called when the task is successful
  63061. */
  63062. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63063. /**
  63064. * Creates a new ImageAssetTask
  63065. * @param name defines the name of the task
  63066. * @param url defines the location of the image to load
  63067. */
  63068. constructor(
  63069. /**
  63070. * Defines the name of the task
  63071. */
  63072. name: string,
  63073. /**
  63074. * Defines the location of the image to load
  63075. */
  63076. url: string);
  63077. /**
  63078. * Execute the current task
  63079. * @param scene defines the scene where you want your assets to be loaded
  63080. * @param onSuccess is a callback called when the task is successfully executed
  63081. * @param onError is a callback called if an error occurs
  63082. */
  63083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63084. }
  63085. /**
  63086. * Defines the interface used by texture loading tasks
  63087. */
  63088. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63089. /**
  63090. * Gets the loaded texture
  63091. */
  63092. texture: TEX;
  63093. }
  63094. /**
  63095. * Define a task used by AssetsManager to load 2D textures
  63096. */
  63097. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63098. /**
  63099. * Defines the name of the task
  63100. */
  63101. name: string;
  63102. /**
  63103. * Defines the location of the file to load
  63104. */
  63105. url: string;
  63106. /**
  63107. * Defines if mipmap should not be generated (default is false)
  63108. */
  63109. noMipmap?: boolean | undefined;
  63110. /**
  63111. * Defines if texture must be inverted on Y axis (default is false)
  63112. */
  63113. invertY?: boolean | undefined;
  63114. /**
  63115. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63116. */
  63117. samplingMode: number;
  63118. /**
  63119. * Gets the loaded texture
  63120. */
  63121. texture: Texture;
  63122. /**
  63123. * Callback called when the task is successful
  63124. */
  63125. onSuccess: (task: TextureAssetTask) => void;
  63126. /**
  63127. * Callback called when the task is successful
  63128. */
  63129. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63130. /**
  63131. * Creates a new TextureAssetTask object
  63132. * @param name defines the name of the task
  63133. * @param url defines the location of the file to load
  63134. * @param noMipmap defines if mipmap should not be generated (default is false)
  63135. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63136. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63137. */
  63138. constructor(
  63139. /**
  63140. * Defines the name of the task
  63141. */
  63142. name: string,
  63143. /**
  63144. * Defines the location of the file to load
  63145. */
  63146. url: string,
  63147. /**
  63148. * Defines if mipmap should not be generated (default is false)
  63149. */
  63150. noMipmap?: boolean | undefined,
  63151. /**
  63152. * Defines if texture must be inverted on Y axis (default is false)
  63153. */
  63154. invertY?: boolean | undefined,
  63155. /**
  63156. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63157. */
  63158. samplingMode?: number);
  63159. /**
  63160. * Execute the current task
  63161. * @param scene defines the scene where you want your assets to be loaded
  63162. * @param onSuccess is a callback called when the task is successfully executed
  63163. * @param onError is a callback called if an error occurs
  63164. */
  63165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63166. }
  63167. /**
  63168. * Define a task used by AssetsManager to load cube textures
  63169. */
  63170. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63171. /**
  63172. * Defines the name of the task
  63173. */
  63174. name: string;
  63175. /**
  63176. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63177. */
  63178. url: string;
  63179. /**
  63180. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63181. */
  63182. extensions?: string[] | undefined;
  63183. /**
  63184. * Defines if mipmaps should not be generated (default is false)
  63185. */
  63186. noMipmap?: boolean | undefined;
  63187. /**
  63188. * Defines the explicit list of files (undefined by default)
  63189. */
  63190. files?: string[] | undefined;
  63191. /**
  63192. * Gets the loaded texture
  63193. */
  63194. texture: CubeTexture;
  63195. /**
  63196. * Callback called when the task is successful
  63197. */
  63198. onSuccess: (task: CubeTextureAssetTask) => void;
  63199. /**
  63200. * Callback called when the task is successful
  63201. */
  63202. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63203. /**
  63204. * Creates a new CubeTextureAssetTask
  63205. * @param name defines the name of the task
  63206. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63207. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63208. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63209. * @param files defines the explicit list of files (undefined by default)
  63210. */
  63211. constructor(
  63212. /**
  63213. * Defines the name of the task
  63214. */
  63215. name: string,
  63216. /**
  63217. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63218. */
  63219. url: string,
  63220. /**
  63221. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63222. */
  63223. extensions?: string[] | undefined,
  63224. /**
  63225. * Defines if mipmaps should not be generated (default is false)
  63226. */
  63227. noMipmap?: boolean | undefined,
  63228. /**
  63229. * Defines the explicit list of files (undefined by default)
  63230. */
  63231. files?: string[] | undefined);
  63232. /**
  63233. * Execute the current task
  63234. * @param scene defines the scene where you want your assets to be loaded
  63235. * @param onSuccess is a callback called when the task is successfully executed
  63236. * @param onError is a callback called if an error occurs
  63237. */
  63238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63239. }
  63240. /**
  63241. * Define a task used by AssetsManager to load HDR cube textures
  63242. */
  63243. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63244. /**
  63245. * Defines the name of the task
  63246. */
  63247. name: string;
  63248. /**
  63249. * Defines the location of the file to load
  63250. */
  63251. url: string;
  63252. /**
  63253. * Defines the desired size (the more it increases the longer the generation will be)
  63254. */
  63255. size: number;
  63256. /**
  63257. * Defines if mipmaps should not be generated (default is false)
  63258. */
  63259. noMipmap: boolean;
  63260. /**
  63261. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63262. */
  63263. generateHarmonics: boolean;
  63264. /**
  63265. * 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)
  63266. */
  63267. gammaSpace: boolean;
  63268. /**
  63269. * Internal Use Only
  63270. */
  63271. reserved: boolean;
  63272. /**
  63273. * Gets the loaded texture
  63274. */
  63275. texture: HDRCubeTexture;
  63276. /**
  63277. * Callback called when the task is successful
  63278. */
  63279. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63280. /**
  63281. * Callback called when the task is successful
  63282. */
  63283. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63284. /**
  63285. * Creates a new HDRCubeTextureAssetTask object
  63286. * @param name defines the name of the task
  63287. * @param url defines the location of the file to load
  63288. * @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.
  63289. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63290. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63291. * @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)
  63292. * @param reserved Internal use only
  63293. */
  63294. constructor(
  63295. /**
  63296. * Defines the name of the task
  63297. */
  63298. name: string,
  63299. /**
  63300. * Defines the location of the file to load
  63301. */
  63302. url: string,
  63303. /**
  63304. * Defines the desired size (the more it increases the longer the generation will be)
  63305. */
  63306. size: number,
  63307. /**
  63308. * Defines if mipmaps should not be generated (default is false)
  63309. */
  63310. noMipmap?: boolean,
  63311. /**
  63312. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63313. */
  63314. generateHarmonics?: boolean,
  63315. /**
  63316. * 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)
  63317. */
  63318. gammaSpace?: boolean,
  63319. /**
  63320. * Internal Use Only
  63321. */
  63322. reserved?: boolean);
  63323. /**
  63324. * Execute the current task
  63325. * @param scene defines the scene where you want your assets to be loaded
  63326. * @param onSuccess is a callback called when the task is successfully executed
  63327. * @param onError is a callback called if an error occurs
  63328. */
  63329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63330. }
  63331. /**
  63332. * Define a task used by AssetsManager to load Equirectangular cube textures
  63333. */
  63334. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63335. /**
  63336. * Defines the name of the task
  63337. */
  63338. name: string;
  63339. /**
  63340. * Defines the location of the file to load
  63341. */
  63342. url: string;
  63343. /**
  63344. * Defines the desired size (the more it increases the longer the generation will be)
  63345. */
  63346. size: number;
  63347. /**
  63348. * Defines if mipmaps should not be generated (default is false)
  63349. */
  63350. noMipmap: boolean;
  63351. /**
  63352. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63353. * but the standard material would require them in Gamma space) (default is true)
  63354. */
  63355. gammaSpace: boolean;
  63356. /**
  63357. * Gets the loaded texture
  63358. */
  63359. texture: EquiRectangularCubeTexture;
  63360. /**
  63361. * Callback called when the task is successful
  63362. */
  63363. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63364. /**
  63365. * Callback called when the task is successful
  63366. */
  63367. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63368. /**
  63369. * Creates a new EquiRectangularCubeTextureAssetTask object
  63370. * @param name defines the name of the task
  63371. * @param url defines the location of the file to load
  63372. * @param size defines the desired size (the more it increases the longer the generation will be)
  63373. * If the size is omitted this implies you are using a preprocessed cubemap.
  63374. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63375. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63376. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63377. * (default is true)
  63378. */
  63379. constructor(
  63380. /**
  63381. * Defines the name of the task
  63382. */
  63383. name: string,
  63384. /**
  63385. * Defines the location of the file to load
  63386. */
  63387. url: string,
  63388. /**
  63389. * Defines the desired size (the more it increases the longer the generation will be)
  63390. */
  63391. size: number,
  63392. /**
  63393. * Defines if mipmaps should not be generated (default is false)
  63394. */
  63395. noMipmap?: boolean,
  63396. /**
  63397. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63398. * but the standard material would require them in Gamma space) (default is true)
  63399. */
  63400. gammaSpace?: boolean);
  63401. /**
  63402. * Execute the current task
  63403. * @param scene defines the scene where you want your assets to be loaded
  63404. * @param onSuccess is a callback called when the task is successfully executed
  63405. * @param onError is a callback called if an error occurs
  63406. */
  63407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63408. }
  63409. /**
  63410. * This class can be used to easily import assets into a scene
  63411. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63412. */
  63413. export class AssetsManager {
  63414. private _scene;
  63415. private _isLoading;
  63416. protected _tasks: AbstractAssetTask[];
  63417. protected _waitingTasksCount: number;
  63418. protected _totalTasksCount: number;
  63419. /**
  63420. * Callback called when all tasks are processed
  63421. */
  63422. onFinish: (tasks: AbstractAssetTask[]) => void;
  63423. /**
  63424. * Callback called when a task is successful
  63425. */
  63426. onTaskSuccess: (task: AbstractAssetTask) => void;
  63427. /**
  63428. * Callback called when a task had an error
  63429. */
  63430. onTaskError: (task: AbstractAssetTask) => void;
  63431. /**
  63432. * Callback called when a task is done (whatever the result is)
  63433. */
  63434. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63435. /**
  63436. * Observable called when all tasks are processed
  63437. */
  63438. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63439. /**
  63440. * Observable called when a task had an error
  63441. */
  63442. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63443. /**
  63444. * Observable called when all tasks were executed
  63445. */
  63446. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63447. /**
  63448. * Observable called when a task is done (whatever the result is)
  63449. */
  63450. onProgressObservable: Observable<IAssetsProgressEvent>;
  63451. /**
  63452. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63453. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63454. */
  63455. useDefaultLoadingScreen: boolean;
  63456. /**
  63457. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63458. * when all assets have been downloaded.
  63459. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63460. */
  63461. autoHideLoadingUI: boolean;
  63462. /**
  63463. * Creates a new AssetsManager
  63464. * @param scene defines the scene to work on
  63465. */
  63466. constructor(scene: Scene);
  63467. /**
  63468. * Add a MeshAssetTask to the list of active tasks
  63469. * @param taskName defines the name of the new task
  63470. * @param meshesNames defines the name of meshes to load
  63471. * @param rootUrl defines the root url to use to locate files
  63472. * @param sceneFilename defines the filename of the scene file
  63473. * @returns a new MeshAssetTask object
  63474. */
  63475. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63476. /**
  63477. * Add a TextFileAssetTask to the list of active tasks
  63478. * @param taskName defines the name of the new task
  63479. * @param url defines the url of the file to load
  63480. * @returns a new TextFileAssetTask object
  63481. */
  63482. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63483. /**
  63484. * Add a BinaryFileAssetTask to the list of active tasks
  63485. * @param taskName defines the name of the new task
  63486. * @param url defines the url of the file to load
  63487. * @returns a new BinaryFileAssetTask object
  63488. */
  63489. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63490. /**
  63491. * Add a ImageAssetTask to the list of active tasks
  63492. * @param taskName defines the name of the new task
  63493. * @param url defines the url of the file to load
  63494. * @returns a new ImageAssetTask object
  63495. */
  63496. addImageTask(taskName: string, url: string): ImageAssetTask;
  63497. /**
  63498. * Add a TextureAssetTask to the list of active tasks
  63499. * @param taskName defines the name of the new task
  63500. * @param url defines the url of the file to load
  63501. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63502. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63503. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63504. * @returns a new TextureAssetTask object
  63505. */
  63506. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63507. /**
  63508. * Add a CubeTextureAssetTask to the list of active tasks
  63509. * @param taskName defines the name of the new task
  63510. * @param url defines the url of the file to load
  63511. * @param extensions defines the extension to use to load the cube map (can be null)
  63512. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63513. * @param files defines the list of files to load (can be null)
  63514. * @returns a new CubeTextureAssetTask object
  63515. */
  63516. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63517. /**
  63518. *
  63519. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63520. * @param taskName defines the name of the new task
  63521. * @param url defines the url of the file to load
  63522. * @param size defines the size you want for the cubemap (can be null)
  63523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63524. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63525. * @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)
  63526. * @param reserved Internal use only
  63527. * @returns a new HDRCubeTextureAssetTask object
  63528. */
  63529. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63530. /**
  63531. *
  63532. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63533. * @param taskName defines the name of the new task
  63534. * @param url defines the url of the file to load
  63535. * @param size defines the size you want for the cubemap (can be null)
  63536. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63537. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63538. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63539. * @returns a new EquiRectangularCubeTextureAssetTask object
  63540. */
  63541. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63542. /**
  63543. * Remove a task from the assets manager.
  63544. * @param task the task to remove
  63545. */
  63546. removeTask(task: AbstractAssetTask): void;
  63547. private _decreaseWaitingTasksCount;
  63548. private _runTask;
  63549. /**
  63550. * Reset the AssetsManager and remove all tasks
  63551. * @return the current instance of the AssetsManager
  63552. */
  63553. reset(): AssetsManager;
  63554. /**
  63555. * Start the loading process
  63556. * @return the current instance of the AssetsManager
  63557. */
  63558. load(): AssetsManager;
  63559. /**
  63560. * Start the loading process as an async operation
  63561. * @return a promise returning the list of failed tasks
  63562. */
  63563. loadAsync(): Promise<void>;
  63564. }
  63565. }
  63566. declare module "babylonjs/Misc/deferred" {
  63567. /**
  63568. * Wrapper class for promise with external resolve and reject.
  63569. */
  63570. export class Deferred<T> {
  63571. /**
  63572. * The promise associated with this deferred object.
  63573. */
  63574. readonly promise: Promise<T>;
  63575. private _resolve;
  63576. private _reject;
  63577. /**
  63578. * The resolve method of the promise associated with this deferred object.
  63579. */
  63580. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63581. /**
  63582. * The reject method of the promise associated with this deferred object.
  63583. */
  63584. readonly reject: (reason?: any) => void;
  63585. /**
  63586. * Constructor for this deferred object.
  63587. */
  63588. constructor();
  63589. }
  63590. }
  63591. declare module "babylonjs/Misc/meshExploder" {
  63592. import { Mesh } from "babylonjs/Meshes/mesh";
  63593. /**
  63594. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63595. */
  63596. export class MeshExploder {
  63597. private _centerMesh;
  63598. private _meshes;
  63599. private _meshesOrigins;
  63600. private _toCenterVectors;
  63601. private _scaledDirection;
  63602. private _newPosition;
  63603. private _centerPosition;
  63604. /**
  63605. * Explodes meshes from a center mesh.
  63606. * @param meshes The meshes to explode.
  63607. * @param centerMesh The mesh to be center of explosion.
  63608. */
  63609. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63610. private _setCenterMesh;
  63611. /**
  63612. * Get class name
  63613. * @returns "MeshExploder"
  63614. */
  63615. getClassName(): string;
  63616. /**
  63617. * "Exploded meshes"
  63618. * @returns Array of meshes with the centerMesh at index 0.
  63619. */
  63620. getMeshes(): Array<Mesh>;
  63621. /**
  63622. * Explodes meshes giving a specific direction
  63623. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63624. */
  63625. explode(direction?: number): void;
  63626. }
  63627. }
  63628. declare module "babylonjs/Misc/filesInput" {
  63629. import { Engine } from "babylonjs/Engines/engine";
  63630. import { Scene } from "babylonjs/scene";
  63631. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63632. /**
  63633. * Class used to help managing file picking and drag'n'drop
  63634. */
  63635. export class FilesInput {
  63636. /**
  63637. * List of files ready to be loaded
  63638. */
  63639. static readonly FilesToLoad: {
  63640. [key: string]: File;
  63641. };
  63642. /**
  63643. * Callback called when a file is processed
  63644. */
  63645. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63646. private _engine;
  63647. private _currentScene;
  63648. private _sceneLoadedCallback;
  63649. private _progressCallback;
  63650. private _additionalRenderLoopLogicCallback;
  63651. private _textureLoadingCallback;
  63652. private _startingProcessingFilesCallback;
  63653. private _onReloadCallback;
  63654. private _errorCallback;
  63655. private _elementToMonitor;
  63656. private _sceneFileToLoad;
  63657. private _filesToLoad;
  63658. /**
  63659. * Creates a new FilesInput
  63660. * @param engine defines the rendering engine
  63661. * @param scene defines the hosting scene
  63662. * @param sceneLoadedCallback callback called when scene is loaded
  63663. * @param progressCallback callback called to track progress
  63664. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63665. * @param textureLoadingCallback callback called when a texture is loading
  63666. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63667. * @param onReloadCallback callback called when a reload is requested
  63668. * @param errorCallback callback call if an error occurs
  63669. */
  63670. 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);
  63671. private _dragEnterHandler;
  63672. private _dragOverHandler;
  63673. private _dropHandler;
  63674. /**
  63675. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63676. * @param elementToMonitor defines the DOM element to track
  63677. */
  63678. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63679. /**
  63680. * Release all associated resources
  63681. */
  63682. dispose(): void;
  63683. private renderFunction;
  63684. private drag;
  63685. private drop;
  63686. private _traverseFolder;
  63687. private _processFiles;
  63688. /**
  63689. * Load files from a drop event
  63690. * @param event defines the drop event to use as source
  63691. */
  63692. loadFiles(event: any): void;
  63693. private _processReload;
  63694. /**
  63695. * Reload the current scene from the loaded files
  63696. */
  63697. reload(): void;
  63698. }
  63699. }
  63700. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63701. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63702. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63703. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63704. }
  63705. declare module "babylonjs/Misc/sceneOptimizer" {
  63706. import { Scene, IDisposable } from "babylonjs/scene";
  63707. import { Observable } from "babylonjs/Misc/observable";
  63708. /**
  63709. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63711. */
  63712. export class SceneOptimization {
  63713. /**
  63714. * Defines the priority of this optimization (0 by default which means first in the list)
  63715. */
  63716. priority: number;
  63717. /**
  63718. * Gets a string describing the action executed by the current optimization
  63719. * @returns description string
  63720. */
  63721. getDescription(): string;
  63722. /**
  63723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63724. * @param scene defines the current scene where to apply this optimization
  63725. * @param optimizer defines the current optimizer
  63726. * @returns true if everything that can be done was applied
  63727. */
  63728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63729. /**
  63730. * Creates the SceneOptimization object
  63731. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63732. * @param desc defines the description associated with the optimization
  63733. */
  63734. constructor(
  63735. /**
  63736. * Defines the priority of this optimization (0 by default which means first in the list)
  63737. */
  63738. priority?: number);
  63739. }
  63740. /**
  63741. * Defines an optimization used to reduce the size of render target textures
  63742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63743. */
  63744. export class TextureOptimization extends SceneOptimization {
  63745. /**
  63746. * Defines the priority of this optimization (0 by default which means first in the list)
  63747. */
  63748. priority: number;
  63749. /**
  63750. * 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
  63751. */
  63752. maximumSize: number;
  63753. /**
  63754. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63755. */
  63756. step: number;
  63757. /**
  63758. * Gets a string describing the action executed by the current optimization
  63759. * @returns description string
  63760. */
  63761. getDescription(): string;
  63762. /**
  63763. * Creates the TextureOptimization object
  63764. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63765. * @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
  63766. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63767. */
  63768. constructor(
  63769. /**
  63770. * Defines the priority of this optimization (0 by default which means first in the list)
  63771. */
  63772. priority?: number,
  63773. /**
  63774. * 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
  63775. */
  63776. maximumSize?: number,
  63777. /**
  63778. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63779. */
  63780. step?: number);
  63781. /**
  63782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63783. * @param scene defines the current scene where to apply this optimization
  63784. * @param optimizer defines the current optimizer
  63785. * @returns true if everything that can be done was applied
  63786. */
  63787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63788. }
  63789. /**
  63790. * Defines an optimization used to increase or decrease the rendering resolution
  63791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63792. */
  63793. export class HardwareScalingOptimization extends SceneOptimization {
  63794. /**
  63795. * Defines the priority of this optimization (0 by default which means first in the list)
  63796. */
  63797. priority: number;
  63798. /**
  63799. * Defines the maximum scale to use (2 by default)
  63800. */
  63801. maximumScale: number;
  63802. /**
  63803. * Defines the step to use between two passes (0.5 by default)
  63804. */
  63805. step: number;
  63806. private _currentScale;
  63807. private _directionOffset;
  63808. /**
  63809. * Gets a string describing the action executed by the current optimization
  63810. * @return description string
  63811. */
  63812. getDescription(): string;
  63813. /**
  63814. * Creates the HardwareScalingOptimization object
  63815. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63816. * @param maximumScale defines the maximum scale to use (2 by default)
  63817. * @param step defines the step to use between two passes (0.5 by default)
  63818. */
  63819. constructor(
  63820. /**
  63821. * Defines the priority of this optimization (0 by default which means first in the list)
  63822. */
  63823. priority?: number,
  63824. /**
  63825. * Defines the maximum scale to use (2 by default)
  63826. */
  63827. maximumScale?: number,
  63828. /**
  63829. * Defines the step to use between two passes (0.5 by default)
  63830. */
  63831. step?: number);
  63832. /**
  63833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63834. * @param scene defines the current scene where to apply this optimization
  63835. * @param optimizer defines the current optimizer
  63836. * @returns true if everything that can be done was applied
  63837. */
  63838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63839. }
  63840. /**
  63841. * Defines an optimization used to remove shadows
  63842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63843. */
  63844. export class ShadowsOptimization extends SceneOptimization {
  63845. /**
  63846. * Gets a string describing the action executed by the current optimization
  63847. * @return description string
  63848. */
  63849. getDescription(): string;
  63850. /**
  63851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63852. * @param scene defines the current scene where to apply this optimization
  63853. * @param optimizer defines the current optimizer
  63854. * @returns true if everything that can be done was applied
  63855. */
  63856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63857. }
  63858. /**
  63859. * Defines an optimization used to turn post-processes off
  63860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63861. */
  63862. export class PostProcessesOptimization extends SceneOptimization {
  63863. /**
  63864. * Gets a string describing the action executed by the current optimization
  63865. * @return description string
  63866. */
  63867. getDescription(): string;
  63868. /**
  63869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63870. * @param scene defines the current scene where to apply this optimization
  63871. * @param optimizer defines the current optimizer
  63872. * @returns true if everything that can be done was applied
  63873. */
  63874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63875. }
  63876. /**
  63877. * Defines an optimization used to turn lens flares off
  63878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63879. */
  63880. export class LensFlaresOptimization extends SceneOptimization {
  63881. /**
  63882. * Gets a string describing the action executed by the current optimization
  63883. * @return description string
  63884. */
  63885. getDescription(): string;
  63886. /**
  63887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63888. * @param scene defines the current scene where to apply this optimization
  63889. * @param optimizer defines the current optimizer
  63890. * @returns true if everything that can be done was applied
  63891. */
  63892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63893. }
  63894. /**
  63895. * Defines an optimization based on user defined callback.
  63896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63897. */
  63898. export class CustomOptimization extends SceneOptimization {
  63899. /**
  63900. * Callback called to apply the custom optimization.
  63901. */
  63902. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63903. /**
  63904. * Callback called to get custom description
  63905. */
  63906. onGetDescription: () => string;
  63907. /**
  63908. * Gets a string describing the action executed by the current optimization
  63909. * @returns description string
  63910. */
  63911. getDescription(): string;
  63912. /**
  63913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63914. * @param scene defines the current scene where to apply this optimization
  63915. * @param optimizer defines the current optimizer
  63916. * @returns true if everything that can be done was applied
  63917. */
  63918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63919. }
  63920. /**
  63921. * Defines an optimization used to turn particles off
  63922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63923. */
  63924. export class ParticlesOptimization extends SceneOptimization {
  63925. /**
  63926. * Gets a string describing the action executed by the current optimization
  63927. * @return description string
  63928. */
  63929. getDescription(): string;
  63930. /**
  63931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63932. * @param scene defines the current scene where to apply this optimization
  63933. * @param optimizer defines the current optimizer
  63934. * @returns true if everything that can be done was applied
  63935. */
  63936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63937. }
  63938. /**
  63939. * Defines an optimization used to turn render targets off
  63940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63941. */
  63942. export class RenderTargetsOptimization extends SceneOptimization {
  63943. /**
  63944. * Gets a string describing the action executed by the current optimization
  63945. * @return description string
  63946. */
  63947. getDescription(): string;
  63948. /**
  63949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63950. * @param scene defines the current scene where to apply this optimization
  63951. * @param optimizer defines the current optimizer
  63952. * @returns true if everything that can be done was applied
  63953. */
  63954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63955. }
  63956. /**
  63957. * Defines an optimization used to merge meshes with compatible materials
  63958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63959. */
  63960. export class MergeMeshesOptimization extends SceneOptimization {
  63961. private static _UpdateSelectionTree;
  63962. /**
  63963. * Gets or sets a boolean which defines if optimization octree has to be updated
  63964. */
  63965. /**
  63966. * Gets or sets a boolean which defines if optimization octree has to be updated
  63967. */
  63968. static UpdateSelectionTree: boolean;
  63969. /**
  63970. * Gets a string describing the action executed by the current optimization
  63971. * @return description string
  63972. */
  63973. getDescription(): string;
  63974. private _canBeMerged;
  63975. /**
  63976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63977. * @param scene defines the current scene where to apply this optimization
  63978. * @param optimizer defines the current optimizer
  63979. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63980. * @returns true if everything that can be done was applied
  63981. */
  63982. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63983. }
  63984. /**
  63985. * Defines a list of options used by SceneOptimizer
  63986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63987. */
  63988. export class SceneOptimizerOptions {
  63989. /**
  63990. * Defines the target frame rate to reach (60 by default)
  63991. */
  63992. targetFrameRate: number;
  63993. /**
  63994. * Defines the interval between two checkes (2000ms by default)
  63995. */
  63996. trackerDuration: number;
  63997. /**
  63998. * Gets the list of optimizations to apply
  63999. */
  64000. optimizations: SceneOptimization[];
  64001. /**
  64002. * Creates a new list of options used by SceneOptimizer
  64003. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64004. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64005. */
  64006. constructor(
  64007. /**
  64008. * Defines the target frame rate to reach (60 by default)
  64009. */
  64010. targetFrameRate?: number,
  64011. /**
  64012. * Defines the interval between two checkes (2000ms by default)
  64013. */
  64014. trackerDuration?: number);
  64015. /**
  64016. * Add a new optimization
  64017. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64018. * @returns the current SceneOptimizerOptions
  64019. */
  64020. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64021. /**
  64022. * Add a new custom optimization
  64023. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64024. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64025. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64026. * @returns the current SceneOptimizerOptions
  64027. */
  64028. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64029. /**
  64030. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64031. * @param targetFrameRate defines the target frame rate (60 by default)
  64032. * @returns a SceneOptimizerOptions object
  64033. */
  64034. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64035. /**
  64036. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64037. * @param targetFrameRate defines the target frame rate (60 by default)
  64038. * @returns a SceneOptimizerOptions object
  64039. */
  64040. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64041. /**
  64042. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64043. * @param targetFrameRate defines the target frame rate (60 by default)
  64044. * @returns a SceneOptimizerOptions object
  64045. */
  64046. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64047. }
  64048. /**
  64049. * Class used to run optimizations in order to reach a target frame rate
  64050. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64051. */
  64052. export class SceneOptimizer implements IDisposable {
  64053. private _isRunning;
  64054. private _options;
  64055. private _scene;
  64056. private _currentPriorityLevel;
  64057. private _targetFrameRate;
  64058. private _trackerDuration;
  64059. private _currentFrameRate;
  64060. private _sceneDisposeObserver;
  64061. private _improvementMode;
  64062. /**
  64063. * Defines an observable called when the optimizer reaches the target frame rate
  64064. */
  64065. onSuccessObservable: Observable<SceneOptimizer>;
  64066. /**
  64067. * Defines an observable called when the optimizer enables an optimization
  64068. */
  64069. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64070. /**
  64071. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64072. */
  64073. onFailureObservable: Observable<SceneOptimizer>;
  64074. /**
  64075. * Gets a boolean indicating if the optimizer is in improvement mode
  64076. */
  64077. readonly isInImprovementMode: boolean;
  64078. /**
  64079. * Gets the current priority level (0 at start)
  64080. */
  64081. readonly currentPriorityLevel: number;
  64082. /**
  64083. * Gets the current frame rate checked by the SceneOptimizer
  64084. */
  64085. readonly currentFrameRate: number;
  64086. /**
  64087. * Gets or sets the current target frame rate (60 by default)
  64088. */
  64089. /**
  64090. * Gets or sets the current target frame rate (60 by default)
  64091. */
  64092. targetFrameRate: number;
  64093. /**
  64094. * Gets or sets the current interval between two checks (every 2000ms by default)
  64095. */
  64096. /**
  64097. * Gets or sets the current interval between two checks (every 2000ms by default)
  64098. */
  64099. trackerDuration: number;
  64100. /**
  64101. * Gets the list of active optimizations
  64102. */
  64103. readonly optimizations: SceneOptimization[];
  64104. /**
  64105. * Creates a new SceneOptimizer
  64106. * @param scene defines the scene to work on
  64107. * @param options defines the options to use with the SceneOptimizer
  64108. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64109. * @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)
  64110. */
  64111. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64112. /**
  64113. * Stops the current optimizer
  64114. */
  64115. stop(): void;
  64116. /**
  64117. * Reset the optimizer to initial step (current priority level = 0)
  64118. */
  64119. reset(): void;
  64120. /**
  64121. * Start the optimizer. By default it will try to reach a specific framerate
  64122. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64123. */
  64124. start(): void;
  64125. private _checkCurrentState;
  64126. /**
  64127. * Release all resources
  64128. */
  64129. dispose(): void;
  64130. /**
  64131. * Helper function to create a SceneOptimizer with one single line of code
  64132. * @param scene defines the scene to work on
  64133. * @param options defines the options to use with the SceneOptimizer
  64134. * @param onSuccess defines a callback to call on success
  64135. * @param onFailure defines a callback to call on failure
  64136. * @returns the new SceneOptimizer object
  64137. */
  64138. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64139. }
  64140. }
  64141. declare module "babylonjs/Misc/sceneSerializer" {
  64142. import { Scene } from "babylonjs/scene";
  64143. /**
  64144. * Class used to serialize a scene into a string
  64145. */
  64146. export class SceneSerializer {
  64147. /**
  64148. * Clear cache used by a previous serialization
  64149. */
  64150. static ClearCache(): void;
  64151. /**
  64152. * Serialize a scene into a JSON compatible object
  64153. * @param scene defines the scene to serialize
  64154. * @returns a JSON compatible object
  64155. */
  64156. static Serialize(scene: Scene): any;
  64157. /**
  64158. * Serialize a mesh into a JSON compatible object
  64159. * @param toSerialize defines the mesh to serialize
  64160. * @param withParents defines if parents must be serialized as well
  64161. * @param withChildren defines if children must be serialized as well
  64162. * @returns a JSON compatible object
  64163. */
  64164. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64165. }
  64166. }
  64167. declare module "babylonjs/Misc/textureTools" {
  64168. import { Texture } from "babylonjs/Materials/Textures/texture";
  64169. /**
  64170. * Class used to host texture specific utilities
  64171. */
  64172. export class TextureTools {
  64173. /**
  64174. * Uses the GPU to create a copy texture rescaled at a given size
  64175. * @param texture Texture to copy from
  64176. * @param width defines the desired width
  64177. * @param height defines the desired height
  64178. * @param useBilinearMode defines if bilinear mode has to be used
  64179. * @return the generated texture
  64180. */
  64181. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64182. }
  64183. }
  64184. declare module "babylonjs/Misc/videoRecorder" {
  64185. import { Nullable } from "babylonjs/types";
  64186. import { Engine } from "babylonjs/Engines/engine";
  64187. /**
  64188. * This represents the different options available for the video capture.
  64189. */
  64190. export interface VideoRecorderOptions {
  64191. /** Defines the mime type of the video. */
  64192. mimeType: string;
  64193. /** Defines the FPS the video should be recorded at. */
  64194. fps: number;
  64195. /** Defines the chunk size for the recording data. */
  64196. recordChunckSize: number;
  64197. /** The audio tracks to attach to the recording. */
  64198. audioTracks?: MediaStreamTrack[];
  64199. }
  64200. /**
  64201. * This can help with recording videos from BabylonJS.
  64202. * This is based on the available WebRTC functionalities of the browser.
  64203. *
  64204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64205. */
  64206. export class VideoRecorder {
  64207. private static readonly _defaultOptions;
  64208. /**
  64209. * Returns whether or not the VideoRecorder is available in your browser.
  64210. * @param engine Defines the Babylon Engine.
  64211. * @returns true if supported otherwise false.
  64212. */
  64213. static IsSupported(engine: Engine): boolean;
  64214. private readonly _options;
  64215. private _canvas;
  64216. private _mediaRecorder;
  64217. private _recordedChunks;
  64218. private _fileName;
  64219. private _resolve;
  64220. private _reject;
  64221. /**
  64222. * True when a recording is already in progress.
  64223. */
  64224. readonly isRecording: boolean;
  64225. /**
  64226. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64227. * @param engine Defines the BabylonJS Engine you wish to record.
  64228. * @param options Defines options that can be used to customize the capture.
  64229. */
  64230. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64231. /**
  64232. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64233. */
  64234. stopRecording(): void;
  64235. /**
  64236. * Starts recording the canvas for a max duration specified in parameters.
  64237. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64238. * If null no automatic download will start and you can rely on the promise to get the data back.
  64239. * @param maxDuration Defines the maximum recording time in seconds.
  64240. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64241. * @return A promise callback at the end of the recording with the video data in Blob.
  64242. */
  64243. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64244. /**
  64245. * Releases internal resources used during the recording.
  64246. */
  64247. dispose(): void;
  64248. private _handleDataAvailable;
  64249. private _handleError;
  64250. private _handleStop;
  64251. }
  64252. }
  64253. declare module "babylonjs/Misc/screenshotTools" {
  64254. import { Camera } from "babylonjs/Cameras/camera";
  64255. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64256. import { Engine } from "babylonjs/Engines/engine";
  64257. /**
  64258. * Class containing a set of static utilities functions for screenshots
  64259. */
  64260. export class ScreenshotTools {
  64261. /**
  64262. * Captures a screenshot of the current rendering
  64263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64264. * @param engine defines the rendering engine
  64265. * @param camera defines the source camera
  64266. * @param size This parameter can be set to a single number or to an object with the
  64267. * following (optional) properties: precision, width, height. If a single number is passed,
  64268. * it will be used for both width and height. If an object is passed, the screenshot size
  64269. * will be derived from the parameters. The precision property is a multiplier allowing
  64270. * rendering at a higher or lower resolution
  64271. * @param successCallback defines the callback receives a single parameter which contains the
  64272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64273. * src parameter of an <img> to display it
  64274. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64275. * Check your browser for supported MIME types
  64276. */
  64277. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64278. /**
  64279. * Captures a screenshot of the current rendering
  64280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64281. * @param engine defines the rendering engine
  64282. * @param camera defines the source camera
  64283. * @param size This parameter can be set to a single number or to an object with the
  64284. * following (optional) properties: precision, width, height. If a single number is passed,
  64285. * it will be used for both width and height. If an object is passed, the screenshot size
  64286. * will be derived from the parameters. The precision property is a multiplier allowing
  64287. * rendering at a higher or lower resolution
  64288. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64289. * Check your browser for supported MIME types
  64290. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64291. * to the src parameter of an <img> to display it
  64292. */
  64293. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64294. /**
  64295. * Generates an image screenshot from the specified camera.
  64296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64297. * @param engine The engine to use for rendering
  64298. * @param camera The camera to use for rendering
  64299. * @param size This parameter can be set to a single number or to an object with the
  64300. * following (optional) properties: precision, width, height. If a single number is passed,
  64301. * it will be used for both width and height. If an object is passed, the screenshot size
  64302. * will be derived from the parameters. The precision property is a multiplier allowing
  64303. * rendering at a higher or lower resolution
  64304. * @param successCallback The callback receives a single parameter which contains the
  64305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64306. * src parameter of an <img> to display it
  64307. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64308. * Check your browser for supported MIME types
  64309. * @param samples Texture samples (default: 1)
  64310. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64311. * @param fileName A name for for the downloaded file.
  64312. */
  64313. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64314. /**
  64315. * Generates an image screenshot from the specified camera.
  64316. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64317. * @param engine The engine to use for rendering
  64318. * @param camera The camera to use for rendering
  64319. * @param size This parameter can be set to a single number or to an object with the
  64320. * following (optional) properties: precision, width, height. If a single number is passed,
  64321. * it will be used for both width and height. If an object is passed, the screenshot size
  64322. * will be derived from the parameters. The precision property is a multiplier allowing
  64323. * rendering at a higher or lower resolution
  64324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64325. * Check your browser for supported MIME types
  64326. * @param samples Texture samples (default: 1)
  64327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64328. * @param fileName A name for for the downloaded file.
  64329. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64330. * to the src parameter of an <img> to display it
  64331. */
  64332. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64333. /**
  64334. * Gets height and width for screenshot size
  64335. * @private
  64336. */
  64337. private static _getScreenshotSize;
  64338. }
  64339. }
  64340. declare module "babylonjs/Misc/index" {
  64341. export * from "babylonjs/Misc/andOrNotEvaluator";
  64342. export * from "babylonjs/Misc/assetsManager";
  64343. export * from "babylonjs/Misc/dds";
  64344. export * from "babylonjs/Misc/decorators";
  64345. export * from "babylonjs/Misc/deferred";
  64346. export * from "babylonjs/Misc/environmentTextureTools";
  64347. export * from "babylonjs/Misc/meshExploder";
  64348. export * from "babylonjs/Misc/filesInput";
  64349. export * from "babylonjs/Misc/HighDynamicRange/index";
  64350. export * from "babylonjs/Misc/khronosTextureContainer";
  64351. export * from "babylonjs/Misc/observable";
  64352. export * from "babylonjs/Misc/performanceMonitor";
  64353. export * from "babylonjs/Misc/promise";
  64354. export * from "babylonjs/Misc/sceneOptimizer";
  64355. export * from "babylonjs/Misc/sceneSerializer";
  64356. export * from "babylonjs/Misc/smartArray";
  64357. export * from "babylonjs/Misc/stringDictionary";
  64358. export * from "babylonjs/Misc/tags";
  64359. export * from "babylonjs/Misc/textureTools";
  64360. export * from "babylonjs/Misc/tga";
  64361. export * from "babylonjs/Misc/tools";
  64362. export * from "babylonjs/Misc/videoRecorder";
  64363. export * from "babylonjs/Misc/virtualJoystick";
  64364. export * from "babylonjs/Misc/workerPool";
  64365. export * from "babylonjs/Misc/logger";
  64366. export * from "babylonjs/Misc/typeStore";
  64367. export * from "babylonjs/Misc/filesInputStore";
  64368. export * from "babylonjs/Misc/deepCopier";
  64369. export * from "babylonjs/Misc/pivotTools";
  64370. export * from "babylonjs/Misc/precisionDate";
  64371. export * from "babylonjs/Misc/screenshotTools";
  64372. export * from "babylonjs/Misc/typeStore";
  64373. export * from "babylonjs/Misc/webRequest";
  64374. export * from "babylonjs/Misc/iInspectable";
  64375. export * from "babylonjs/Misc/brdfTextureTools";
  64376. export * from "babylonjs/Misc/gradients";
  64377. export * from "babylonjs/Misc/perfCounter";
  64378. export * from "babylonjs/Misc/fileRequest";
  64379. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64380. export * from "babylonjs/Misc/retryStrategy";
  64381. export * from "babylonjs/Misc/loadFileError";
  64382. }
  64383. declare module "babylonjs/index" {
  64384. export * from "babylonjs/abstractScene";
  64385. export * from "babylonjs/Actions/index";
  64386. export * from "babylonjs/Animations/index";
  64387. export * from "babylonjs/assetContainer";
  64388. export * from "babylonjs/Audio/index";
  64389. export * from "babylonjs/Behaviors/index";
  64390. export * from "babylonjs/Bones/index";
  64391. export * from "babylonjs/Cameras/index";
  64392. export * from "babylonjs/Collisions/index";
  64393. export * from "babylonjs/Culling/index";
  64394. export * from "babylonjs/Debug/index";
  64395. export * from "babylonjs/Engines/index";
  64396. export * from "babylonjs/Events/index";
  64397. export * from "babylonjs/Gamepads/index";
  64398. export * from "babylonjs/Gizmos/index";
  64399. export * from "babylonjs/Helpers/index";
  64400. export * from "babylonjs/Instrumentation/index";
  64401. export * from "babylonjs/Layers/index";
  64402. export * from "babylonjs/LensFlares/index";
  64403. export * from "babylonjs/Lights/index";
  64404. export * from "babylonjs/Loading/index";
  64405. export * from "babylonjs/Materials/index";
  64406. export * from "babylonjs/Maths/index";
  64407. export * from "babylonjs/Meshes/index";
  64408. export * from "babylonjs/Morph/index";
  64409. export * from "babylonjs/Navigation/index";
  64410. export * from "babylonjs/node";
  64411. export * from "babylonjs/Offline/index";
  64412. export * from "babylonjs/Particles/index";
  64413. export * from "babylonjs/Physics/index";
  64414. export * from "babylonjs/PostProcesses/index";
  64415. export * from "babylonjs/Probes/index";
  64416. export * from "babylonjs/Rendering/index";
  64417. export * from "babylonjs/scene";
  64418. export * from "babylonjs/sceneComponent";
  64419. export * from "babylonjs/Sprites/index";
  64420. export * from "babylonjs/States/index";
  64421. export * from "babylonjs/Misc/index";
  64422. export * from "babylonjs/types";
  64423. }
  64424. declare module "babylonjs/Animations/pathCursor" {
  64425. import { Vector3 } from "babylonjs/Maths/math.vector";
  64426. import { Path2 } from "babylonjs/Maths/math.path";
  64427. /**
  64428. * A cursor which tracks a point on a path
  64429. */
  64430. export class PathCursor {
  64431. private path;
  64432. /**
  64433. * Stores path cursor callbacks for when an onchange event is triggered
  64434. */
  64435. private _onchange;
  64436. /**
  64437. * The value of the path cursor
  64438. */
  64439. value: number;
  64440. /**
  64441. * The animation array of the path cursor
  64442. */
  64443. animations: Animation[];
  64444. /**
  64445. * Initializes the path cursor
  64446. * @param path The path to track
  64447. */
  64448. constructor(path: Path2);
  64449. /**
  64450. * Gets the cursor point on the path
  64451. * @returns A point on the path cursor at the cursor location
  64452. */
  64453. getPoint(): Vector3;
  64454. /**
  64455. * Moves the cursor ahead by the step amount
  64456. * @param step The amount to move the cursor forward
  64457. * @returns This path cursor
  64458. */
  64459. moveAhead(step?: number): PathCursor;
  64460. /**
  64461. * Moves the cursor behind by the step amount
  64462. * @param step The amount to move the cursor back
  64463. * @returns This path cursor
  64464. */
  64465. moveBack(step?: number): PathCursor;
  64466. /**
  64467. * Moves the cursor by the step amount
  64468. * If the step amount is greater than one, an exception is thrown
  64469. * @param step The amount to move the cursor
  64470. * @returns This path cursor
  64471. */
  64472. move(step: number): PathCursor;
  64473. /**
  64474. * Ensures that the value is limited between zero and one
  64475. * @returns This path cursor
  64476. */
  64477. private ensureLimits;
  64478. /**
  64479. * Runs onchange callbacks on change (used by the animation engine)
  64480. * @returns This path cursor
  64481. */
  64482. private raiseOnChange;
  64483. /**
  64484. * Executes a function on change
  64485. * @param f A path cursor onchange callback
  64486. * @returns This path cursor
  64487. */
  64488. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64489. }
  64490. }
  64491. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64492. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64493. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64494. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64495. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64496. }
  64497. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64498. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64499. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64500. }
  64501. declare module "babylonjs/Engines/Processors/index" {
  64502. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64503. export * from "babylonjs/Engines/Processors/Expressions/index";
  64504. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64505. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64506. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64507. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64508. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64509. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64510. }
  64511. declare module "babylonjs/Legacy/legacy" {
  64512. import * as Babylon from "babylonjs/index";
  64513. export * from "babylonjs/index";
  64514. }
  64515. declare module "babylonjs/Shaders/blur.fragment" {
  64516. /** @hidden */
  64517. export var blurPixelShader: {
  64518. name: string;
  64519. shader: string;
  64520. };
  64521. }
  64522. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64523. /** @hidden */
  64524. export var pointCloudVertexDeclaration: {
  64525. name: string;
  64526. shader: string;
  64527. };
  64528. }
  64529. declare module "babylonjs" {
  64530. export * from "babylonjs/Legacy/legacy";
  64531. }
  64532. declare module BABYLON {
  64533. /** Alias type for value that can be null */
  64534. export type Nullable<T> = T | null;
  64535. /**
  64536. * Alias type for number that are floats
  64537. * @ignorenaming
  64538. */
  64539. export type float = number;
  64540. /**
  64541. * Alias type for number that are doubles.
  64542. * @ignorenaming
  64543. */
  64544. export type double = number;
  64545. /**
  64546. * Alias type for number that are integer
  64547. * @ignorenaming
  64548. */
  64549. export type int = number;
  64550. /** Alias type for number array or Float32Array */
  64551. export type FloatArray = number[] | Float32Array;
  64552. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64553. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64554. /**
  64555. * Alias for types that can be used by a Buffer or VertexBuffer.
  64556. */
  64557. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64558. /**
  64559. * Alias type for primitive types
  64560. * @ignorenaming
  64561. */
  64562. type Primitive = undefined | null | boolean | string | number | Function;
  64563. /**
  64564. * Type modifier to make all the properties of an object Readonly
  64565. */
  64566. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64567. /**
  64568. * Type modifier to make all the properties of an object Readonly recursively
  64569. */
  64570. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64571. /** @hidden */
  64572. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64573. }
  64574. /** @hidden */
  64575. /** @hidden */
  64576. type DeepImmutableObject<T> = {
  64577. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64578. };
  64579. }
  64580. declare module BABYLON {
  64581. /**
  64582. * A class serves as a medium between the observable and its observers
  64583. */
  64584. export class EventState {
  64585. /**
  64586. * Create a new EventState
  64587. * @param mask defines the mask associated with this state
  64588. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64589. * @param target defines the original target of the state
  64590. * @param currentTarget defines the current target of the state
  64591. */
  64592. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64593. /**
  64594. * Initialize the current event state
  64595. * @param mask defines the mask associated with this state
  64596. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64597. * @param target defines the original target of the state
  64598. * @param currentTarget defines the current target of the state
  64599. * @returns the current event state
  64600. */
  64601. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64602. /**
  64603. * An Observer can set this property to true to prevent subsequent observers of being notified
  64604. */
  64605. skipNextObservers: boolean;
  64606. /**
  64607. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64608. */
  64609. mask: number;
  64610. /**
  64611. * The object that originally notified the event
  64612. */
  64613. target?: any;
  64614. /**
  64615. * The current object in the bubbling phase
  64616. */
  64617. currentTarget?: any;
  64618. /**
  64619. * This will be populated with the return value of the last function that was executed.
  64620. * If it is the first function in the callback chain it will be the event data.
  64621. */
  64622. lastReturnValue?: any;
  64623. }
  64624. /**
  64625. * Represent an Observer registered to a given Observable object.
  64626. */
  64627. export class Observer<T> {
  64628. /**
  64629. * Defines the callback to call when the observer is notified
  64630. */
  64631. callback: (eventData: T, eventState: EventState) => void;
  64632. /**
  64633. * Defines the mask of the observer (used to filter notifications)
  64634. */
  64635. mask: number;
  64636. /**
  64637. * Defines the current scope used to restore the JS context
  64638. */
  64639. scope: any;
  64640. /** @hidden */
  64641. _willBeUnregistered: boolean;
  64642. /**
  64643. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64644. */
  64645. unregisterOnNextCall: boolean;
  64646. /**
  64647. * Creates a new observer
  64648. * @param callback defines the callback to call when the observer is notified
  64649. * @param mask defines the mask of the observer (used to filter notifications)
  64650. * @param scope defines the current scope used to restore the JS context
  64651. */
  64652. constructor(
  64653. /**
  64654. * Defines the callback to call when the observer is notified
  64655. */
  64656. callback: (eventData: T, eventState: EventState) => void,
  64657. /**
  64658. * Defines the mask of the observer (used to filter notifications)
  64659. */
  64660. mask: number,
  64661. /**
  64662. * Defines the current scope used to restore the JS context
  64663. */
  64664. scope?: any);
  64665. }
  64666. /**
  64667. * Represent a list of observers registered to multiple Observables object.
  64668. */
  64669. export class MultiObserver<T> {
  64670. private _observers;
  64671. private _observables;
  64672. /**
  64673. * Release associated resources
  64674. */
  64675. dispose(): void;
  64676. /**
  64677. * Raise a callback when one of the observable will notify
  64678. * @param observables defines a list of observables to watch
  64679. * @param callback defines the callback to call on notification
  64680. * @param mask defines the mask used to filter notifications
  64681. * @param scope defines the current scope used to restore the JS context
  64682. * @returns the new MultiObserver
  64683. */
  64684. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64685. }
  64686. /**
  64687. * The Observable class is a simple implementation of the Observable pattern.
  64688. *
  64689. * 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.
  64690. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64691. * 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).
  64692. * 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.
  64693. */
  64694. export class Observable<T> {
  64695. private _observers;
  64696. private _eventState;
  64697. private _onObserverAdded;
  64698. /**
  64699. * Gets the list of observers
  64700. */
  64701. readonly observers: Array<Observer<T>>;
  64702. /**
  64703. * Creates a new observable
  64704. * @param onObserverAdded defines a callback to call when a new observer is added
  64705. */
  64706. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64707. /**
  64708. * Create a new Observer with the specified callback
  64709. * @param callback the callback that will be executed for that Observer
  64710. * @param mask the mask used to filter observers
  64711. * @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.
  64712. * @param scope optional scope for the callback to be called from
  64713. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64714. * @returns the new observer created for the callback
  64715. */
  64716. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64717. /**
  64718. * Create a new Observer with the specified callback and unregisters after the next notification
  64719. * @param callback the callback that will be executed for that Observer
  64720. * @returns the new observer created for the callback
  64721. */
  64722. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64723. /**
  64724. * Remove an Observer from the Observable object
  64725. * @param observer the instance of the Observer to remove
  64726. * @returns false if it doesn't belong to this Observable
  64727. */
  64728. remove(observer: Nullable<Observer<T>>): boolean;
  64729. /**
  64730. * Remove a callback from the Observable object
  64731. * @param callback the callback to remove
  64732. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64733. * @returns false if it doesn't belong to this Observable
  64734. */
  64735. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64736. private _deferUnregister;
  64737. private _remove;
  64738. /**
  64739. * Moves the observable to the top of the observer list making it get called first when notified
  64740. * @param observer the observer to move
  64741. */
  64742. makeObserverTopPriority(observer: Observer<T>): void;
  64743. /**
  64744. * Moves the observable to the bottom of the observer list making it get called last when notified
  64745. * @param observer the observer to move
  64746. */
  64747. makeObserverBottomPriority(observer: Observer<T>): void;
  64748. /**
  64749. * Notify all Observers by calling their respective callback with the given data
  64750. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64751. * @param eventData defines the data to send to all observers
  64752. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64753. * @param target defines the original target of the state
  64754. * @param currentTarget defines the current target of the state
  64755. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64756. */
  64757. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64758. /**
  64759. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64760. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64761. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64762. * and it is crucial that all callbacks will be executed.
  64763. * The order of the callbacks is kept, callbacks are not executed parallel.
  64764. *
  64765. * @param eventData The data to be sent to each callback
  64766. * @param mask is used to filter observers defaults to -1
  64767. * @param target defines the callback target (see EventState)
  64768. * @param currentTarget defines he current object in the bubbling phase
  64769. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64770. */
  64771. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64772. /**
  64773. * Notify a specific observer
  64774. * @param observer defines the observer to notify
  64775. * @param eventData defines the data to be sent to each callback
  64776. * @param mask is used to filter observers defaults to -1
  64777. */
  64778. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64779. /**
  64780. * Gets a boolean indicating if the observable has at least one observer
  64781. * @returns true is the Observable has at least one Observer registered
  64782. */
  64783. hasObservers(): boolean;
  64784. /**
  64785. * Clear the list of observers
  64786. */
  64787. clear(): void;
  64788. /**
  64789. * Clone the current observable
  64790. * @returns a new observable
  64791. */
  64792. clone(): Observable<T>;
  64793. /**
  64794. * Does this observable handles observer registered with a given mask
  64795. * @param mask defines the mask to be tested
  64796. * @return whether or not one observer registered with the given mask is handeled
  64797. **/
  64798. hasSpecificMask(mask?: number): boolean;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64804. * Babylon.js
  64805. */
  64806. export class DomManagement {
  64807. /**
  64808. * Checks if the window object exists
  64809. * @returns true if the window object exists
  64810. */
  64811. static IsWindowObjectExist(): boolean;
  64812. /**
  64813. * Extracts text content from a DOM element hierarchy
  64814. * @param element defines the root element
  64815. * @returns a string
  64816. */
  64817. static GetDOMTextContent(element: HTMLElement): string;
  64818. }
  64819. }
  64820. declare module BABYLON {
  64821. /**
  64822. * Logger used througouht the application to allow configuration of
  64823. * the log level required for the messages.
  64824. */
  64825. export class Logger {
  64826. /**
  64827. * No log
  64828. */
  64829. static readonly NoneLogLevel: number;
  64830. /**
  64831. * Only message logs
  64832. */
  64833. static readonly MessageLogLevel: number;
  64834. /**
  64835. * Only warning logs
  64836. */
  64837. static readonly WarningLogLevel: number;
  64838. /**
  64839. * Only error logs
  64840. */
  64841. static readonly ErrorLogLevel: number;
  64842. /**
  64843. * All logs
  64844. */
  64845. static readonly AllLogLevel: number;
  64846. private static _LogCache;
  64847. /**
  64848. * Gets a value indicating the number of loading errors
  64849. * @ignorenaming
  64850. */
  64851. static errorsCount: number;
  64852. /**
  64853. * Callback called when a new log is added
  64854. */
  64855. static OnNewCacheEntry: (entry: string) => void;
  64856. private static _AddLogEntry;
  64857. private static _FormatMessage;
  64858. private static _LogDisabled;
  64859. private static _LogEnabled;
  64860. private static _WarnDisabled;
  64861. private static _WarnEnabled;
  64862. private static _ErrorDisabled;
  64863. private static _ErrorEnabled;
  64864. /**
  64865. * Log a message to the console
  64866. */
  64867. static Log: (message: string) => void;
  64868. /**
  64869. * Write a warning message to the console
  64870. */
  64871. static Warn: (message: string) => void;
  64872. /**
  64873. * Write an error message to the console
  64874. */
  64875. static Error: (message: string) => void;
  64876. /**
  64877. * Gets current log cache (list of logs)
  64878. */
  64879. static readonly LogCache: string;
  64880. /**
  64881. * Clears the log cache
  64882. */
  64883. static ClearLogCache(): void;
  64884. /**
  64885. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64886. */
  64887. static LogLevels: number;
  64888. }
  64889. }
  64890. declare module BABYLON {
  64891. /** @hidden */
  64892. export class _TypeStore {
  64893. /** @hidden */
  64894. static RegisteredTypes: {
  64895. [key: string]: Object;
  64896. };
  64897. /** @hidden */
  64898. static GetClass(fqdn: string): any;
  64899. }
  64900. }
  64901. declare module BABYLON {
  64902. /**
  64903. * Class containing a set of static utilities functions for deep copy.
  64904. */
  64905. export class DeepCopier {
  64906. /**
  64907. * Tries to copy an object by duplicating every property
  64908. * @param source defines the source object
  64909. * @param destination defines the target object
  64910. * @param doNotCopyList defines a list of properties to avoid
  64911. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64912. */
  64913. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64914. }
  64915. }
  64916. declare module BABYLON {
  64917. /**
  64918. * Class containing a set of static utilities functions for precision date
  64919. */
  64920. export class PrecisionDate {
  64921. /**
  64922. * Gets either window.performance.now() if supported or Date.now() else
  64923. */
  64924. static readonly Now: number;
  64925. }
  64926. }
  64927. declare module BABYLON {
  64928. /** @hidden */
  64929. export class _DevTools {
  64930. static WarnImport(name: string): string;
  64931. }
  64932. }
  64933. declare module BABYLON {
  64934. /**
  64935. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64936. */
  64937. export class WebRequest {
  64938. private _xhr;
  64939. /**
  64940. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64941. * i.e. when loading files, where the server/service expects an Authorization header
  64942. */
  64943. static CustomRequestHeaders: {
  64944. [key: string]: string;
  64945. };
  64946. /**
  64947. * Add callback functions in this array to update all the requests before they get sent to the network
  64948. */
  64949. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64950. private _injectCustomRequestHeaders;
  64951. /**
  64952. * Gets or sets a function to be called when loading progress changes
  64953. */
  64954. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64955. /**
  64956. * Returns client's state
  64957. */
  64958. readonly readyState: number;
  64959. /**
  64960. * Returns client's status
  64961. */
  64962. readonly status: number;
  64963. /**
  64964. * Returns client's status as a text
  64965. */
  64966. readonly statusText: string;
  64967. /**
  64968. * Returns client's response
  64969. */
  64970. readonly response: any;
  64971. /**
  64972. * Returns client's response url
  64973. */
  64974. readonly responseURL: string;
  64975. /**
  64976. * Returns client's response as text
  64977. */
  64978. readonly responseText: string;
  64979. /**
  64980. * Gets or sets the expected response type
  64981. */
  64982. responseType: XMLHttpRequestResponseType;
  64983. /** @hidden */
  64984. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64985. /** @hidden */
  64986. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64987. /**
  64988. * Cancels any network activity
  64989. */
  64990. abort(): void;
  64991. /**
  64992. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64993. * @param body defines an optional request body
  64994. */
  64995. send(body?: Document | BodyInit | null): void;
  64996. /**
  64997. * Sets the request method, request URL
  64998. * @param method defines the method to use (GET, POST, etc..)
  64999. * @param url defines the url to connect with
  65000. */
  65001. open(method: string, url: string): void;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * File request interface
  65007. */
  65008. export interface IFileRequest {
  65009. /**
  65010. * Raised when the request is complete (success or error).
  65011. */
  65012. onCompleteObservable: Observable<IFileRequest>;
  65013. /**
  65014. * Aborts the request for a file.
  65015. */
  65016. abort: () => void;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65022. */
  65023. export class PerformanceMonitor {
  65024. private _enabled;
  65025. private _rollingFrameTime;
  65026. private _lastFrameTimeMs;
  65027. /**
  65028. * constructor
  65029. * @param frameSampleSize The number of samples required to saturate the sliding window
  65030. */
  65031. constructor(frameSampleSize?: number);
  65032. /**
  65033. * Samples current frame
  65034. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65035. */
  65036. sampleFrame(timeMs?: number): void;
  65037. /**
  65038. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65039. */
  65040. readonly averageFrameTime: number;
  65041. /**
  65042. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65043. */
  65044. readonly averageFrameTimeVariance: number;
  65045. /**
  65046. * Returns the frame time of the most recent frame
  65047. */
  65048. readonly instantaneousFrameTime: number;
  65049. /**
  65050. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65051. */
  65052. readonly averageFPS: number;
  65053. /**
  65054. * Returns the average framerate in frames per second using the most recent frame time
  65055. */
  65056. readonly instantaneousFPS: number;
  65057. /**
  65058. * Returns true if enough samples have been taken to completely fill the sliding window
  65059. */
  65060. readonly isSaturated: boolean;
  65061. /**
  65062. * Enables contributions to the sliding window sample set
  65063. */
  65064. enable(): void;
  65065. /**
  65066. * Disables contributions to the sliding window sample set
  65067. * Samples will not be interpolated over the disabled period
  65068. */
  65069. disable(): void;
  65070. /**
  65071. * Returns true if sampling is enabled
  65072. */
  65073. readonly isEnabled: boolean;
  65074. /**
  65075. * Resets performance monitor
  65076. */
  65077. reset(): void;
  65078. }
  65079. /**
  65080. * RollingAverage
  65081. *
  65082. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65083. */
  65084. export class RollingAverage {
  65085. /**
  65086. * Current average
  65087. */
  65088. average: number;
  65089. /**
  65090. * Current variance
  65091. */
  65092. variance: number;
  65093. protected _samples: Array<number>;
  65094. protected _sampleCount: number;
  65095. protected _pos: number;
  65096. protected _m2: number;
  65097. /**
  65098. * constructor
  65099. * @param length The number of samples required to saturate the sliding window
  65100. */
  65101. constructor(length: number);
  65102. /**
  65103. * Adds a sample to the sample set
  65104. * @param v The sample value
  65105. */
  65106. add(v: number): void;
  65107. /**
  65108. * Returns previously added values or null if outside of history or outside the sliding window domain
  65109. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65110. * @return Value previously recorded with add() or null if outside of range
  65111. */
  65112. history(i: number): number;
  65113. /**
  65114. * Returns true if enough samples have been taken to completely fill the sliding window
  65115. * @return true if sample-set saturated
  65116. */
  65117. isSaturated(): boolean;
  65118. /**
  65119. * Resets the rolling average (equivalent to 0 samples taken so far)
  65120. */
  65121. reset(): void;
  65122. /**
  65123. * Wraps a value around the sample range boundaries
  65124. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65125. * @return Wrapped position in sample range
  65126. */
  65127. protected _wrapPosition(i: number): number;
  65128. }
  65129. }
  65130. declare module BABYLON {
  65131. /**
  65132. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65133. * The underlying implementation relies on an associative array to ensure the best performances.
  65134. * The value can be anything including 'null' but except 'undefined'
  65135. */
  65136. export class StringDictionary<T> {
  65137. /**
  65138. * This will clear this dictionary and copy the content from the 'source' one.
  65139. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65140. * @param source the dictionary to take the content from and copy to this dictionary
  65141. */
  65142. copyFrom(source: StringDictionary<T>): void;
  65143. /**
  65144. * Get a value based from its key
  65145. * @param key the given key to get the matching value from
  65146. * @return the value if found, otherwise undefined is returned
  65147. */
  65148. get(key: string): T | undefined;
  65149. /**
  65150. * Get a value from its key or add it if it doesn't exist.
  65151. * This method will ensure you that a given key/data will be present in the dictionary.
  65152. * @param key the given key to get the matching value from
  65153. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65154. * The factory will only be invoked if there's no data for the given key.
  65155. * @return the value corresponding to the key.
  65156. */
  65157. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65158. /**
  65159. * Get a value from its key if present in the dictionary otherwise add it
  65160. * @param key the key to get the value from
  65161. * @param val if there's no such key/value pair in the dictionary add it with this value
  65162. * @return the value corresponding to the key
  65163. */
  65164. getOrAdd(key: string, val: T): T;
  65165. /**
  65166. * Check if there's a given key in the dictionary
  65167. * @param key the key to check for
  65168. * @return true if the key is present, false otherwise
  65169. */
  65170. contains(key: string): boolean;
  65171. /**
  65172. * Add a new key and its corresponding value
  65173. * @param key the key to add
  65174. * @param value the value corresponding to the key
  65175. * @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
  65176. */
  65177. add(key: string, value: T): boolean;
  65178. /**
  65179. * Update a specific value associated to a key
  65180. * @param key defines the key to use
  65181. * @param value defines the value to store
  65182. * @returns true if the value was updated (or false if the key was not found)
  65183. */
  65184. set(key: string, value: T): boolean;
  65185. /**
  65186. * Get the element of the given key and remove it from the dictionary
  65187. * @param key defines the key to search
  65188. * @returns the value associated with the key or null if not found
  65189. */
  65190. getAndRemove(key: string): Nullable<T>;
  65191. /**
  65192. * Remove a key/value from the dictionary.
  65193. * @param key the key to remove
  65194. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65195. */
  65196. remove(key: string): boolean;
  65197. /**
  65198. * Clear the whole content of the dictionary
  65199. */
  65200. clear(): void;
  65201. /**
  65202. * Gets the current count
  65203. */
  65204. readonly count: number;
  65205. /**
  65206. * Execute a callback on each key/val of the dictionary.
  65207. * Note that you can remove any element in this dictionary in the callback implementation
  65208. * @param callback the callback to execute on a given key/value pair
  65209. */
  65210. forEach(callback: (key: string, val: T) => void): void;
  65211. /**
  65212. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65213. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65214. * Note that you can remove any element in this dictionary in the callback implementation
  65215. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65216. * @returns the first item
  65217. */
  65218. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65219. private _count;
  65220. private _data;
  65221. }
  65222. }
  65223. declare module BABYLON {
  65224. /**
  65225. * Class used to store gfx data (like WebGLBuffer)
  65226. */
  65227. export class DataBuffer {
  65228. /**
  65229. * Gets or sets the number of objects referencing this buffer
  65230. */
  65231. references: number;
  65232. /** Gets or sets the size of the underlying buffer */
  65233. capacity: number;
  65234. /**
  65235. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65236. */
  65237. is32Bits: boolean;
  65238. /**
  65239. * Gets the underlying buffer
  65240. */
  65241. readonly underlyingResource: any;
  65242. }
  65243. }
  65244. declare module BABYLON {
  65245. /**
  65246. * Class used to store data that will be store in GPU memory
  65247. */
  65248. export class Buffer {
  65249. private _engine;
  65250. private _buffer;
  65251. /** @hidden */
  65252. _data: Nullable<DataArray>;
  65253. private _updatable;
  65254. private _instanced;
  65255. /**
  65256. * Gets the byte stride.
  65257. */
  65258. readonly byteStride: number;
  65259. /**
  65260. * Constructor
  65261. * @param engine the engine
  65262. * @param data the data to use for this buffer
  65263. * @param updatable whether the data is updatable
  65264. * @param stride the stride (optional)
  65265. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65266. * @param instanced whether the buffer is instanced (optional)
  65267. * @param useBytes set to true if the stride in in bytes (optional)
  65268. */
  65269. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65270. /**
  65271. * Create a new VertexBuffer based on the current buffer
  65272. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65273. * @param offset defines offset in the buffer (0 by default)
  65274. * @param size defines the size in floats of attributes (position is 3 for instance)
  65275. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65276. * @param instanced defines if the vertex buffer contains indexed data
  65277. * @param useBytes defines if the offset and stride are in bytes
  65278. * @returns the new vertex buffer
  65279. */
  65280. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65281. /**
  65282. * Gets a boolean indicating if the Buffer is updatable?
  65283. * @returns true if the buffer is updatable
  65284. */
  65285. isUpdatable(): boolean;
  65286. /**
  65287. * Gets current buffer's data
  65288. * @returns a DataArray or null
  65289. */
  65290. getData(): Nullable<DataArray>;
  65291. /**
  65292. * Gets underlying native buffer
  65293. * @returns underlying native buffer
  65294. */
  65295. getBuffer(): Nullable<DataBuffer>;
  65296. /**
  65297. * Gets the stride in float32 units (i.e. byte stride / 4).
  65298. * May not be an integer if the byte stride is not divisible by 4.
  65299. * DEPRECATED. Use byteStride instead.
  65300. * @returns the stride in float32 units
  65301. */
  65302. getStrideSize(): number;
  65303. /**
  65304. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65305. * @param data defines the data to store
  65306. */
  65307. create(data?: Nullable<DataArray>): void;
  65308. /** @hidden */
  65309. _rebuild(): void;
  65310. /**
  65311. * Update current buffer data
  65312. * @param data defines the data to store
  65313. */
  65314. update(data: DataArray): void;
  65315. /**
  65316. * Updates the data directly.
  65317. * @param data the new data
  65318. * @param offset the new offset
  65319. * @param vertexCount the vertex count (optional)
  65320. * @param useBytes set to true if the offset is in bytes
  65321. */
  65322. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65323. /**
  65324. * Release all resources
  65325. */
  65326. dispose(): void;
  65327. }
  65328. /**
  65329. * Specialized buffer used to store vertex data
  65330. */
  65331. export class VertexBuffer {
  65332. /** @hidden */
  65333. _buffer: Buffer;
  65334. private _kind;
  65335. private _size;
  65336. private _ownsBuffer;
  65337. private _instanced;
  65338. private _instanceDivisor;
  65339. /**
  65340. * The byte type.
  65341. */
  65342. static readonly BYTE: number;
  65343. /**
  65344. * The unsigned byte type.
  65345. */
  65346. static readonly UNSIGNED_BYTE: number;
  65347. /**
  65348. * The short type.
  65349. */
  65350. static readonly SHORT: number;
  65351. /**
  65352. * The unsigned short type.
  65353. */
  65354. static readonly UNSIGNED_SHORT: number;
  65355. /**
  65356. * The integer type.
  65357. */
  65358. static readonly INT: number;
  65359. /**
  65360. * The unsigned integer type.
  65361. */
  65362. static readonly UNSIGNED_INT: number;
  65363. /**
  65364. * The float type.
  65365. */
  65366. static readonly FLOAT: number;
  65367. /**
  65368. * Gets or sets the instance divisor when in instanced mode
  65369. */
  65370. instanceDivisor: number;
  65371. /**
  65372. * Gets the byte stride.
  65373. */
  65374. readonly byteStride: number;
  65375. /**
  65376. * Gets the byte offset.
  65377. */
  65378. readonly byteOffset: number;
  65379. /**
  65380. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65381. */
  65382. readonly normalized: boolean;
  65383. /**
  65384. * Gets the data type of each component in the array.
  65385. */
  65386. readonly type: number;
  65387. /**
  65388. * Constructor
  65389. * @param engine the engine
  65390. * @param data the data to use for this vertex buffer
  65391. * @param kind the vertex buffer kind
  65392. * @param updatable whether the data is updatable
  65393. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65394. * @param stride the stride (optional)
  65395. * @param instanced whether the buffer is instanced (optional)
  65396. * @param offset the offset of the data (optional)
  65397. * @param size the number of components (optional)
  65398. * @param type the type of the component (optional)
  65399. * @param normalized whether the data contains normalized data (optional)
  65400. * @param useBytes set to true if stride and offset are in bytes (optional)
  65401. */
  65402. 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);
  65403. /** @hidden */
  65404. _rebuild(): void;
  65405. /**
  65406. * Returns the kind of the VertexBuffer (string)
  65407. * @returns a string
  65408. */
  65409. getKind(): string;
  65410. /**
  65411. * Gets a boolean indicating if the VertexBuffer is updatable?
  65412. * @returns true if the buffer is updatable
  65413. */
  65414. isUpdatable(): boolean;
  65415. /**
  65416. * Gets current buffer's data
  65417. * @returns a DataArray or null
  65418. */
  65419. getData(): Nullable<DataArray>;
  65420. /**
  65421. * Gets underlying native buffer
  65422. * @returns underlying native buffer
  65423. */
  65424. getBuffer(): Nullable<DataBuffer>;
  65425. /**
  65426. * Gets the stride in float32 units (i.e. byte stride / 4).
  65427. * May not be an integer if the byte stride is not divisible by 4.
  65428. * DEPRECATED. Use byteStride instead.
  65429. * @returns the stride in float32 units
  65430. */
  65431. getStrideSize(): number;
  65432. /**
  65433. * Returns the offset as a multiple of the type byte length.
  65434. * DEPRECATED. Use byteOffset instead.
  65435. * @returns the offset in bytes
  65436. */
  65437. getOffset(): number;
  65438. /**
  65439. * Returns the number of components per vertex attribute (integer)
  65440. * @returns the size in float
  65441. */
  65442. getSize(): number;
  65443. /**
  65444. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65445. * @returns true if this buffer is instanced
  65446. */
  65447. getIsInstanced(): boolean;
  65448. /**
  65449. * Returns the instancing divisor, zero for non-instanced (integer).
  65450. * @returns a number
  65451. */
  65452. getInstanceDivisor(): number;
  65453. /**
  65454. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65455. * @param data defines the data to store
  65456. */
  65457. create(data?: DataArray): void;
  65458. /**
  65459. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65460. * This function will create a new buffer if the current one is not updatable
  65461. * @param data defines the data to store
  65462. */
  65463. update(data: DataArray): void;
  65464. /**
  65465. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65466. * Returns the directly updated WebGLBuffer.
  65467. * @param data the new data
  65468. * @param offset the new offset
  65469. * @param useBytes set to true if the offset is in bytes
  65470. */
  65471. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65472. /**
  65473. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65474. */
  65475. dispose(): void;
  65476. /**
  65477. * Enumerates each value of this vertex buffer as numbers.
  65478. * @param count the number of values to enumerate
  65479. * @param callback the callback function called for each value
  65480. */
  65481. forEach(count: number, callback: (value: number, index: number) => void): void;
  65482. /**
  65483. * Positions
  65484. */
  65485. static readonly PositionKind: string;
  65486. /**
  65487. * Normals
  65488. */
  65489. static readonly NormalKind: string;
  65490. /**
  65491. * Tangents
  65492. */
  65493. static readonly TangentKind: string;
  65494. /**
  65495. * Texture coordinates
  65496. */
  65497. static readonly UVKind: string;
  65498. /**
  65499. * Texture coordinates 2
  65500. */
  65501. static readonly UV2Kind: string;
  65502. /**
  65503. * Texture coordinates 3
  65504. */
  65505. static readonly UV3Kind: string;
  65506. /**
  65507. * Texture coordinates 4
  65508. */
  65509. static readonly UV4Kind: string;
  65510. /**
  65511. * Texture coordinates 5
  65512. */
  65513. static readonly UV5Kind: string;
  65514. /**
  65515. * Texture coordinates 6
  65516. */
  65517. static readonly UV6Kind: string;
  65518. /**
  65519. * Colors
  65520. */
  65521. static readonly ColorKind: string;
  65522. /**
  65523. * Matrix indices (for bones)
  65524. */
  65525. static readonly MatricesIndicesKind: string;
  65526. /**
  65527. * Matrix weights (for bones)
  65528. */
  65529. static readonly MatricesWeightsKind: string;
  65530. /**
  65531. * Additional matrix indices (for bones)
  65532. */
  65533. static readonly MatricesIndicesExtraKind: string;
  65534. /**
  65535. * Additional matrix weights (for bones)
  65536. */
  65537. static readonly MatricesWeightsExtraKind: string;
  65538. /**
  65539. * Deduces the stride given a kind.
  65540. * @param kind The kind string to deduce
  65541. * @returns The deduced stride
  65542. */
  65543. static DeduceStride(kind: string): number;
  65544. /**
  65545. * Gets the byte length of the given type.
  65546. * @param type the type
  65547. * @returns the number of bytes
  65548. */
  65549. static GetTypeByteLength(type: number): number;
  65550. /**
  65551. * Enumerates each value of the given parameters as numbers.
  65552. * @param data the data to enumerate
  65553. * @param byteOffset the byte offset of the data
  65554. * @param byteStride the byte stride of the data
  65555. * @param componentCount the number of components per element
  65556. * @param componentType the type of the component
  65557. * @param count the number of values to enumerate
  65558. * @param normalized whether the data is normalized
  65559. * @param callback the callback function called for each value
  65560. */
  65561. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65562. private static _GetFloatValue;
  65563. }
  65564. }
  65565. declare module BABYLON {
  65566. /**
  65567. * Scalar computation library
  65568. */
  65569. export class Scalar {
  65570. /**
  65571. * Two pi constants convenient for computation.
  65572. */
  65573. static TwoPi: number;
  65574. /**
  65575. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65576. * @param a number
  65577. * @param b number
  65578. * @param epsilon (default = 1.401298E-45)
  65579. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65580. */
  65581. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65582. /**
  65583. * Returns a string : the upper case translation of the number i to hexadecimal.
  65584. * @param i number
  65585. * @returns the upper case translation of the number i to hexadecimal.
  65586. */
  65587. static ToHex(i: number): string;
  65588. /**
  65589. * Returns -1 if value is negative and +1 is value is positive.
  65590. * @param value the value
  65591. * @returns the value itself if it's equal to zero.
  65592. */
  65593. static Sign(value: number): number;
  65594. /**
  65595. * Returns the value itself if it's between min and max.
  65596. * Returns min if the value is lower than min.
  65597. * Returns max if the value is greater than max.
  65598. * @param value the value to clmap
  65599. * @param min the min value to clamp to (default: 0)
  65600. * @param max the max value to clamp to (default: 1)
  65601. * @returns the clamped value
  65602. */
  65603. static Clamp(value: number, min?: number, max?: number): number;
  65604. /**
  65605. * the log2 of value.
  65606. * @param value the value to compute log2 of
  65607. * @returns the log2 of value.
  65608. */
  65609. static Log2(value: number): number;
  65610. /**
  65611. * Loops the value, so that it is never larger than length and never smaller than 0.
  65612. *
  65613. * This is similar to the modulo operator but it works with floating point numbers.
  65614. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65615. * With t = 5 and length = 2.5, the result would be 0.0.
  65616. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65617. * @param value the value
  65618. * @param length the length
  65619. * @returns the looped value
  65620. */
  65621. static Repeat(value: number, length: number): number;
  65622. /**
  65623. * Normalize the value between 0.0 and 1.0 using min and max values
  65624. * @param value value to normalize
  65625. * @param min max to normalize between
  65626. * @param max min to normalize between
  65627. * @returns the normalized value
  65628. */
  65629. static Normalize(value: number, min: number, max: number): number;
  65630. /**
  65631. * Denormalize the value from 0.0 and 1.0 using min and max values
  65632. * @param normalized value to denormalize
  65633. * @param min max to denormalize between
  65634. * @param max min to denormalize between
  65635. * @returns the denormalized value
  65636. */
  65637. static Denormalize(normalized: number, min: number, max: number): number;
  65638. /**
  65639. * Calculates the shortest difference between two given angles given in degrees.
  65640. * @param current current angle in degrees
  65641. * @param target target angle in degrees
  65642. * @returns the delta
  65643. */
  65644. static DeltaAngle(current: number, target: number): number;
  65645. /**
  65646. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65647. * @param tx value
  65648. * @param length length
  65649. * @returns The returned value will move back and forth between 0 and length
  65650. */
  65651. static PingPong(tx: number, length: number): number;
  65652. /**
  65653. * Interpolates between min and max with smoothing at the limits.
  65654. *
  65655. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65656. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65657. * @param from from
  65658. * @param to to
  65659. * @param tx value
  65660. * @returns the smooth stepped value
  65661. */
  65662. static SmoothStep(from: number, to: number, tx: number): number;
  65663. /**
  65664. * Moves a value current towards target.
  65665. *
  65666. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65667. * Negative values of maxDelta pushes the value away from target.
  65668. * @param current current value
  65669. * @param target target value
  65670. * @param maxDelta max distance to move
  65671. * @returns resulting value
  65672. */
  65673. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65674. /**
  65675. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65676. *
  65677. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65678. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65679. * @param current current value
  65680. * @param target target value
  65681. * @param maxDelta max distance to move
  65682. * @returns resulting angle
  65683. */
  65684. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65685. /**
  65686. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65687. * @param start start value
  65688. * @param end target value
  65689. * @param amount amount to lerp between
  65690. * @returns the lerped value
  65691. */
  65692. static Lerp(start: number, end: number, amount: number): number;
  65693. /**
  65694. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65695. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65696. * @param start start value
  65697. * @param end target value
  65698. * @param amount amount to lerp between
  65699. * @returns the lerped value
  65700. */
  65701. static LerpAngle(start: number, end: number, amount: number): number;
  65702. /**
  65703. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65704. * @param a start value
  65705. * @param b target value
  65706. * @param value value between a and b
  65707. * @returns the inverseLerp value
  65708. */
  65709. static InverseLerp(a: number, b: number, value: number): number;
  65710. /**
  65711. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65712. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65713. * @param value1 spline value
  65714. * @param tangent1 spline value
  65715. * @param value2 spline value
  65716. * @param tangent2 spline value
  65717. * @param amount input value
  65718. * @returns hermite result
  65719. */
  65720. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65721. /**
  65722. * Returns a random float number between and min and max values
  65723. * @param min min value of random
  65724. * @param max max value of random
  65725. * @returns random value
  65726. */
  65727. static RandomRange(min: number, max: number): number;
  65728. /**
  65729. * This function returns percentage of a number in a given range.
  65730. *
  65731. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65732. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65733. * @param number to convert to percentage
  65734. * @param min min range
  65735. * @param max max range
  65736. * @returns the percentage
  65737. */
  65738. static RangeToPercent(number: number, min: number, max: number): number;
  65739. /**
  65740. * This function returns number that corresponds to the percentage in a given range.
  65741. *
  65742. * PercentToRange(0.34,0,100) will return 34.
  65743. * @param percent to convert to number
  65744. * @param min min range
  65745. * @param max max range
  65746. * @returns the number
  65747. */
  65748. static PercentToRange(percent: number, min: number, max: number): number;
  65749. /**
  65750. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65751. * @param angle The angle to normalize in radian.
  65752. * @return The converted angle.
  65753. */
  65754. static NormalizeRadians(angle: number): number;
  65755. }
  65756. }
  65757. declare module BABYLON {
  65758. /**
  65759. * Constant used to convert a value to gamma space
  65760. * @ignorenaming
  65761. */
  65762. export const ToGammaSpace: number;
  65763. /**
  65764. * Constant used to convert a value to linear space
  65765. * @ignorenaming
  65766. */
  65767. export const ToLinearSpace = 2.2;
  65768. /**
  65769. * Constant used to define the minimal number value in Babylon.js
  65770. * @ignorenaming
  65771. */
  65772. let Epsilon: number;
  65773. }
  65774. declare module BABYLON {
  65775. /**
  65776. * Class used to represent a viewport on screen
  65777. */
  65778. export class Viewport {
  65779. /** viewport left coordinate */
  65780. x: number;
  65781. /** viewport top coordinate */
  65782. y: number;
  65783. /**viewport width */
  65784. width: number;
  65785. /** viewport height */
  65786. height: number;
  65787. /**
  65788. * Creates a Viewport object located at (x, y) and sized (width, height)
  65789. * @param x defines viewport left coordinate
  65790. * @param y defines viewport top coordinate
  65791. * @param width defines the viewport width
  65792. * @param height defines the viewport height
  65793. */
  65794. constructor(
  65795. /** viewport left coordinate */
  65796. x: number,
  65797. /** viewport top coordinate */
  65798. y: number,
  65799. /**viewport width */
  65800. width: number,
  65801. /** viewport height */
  65802. height: number);
  65803. /**
  65804. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65805. * @param renderWidth defines the rendering width
  65806. * @param renderHeight defines the rendering height
  65807. * @returns a new Viewport
  65808. */
  65809. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65810. /**
  65811. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65812. * @param renderWidth defines the rendering width
  65813. * @param renderHeight defines the rendering height
  65814. * @param ref defines the target viewport
  65815. * @returns the current viewport
  65816. */
  65817. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65818. /**
  65819. * Returns a new Viewport copied from the current one
  65820. * @returns a new Viewport
  65821. */
  65822. clone(): Viewport;
  65823. }
  65824. }
  65825. declare module BABYLON {
  65826. /**
  65827. * Class containing a set of static utilities functions for arrays.
  65828. */
  65829. export class ArrayTools {
  65830. /**
  65831. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65832. * @param size the number of element to construct and put in the array
  65833. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65834. * @returns a new array filled with new objects
  65835. */
  65836. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65837. }
  65838. }
  65839. declare module BABYLON {
  65840. /**
  65841. * @hidden
  65842. */
  65843. export interface IColor4Like {
  65844. r: float;
  65845. g: float;
  65846. b: float;
  65847. a: float;
  65848. }
  65849. /**
  65850. * @hidden
  65851. */
  65852. export interface IColor3Like {
  65853. r: float;
  65854. g: float;
  65855. b: float;
  65856. }
  65857. /**
  65858. * @hidden
  65859. */
  65860. export interface IVector4Like {
  65861. x: float;
  65862. y: float;
  65863. z: float;
  65864. w: float;
  65865. }
  65866. /**
  65867. * @hidden
  65868. */
  65869. export interface IVector3Like {
  65870. x: float;
  65871. y: float;
  65872. z: float;
  65873. }
  65874. /**
  65875. * @hidden
  65876. */
  65877. export interface IVector2Like {
  65878. x: float;
  65879. y: float;
  65880. }
  65881. /**
  65882. * @hidden
  65883. */
  65884. export interface IMatrixLike {
  65885. toArray(): DeepImmutable<Float32Array>;
  65886. updateFlag: int;
  65887. }
  65888. /**
  65889. * @hidden
  65890. */
  65891. export interface IViewportLike {
  65892. x: float;
  65893. y: float;
  65894. width: float;
  65895. height: float;
  65896. }
  65897. /**
  65898. * @hidden
  65899. */
  65900. export interface IPlaneLike {
  65901. normal: IVector3Like;
  65902. d: float;
  65903. normalize(): void;
  65904. }
  65905. }
  65906. declare module BABYLON {
  65907. /**
  65908. * Class representing a vector containing 2 coordinates
  65909. */
  65910. export class Vector2 {
  65911. /** defines the first coordinate */
  65912. x: number;
  65913. /** defines the second coordinate */
  65914. y: number;
  65915. /**
  65916. * Creates a new Vector2 from the given x and y coordinates
  65917. * @param x defines the first coordinate
  65918. * @param y defines the second coordinate
  65919. */
  65920. constructor(
  65921. /** defines the first coordinate */
  65922. x?: number,
  65923. /** defines the second coordinate */
  65924. y?: number);
  65925. /**
  65926. * Gets a string with the Vector2 coordinates
  65927. * @returns a string with the Vector2 coordinates
  65928. */
  65929. toString(): string;
  65930. /**
  65931. * Gets class name
  65932. * @returns the string "Vector2"
  65933. */
  65934. getClassName(): string;
  65935. /**
  65936. * Gets current vector hash code
  65937. * @returns the Vector2 hash code as a number
  65938. */
  65939. getHashCode(): number;
  65940. /**
  65941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65942. * @param array defines the source array
  65943. * @param index defines the offset in source array
  65944. * @returns the current Vector2
  65945. */
  65946. toArray(array: FloatArray, index?: number): Vector2;
  65947. /**
  65948. * Copy the current vector to an array
  65949. * @returns a new array with 2 elements: the Vector2 coordinates.
  65950. */
  65951. asArray(): number[];
  65952. /**
  65953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65954. * @param source defines the source Vector2
  65955. * @returns the current updated Vector2
  65956. */
  65957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65958. /**
  65959. * Sets the Vector2 coordinates with the given floats
  65960. * @param x defines the first coordinate
  65961. * @param y defines the second coordinate
  65962. * @returns the current updated Vector2
  65963. */
  65964. copyFromFloats(x: number, y: number): Vector2;
  65965. /**
  65966. * Sets the Vector2 coordinates with the given floats
  65967. * @param x defines the first coordinate
  65968. * @param y defines the second coordinate
  65969. * @returns the current updated Vector2
  65970. */
  65971. set(x: number, y: number): Vector2;
  65972. /**
  65973. * Add another vector with the current one
  65974. * @param otherVector defines the other vector
  65975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65976. */
  65977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65978. /**
  65979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65980. * @param otherVector defines the other vector
  65981. * @param result defines the target vector
  65982. * @returns the unmodified current Vector2
  65983. */
  65984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65985. /**
  65986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65987. * @param otherVector defines the other vector
  65988. * @returns the current updated Vector2
  65989. */
  65990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65991. /**
  65992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65993. * @param otherVector defines the other vector
  65994. * @returns a new Vector2
  65995. */
  65996. addVector3(otherVector: Vector3): Vector2;
  65997. /**
  65998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65999. * @param otherVector defines the other vector
  66000. * @returns a new Vector2
  66001. */
  66002. subtract(otherVector: Vector2): Vector2;
  66003. /**
  66004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66005. * @param otherVector defines the other vector
  66006. * @param result defines the target vector
  66007. * @returns the unmodified current Vector2
  66008. */
  66009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66010. /**
  66011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66012. * @param otherVector defines the other vector
  66013. * @returns the current updated Vector2
  66014. */
  66015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66016. /**
  66017. * Multiplies in place the current Vector2 coordinates by the given ones
  66018. * @param otherVector defines the other vector
  66019. * @returns the current updated Vector2
  66020. */
  66021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66022. /**
  66023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66024. * @param otherVector defines the other vector
  66025. * @returns a new Vector2
  66026. */
  66027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66028. /**
  66029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66030. * @param otherVector defines the other vector
  66031. * @param result defines the target vector
  66032. * @returns the unmodified current Vector2
  66033. */
  66034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66035. /**
  66036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66037. * @param x defines the first coordinate
  66038. * @param y defines the second coordinate
  66039. * @returns a new Vector2
  66040. */
  66041. multiplyByFloats(x: number, y: number): Vector2;
  66042. /**
  66043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66044. * @param otherVector defines the other vector
  66045. * @returns a new Vector2
  66046. */
  66047. divide(otherVector: Vector2): Vector2;
  66048. /**
  66049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66050. * @param otherVector defines the other vector
  66051. * @param result defines the target vector
  66052. * @returns the unmodified current Vector2
  66053. */
  66054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66055. /**
  66056. * Divides the current Vector2 coordinates by the given ones
  66057. * @param otherVector defines the other vector
  66058. * @returns the current updated Vector2
  66059. */
  66060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66061. /**
  66062. * Gets a new Vector2 with current Vector2 negated coordinates
  66063. * @returns a new Vector2
  66064. */
  66065. negate(): Vector2;
  66066. /**
  66067. * Multiply the Vector2 coordinates by scale
  66068. * @param scale defines the scaling factor
  66069. * @returns the current updated Vector2
  66070. */
  66071. scaleInPlace(scale: number): Vector2;
  66072. /**
  66073. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66074. * @param scale defines the scaling factor
  66075. * @returns a new Vector2
  66076. */
  66077. scale(scale: number): Vector2;
  66078. /**
  66079. * Scale the current Vector2 values by a factor to a given Vector2
  66080. * @param scale defines the scale factor
  66081. * @param result defines the Vector2 object where to store the result
  66082. * @returns the unmodified current Vector2
  66083. */
  66084. scaleToRef(scale: number, result: Vector2): Vector2;
  66085. /**
  66086. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66087. * @param scale defines the scale factor
  66088. * @param result defines the Vector2 object where to store the result
  66089. * @returns the unmodified current Vector2
  66090. */
  66091. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66092. /**
  66093. * Gets a boolean if two vectors are equals
  66094. * @param otherVector defines the other vector
  66095. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66096. */
  66097. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66098. /**
  66099. * Gets a boolean if two vectors are equals (using an epsilon value)
  66100. * @param otherVector defines the other vector
  66101. * @param epsilon defines the minimal distance to consider equality
  66102. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66103. */
  66104. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66105. /**
  66106. * Gets a new Vector2 from current Vector2 floored values
  66107. * @returns a new Vector2
  66108. */
  66109. floor(): Vector2;
  66110. /**
  66111. * Gets a new Vector2 from current Vector2 floored values
  66112. * @returns a new Vector2
  66113. */
  66114. fract(): Vector2;
  66115. /**
  66116. * Gets the length of the vector
  66117. * @returns the vector length (float)
  66118. */
  66119. length(): number;
  66120. /**
  66121. * Gets the vector squared length
  66122. * @returns the vector squared length (float)
  66123. */
  66124. lengthSquared(): number;
  66125. /**
  66126. * Normalize the vector
  66127. * @returns the current updated Vector2
  66128. */
  66129. normalize(): Vector2;
  66130. /**
  66131. * Gets a new Vector2 copied from the Vector2
  66132. * @returns a new Vector2
  66133. */
  66134. clone(): Vector2;
  66135. /**
  66136. * Gets a new Vector2(0, 0)
  66137. * @returns a new Vector2
  66138. */
  66139. static Zero(): Vector2;
  66140. /**
  66141. * Gets a new Vector2(1, 1)
  66142. * @returns a new Vector2
  66143. */
  66144. static One(): Vector2;
  66145. /**
  66146. * Gets a new Vector2 set from the given index element of the given array
  66147. * @param array defines the data source
  66148. * @param offset defines the offset in the data source
  66149. * @returns a new Vector2
  66150. */
  66151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66152. /**
  66153. * Sets "result" from the given index element of the given array
  66154. * @param array defines the data source
  66155. * @param offset defines the offset in the data source
  66156. * @param result defines the target vector
  66157. */
  66158. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66159. /**
  66160. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66161. * @param value1 defines 1st point of control
  66162. * @param value2 defines 2nd point of control
  66163. * @param value3 defines 3rd point of control
  66164. * @param value4 defines 4th point of control
  66165. * @param amount defines the interpolation factor
  66166. * @returns a new Vector2
  66167. */
  66168. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66169. /**
  66170. * 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".
  66171. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66172. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66173. * @param value defines the value to clamp
  66174. * @param min defines the lower limit
  66175. * @param max defines the upper limit
  66176. * @returns a new Vector2
  66177. */
  66178. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66179. /**
  66180. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66181. * @param value1 defines the 1st control point
  66182. * @param tangent1 defines the outgoing tangent
  66183. * @param value2 defines the 2nd control point
  66184. * @param tangent2 defines the incoming tangent
  66185. * @param amount defines the interpolation factor
  66186. * @returns a new Vector2
  66187. */
  66188. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66189. /**
  66190. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66191. * @param start defines the start vector
  66192. * @param end defines the end vector
  66193. * @param amount defines the interpolation factor
  66194. * @returns a new Vector2
  66195. */
  66196. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66197. /**
  66198. * Gets the dot product of the vector "left" and the vector "right"
  66199. * @param left defines first vector
  66200. * @param right defines second vector
  66201. * @returns the dot product (float)
  66202. */
  66203. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66204. /**
  66205. * Returns a new Vector2 equal to the normalized given vector
  66206. * @param vector defines the vector to normalize
  66207. * @returns a new Vector2
  66208. */
  66209. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66210. /**
  66211. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66212. * @param left defines 1st vector
  66213. * @param right defines 2nd vector
  66214. * @returns a new Vector2
  66215. */
  66216. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66217. /**
  66218. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66219. * @param left defines 1st vector
  66220. * @param right defines 2nd vector
  66221. * @returns a new Vector2
  66222. */
  66223. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66224. /**
  66225. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66226. * @param vector defines the vector to transform
  66227. * @param transformation defines the matrix to apply
  66228. * @returns a new Vector2
  66229. */
  66230. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66231. /**
  66232. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66233. * @param vector defines the vector to transform
  66234. * @param transformation defines the matrix to apply
  66235. * @param result defines the target vector
  66236. */
  66237. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66238. /**
  66239. * Determines if a given vector is included in a triangle
  66240. * @param p defines the vector to test
  66241. * @param p0 defines 1st triangle point
  66242. * @param p1 defines 2nd triangle point
  66243. * @param p2 defines 3rd triangle point
  66244. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66245. */
  66246. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66247. /**
  66248. * Gets the distance between the vectors "value1" and "value2"
  66249. * @param value1 defines first vector
  66250. * @param value2 defines second vector
  66251. * @returns the distance between vectors
  66252. */
  66253. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66254. /**
  66255. * Returns the squared distance between the vectors "value1" and "value2"
  66256. * @param value1 defines first vector
  66257. * @param value2 defines second vector
  66258. * @returns the squared distance between vectors
  66259. */
  66260. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66261. /**
  66262. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66263. * @param value1 defines first vector
  66264. * @param value2 defines second vector
  66265. * @returns a new Vector2
  66266. */
  66267. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66268. /**
  66269. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66270. * @param p defines the middle point
  66271. * @param segA defines one point of the segment
  66272. * @param segB defines the other point of the segment
  66273. * @returns the shortest distance
  66274. */
  66275. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66276. }
  66277. /**
  66278. * Classed used to store (x,y,z) vector representation
  66279. * A Vector3 is the main object used in 3D geometry
  66280. * It can represent etiher the coordinates of a point the space, either a direction
  66281. * Reminder: js uses a left handed forward facing system
  66282. */
  66283. export class Vector3 {
  66284. /**
  66285. * Defines the first coordinates (on X axis)
  66286. */
  66287. x: number;
  66288. /**
  66289. * Defines the second coordinates (on Y axis)
  66290. */
  66291. y: number;
  66292. /**
  66293. * Defines the third coordinates (on Z axis)
  66294. */
  66295. z: number;
  66296. private static _UpReadOnly;
  66297. private static _ZeroReadOnly;
  66298. /**
  66299. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66300. * @param x defines the first coordinates (on X axis)
  66301. * @param y defines the second coordinates (on Y axis)
  66302. * @param z defines the third coordinates (on Z axis)
  66303. */
  66304. constructor(
  66305. /**
  66306. * Defines the first coordinates (on X axis)
  66307. */
  66308. x?: number,
  66309. /**
  66310. * Defines the second coordinates (on Y axis)
  66311. */
  66312. y?: number,
  66313. /**
  66314. * Defines the third coordinates (on Z axis)
  66315. */
  66316. z?: number);
  66317. /**
  66318. * Creates a string representation of the Vector3
  66319. * @returns a string with the Vector3 coordinates.
  66320. */
  66321. toString(): string;
  66322. /**
  66323. * Gets the class name
  66324. * @returns the string "Vector3"
  66325. */
  66326. getClassName(): string;
  66327. /**
  66328. * Creates the Vector3 hash code
  66329. * @returns a number which tends to be unique between Vector3 instances
  66330. */
  66331. getHashCode(): number;
  66332. /**
  66333. * Creates an array containing three elements : the coordinates of the Vector3
  66334. * @returns a new array of numbers
  66335. */
  66336. asArray(): number[];
  66337. /**
  66338. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66339. * @param array defines the destination array
  66340. * @param index defines the offset in the destination array
  66341. * @returns the current Vector3
  66342. */
  66343. toArray(array: FloatArray, index?: number): Vector3;
  66344. /**
  66345. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66346. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66347. */
  66348. toQuaternion(): Quaternion;
  66349. /**
  66350. * Adds the given vector to the current Vector3
  66351. * @param otherVector defines the second operand
  66352. * @returns the current updated Vector3
  66353. */
  66354. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66355. /**
  66356. * Adds the given coordinates to the current Vector3
  66357. * @param x defines the x coordinate of the operand
  66358. * @param y defines the y coordinate of the operand
  66359. * @param z defines the z coordinate of the operand
  66360. * @returns the current updated Vector3
  66361. */
  66362. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66363. /**
  66364. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66365. * @param otherVector defines the second operand
  66366. * @returns the resulting Vector3
  66367. */
  66368. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66369. /**
  66370. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66371. * @param otherVector defines the second operand
  66372. * @param result defines the Vector3 object where to store the result
  66373. * @returns the current Vector3
  66374. */
  66375. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66376. /**
  66377. * Subtract the given vector from the current Vector3
  66378. * @param otherVector defines the second operand
  66379. * @returns the current updated Vector3
  66380. */
  66381. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66382. /**
  66383. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66384. * @param otherVector defines the second operand
  66385. * @returns the resulting Vector3
  66386. */
  66387. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66388. /**
  66389. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66390. * @param otherVector defines the second operand
  66391. * @param result defines the Vector3 object where to store the result
  66392. * @returns the current Vector3
  66393. */
  66394. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66395. /**
  66396. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66397. * @param x defines the x coordinate of the operand
  66398. * @param y defines the y coordinate of the operand
  66399. * @param z defines the z coordinate of the operand
  66400. * @returns the resulting Vector3
  66401. */
  66402. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66403. /**
  66404. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66405. * @param x defines the x coordinate of the operand
  66406. * @param y defines the y coordinate of the operand
  66407. * @param z defines the z coordinate of the operand
  66408. * @param result defines the Vector3 object where to store the result
  66409. * @returns the current Vector3
  66410. */
  66411. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66412. /**
  66413. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66414. * @returns a new Vector3
  66415. */
  66416. negate(): Vector3;
  66417. /**
  66418. * Multiplies the Vector3 coordinates by the float "scale"
  66419. * @param scale defines the multiplier factor
  66420. * @returns the current updated Vector3
  66421. */
  66422. scaleInPlace(scale: number): Vector3;
  66423. /**
  66424. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66425. * @param scale defines the multiplier factor
  66426. * @returns a new Vector3
  66427. */
  66428. scale(scale: number): Vector3;
  66429. /**
  66430. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66431. * @param scale defines the multiplier factor
  66432. * @param result defines the Vector3 object where to store the result
  66433. * @returns the current Vector3
  66434. */
  66435. scaleToRef(scale: number, result: Vector3): Vector3;
  66436. /**
  66437. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66438. * @param scale defines the scale factor
  66439. * @param result defines the Vector3 object where to store the result
  66440. * @returns the unmodified current Vector3
  66441. */
  66442. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66443. /**
  66444. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66445. * @param otherVector defines the second operand
  66446. * @returns true if both vectors are equals
  66447. */
  66448. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66449. /**
  66450. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66451. * @param otherVector defines the second operand
  66452. * @param epsilon defines the minimal distance to define values as equals
  66453. * @returns true if both vectors are distant less than epsilon
  66454. */
  66455. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66456. /**
  66457. * Returns true if the current Vector3 coordinates equals the given floats
  66458. * @param x defines the x coordinate of the operand
  66459. * @param y defines the y coordinate of the operand
  66460. * @param z defines the z coordinate of the operand
  66461. * @returns true if both vectors are equals
  66462. */
  66463. equalsToFloats(x: number, y: number, z: number): boolean;
  66464. /**
  66465. * Multiplies the current Vector3 coordinates by the given ones
  66466. * @param otherVector defines the second operand
  66467. * @returns the current updated Vector3
  66468. */
  66469. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66470. /**
  66471. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66472. * @param otherVector defines the second operand
  66473. * @returns the new Vector3
  66474. */
  66475. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66476. /**
  66477. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66478. * @param otherVector defines the second operand
  66479. * @param result defines the Vector3 object where to store the result
  66480. * @returns the current Vector3
  66481. */
  66482. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66483. /**
  66484. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66485. * @param x defines the x coordinate of the operand
  66486. * @param y defines the y coordinate of the operand
  66487. * @param z defines the z coordinate of the operand
  66488. * @returns the new Vector3
  66489. */
  66490. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66491. /**
  66492. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66493. * @param otherVector defines the second operand
  66494. * @returns the new Vector3
  66495. */
  66496. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66497. /**
  66498. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66499. * @param otherVector defines the second operand
  66500. * @param result defines the Vector3 object where to store the result
  66501. * @returns the current Vector3
  66502. */
  66503. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66504. /**
  66505. * Divides the current Vector3 coordinates by the given ones.
  66506. * @param otherVector defines the second operand
  66507. * @returns the current updated Vector3
  66508. */
  66509. divideInPlace(otherVector: Vector3): Vector3;
  66510. /**
  66511. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66512. * @param other defines the second operand
  66513. * @returns the current updated Vector3
  66514. */
  66515. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66516. /**
  66517. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66518. * @param other defines the second operand
  66519. * @returns the current updated Vector3
  66520. */
  66521. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66522. /**
  66523. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66524. * @param x defines the x coordinate of the operand
  66525. * @param y defines the y coordinate of the operand
  66526. * @param z defines the z coordinate of the operand
  66527. * @returns the current updated Vector3
  66528. */
  66529. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66530. /**
  66531. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66532. * @param x defines the x coordinate of the operand
  66533. * @param y defines the y coordinate of the operand
  66534. * @param z defines the z coordinate of the operand
  66535. * @returns the current updated Vector3
  66536. */
  66537. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66538. /**
  66539. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66540. * Check if is non uniform within a certain amount of decimal places to account for this
  66541. * @param epsilon the amount the values can differ
  66542. * @returns if the the vector is non uniform to a certain number of decimal places
  66543. */
  66544. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66545. /**
  66546. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66547. */
  66548. readonly isNonUniform: boolean;
  66549. /**
  66550. * Gets a new Vector3 from current Vector3 floored values
  66551. * @returns a new Vector3
  66552. */
  66553. floor(): Vector3;
  66554. /**
  66555. * Gets a new Vector3 from current Vector3 floored values
  66556. * @returns a new Vector3
  66557. */
  66558. fract(): Vector3;
  66559. /**
  66560. * Gets the length of the Vector3
  66561. * @returns the length of the Vector3
  66562. */
  66563. length(): number;
  66564. /**
  66565. * Gets the squared length of the Vector3
  66566. * @returns squared length of the Vector3
  66567. */
  66568. lengthSquared(): number;
  66569. /**
  66570. * Normalize the current Vector3.
  66571. * Please note that this is an in place operation.
  66572. * @returns the current updated Vector3
  66573. */
  66574. normalize(): Vector3;
  66575. /**
  66576. * Reorders the x y z properties of the vector in place
  66577. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66578. * @returns the current updated vector
  66579. */
  66580. reorderInPlace(order: string): this;
  66581. /**
  66582. * Rotates the vector around 0,0,0 by a quaternion
  66583. * @param quaternion the rotation quaternion
  66584. * @param result vector to store the result
  66585. * @returns the resulting vector
  66586. */
  66587. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66588. /**
  66589. * Rotates a vector around a given point
  66590. * @param quaternion the rotation quaternion
  66591. * @param point the point to rotate around
  66592. * @param result vector to store the result
  66593. * @returns the resulting vector
  66594. */
  66595. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66596. /**
  66597. * Normalize the current Vector3 with the given input length.
  66598. * Please note that this is an in place operation.
  66599. * @param len the length of the vector
  66600. * @returns the current updated Vector3
  66601. */
  66602. normalizeFromLength(len: number): Vector3;
  66603. /**
  66604. * Normalize the current Vector3 to a new vector
  66605. * @returns the new Vector3
  66606. */
  66607. normalizeToNew(): Vector3;
  66608. /**
  66609. * Normalize the current Vector3 to the reference
  66610. * @param reference define the Vector3 to update
  66611. * @returns the updated Vector3
  66612. */
  66613. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66614. /**
  66615. * Creates a new Vector3 copied from the current Vector3
  66616. * @returns the new Vector3
  66617. */
  66618. clone(): Vector3;
  66619. /**
  66620. * Copies the given vector coordinates to the current Vector3 ones
  66621. * @param source defines the source Vector3
  66622. * @returns the current updated Vector3
  66623. */
  66624. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66625. /**
  66626. * Copies the given floats to the current Vector3 coordinates
  66627. * @param x defines the x coordinate of the operand
  66628. * @param y defines the y coordinate of the operand
  66629. * @param z defines the z coordinate of the operand
  66630. * @returns the current updated Vector3
  66631. */
  66632. copyFromFloats(x: number, y: number, z: number): Vector3;
  66633. /**
  66634. * Copies the given floats to the current Vector3 coordinates
  66635. * @param x defines the x coordinate of the operand
  66636. * @param y defines the y coordinate of the operand
  66637. * @param z defines the z coordinate of the operand
  66638. * @returns the current updated Vector3
  66639. */
  66640. set(x: number, y: number, z: number): Vector3;
  66641. /**
  66642. * Copies the given float to the current Vector3 coordinates
  66643. * @param v defines the x, y and z coordinates of the operand
  66644. * @returns the current updated Vector3
  66645. */
  66646. setAll(v: number): Vector3;
  66647. /**
  66648. * Get the clip factor between two vectors
  66649. * @param vector0 defines the first operand
  66650. * @param vector1 defines the second operand
  66651. * @param axis defines the axis to use
  66652. * @param size defines the size along the axis
  66653. * @returns the clip factor
  66654. */
  66655. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66656. /**
  66657. * Get angle between two vectors
  66658. * @param vector0 angle between vector0 and vector1
  66659. * @param vector1 angle between vector0 and vector1
  66660. * @param normal direction of the normal
  66661. * @return the angle between vector0 and vector1
  66662. */
  66663. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66664. /**
  66665. * Returns a new Vector3 set from the index "offset" of the given array
  66666. * @param array defines the source array
  66667. * @param offset defines the offset in the source array
  66668. * @returns the new Vector3
  66669. */
  66670. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66671. /**
  66672. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66673. * This function is deprecated. Use FromArray instead
  66674. * @param array defines the source array
  66675. * @param offset defines the offset in the source array
  66676. * @returns the new Vector3
  66677. */
  66678. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66679. /**
  66680. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66681. * @param array defines the source array
  66682. * @param offset defines the offset in the source array
  66683. * @param result defines the Vector3 where to store the result
  66684. */
  66685. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66686. /**
  66687. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66688. * This function is deprecated. Use FromArrayToRef instead.
  66689. * @param array defines the source array
  66690. * @param offset defines the offset in the source array
  66691. * @param result defines the Vector3 where to store the result
  66692. */
  66693. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66694. /**
  66695. * Sets the given vector "result" with the given floats.
  66696. * @param x defines the x coordinate of the source
  66697. * @param y defines the y coordinate of the source
  66698. * @param z defines the z coordinate of the source
  66699. * @param result defines the Vector3 where to store the result
  66700. */
  66701. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66702. /**
  66703. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66704. * @returns a new empty Vector3
  66705. */
  66706. static Zero(): Vector3;
  66707. /**
  66708. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66709. * @returns a new unit Vector3
  66710. */
  66711. static One(): Vector3;
  66712. /**
  66713. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66714. * @returns a new up Vector3
  66715. */
  66716. static Up(): Vector3;
  66717. /**
  66718. * Gets a up Vector3 that must not be updated
  66719. */
  66720. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66721. /**
  66722. * Gets a zero Vector3 that must not be updated
  66723. */
  66724. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66725. /**
  66726. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66727. * @returns a new down Vector3
  66728. */
  66729. static Down(): Vector3;
  66730. /**
  66731. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66732. * @returns a new forward Vector3
  66733. */
  66734. static Forward(): Vector3;
  66735. /**
  66736. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66737. * @returns a new forward Vector3
  66738. */
  66739. static Backward(): Vector3;
  66740. /**
  66741. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66742. * @returns a new right Vector3
  66743. */
  66744. static Right(): Vector3;
  66745. /**
  66746. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66747. * @returns a new left Vector3
  66748. */
  66749. static Left(): Vector3;
  66750. /**
  66751. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66752. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66753. * @param vector defines the Vector3 to transform
  66754. * @param transformation defines the transformation matrix
  66755. * @returns the transformed Vector3
  66756. */
  66757. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66758. /**
  66759. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66760. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66761. * @param vector defines the Vector3 to transform
  66762. * @param transformation defines the transformation matrix
  66763. * @param result defines the Vector3 where to store the result
  66764. */
  66765. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66766. /**
  66767. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66768. * This method computes tranformed coordinates only, not transformed direction vectors
  66769. * @param x define the x coordinate of the source vector
  66770. * @param y define the y coordinate of the source vector
  66771. * @param z define the z coordinate of the source vector
  66772. * @param transformation defines the transformation matrix
  66773. * @param result defines the Vector3 where to store the result
  66774. */
  66775. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66776. /**
  66777. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66778. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66779. * @param vector defines the Vector3 to transform
  66780. * @param transformation defines the transformation matrix
  66781. * @returns the new Vector3
  66782. */
  66783. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66784. /**
  66785. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66786. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66787. * @param vector defines the Vector3 to transform
  66788. * @param transformation defines the transformation matrix
  66789. * @param result defines the Vector3 where to store the result
  66790. */
  66791. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66792. /**
  66793. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66794. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66795. * @param x define the x coordinate of the source vector
  66796. * @param y define the y coordinate of the source vector
  66797. * @param z define the z coordinate of the source vector
  66798. * @param transformation defines the transformation matrix
  66799. * @param result defines the Vector3 where to store the result
  66800. */
  66801. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66802. /**
  66803. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66804. * @param value1 defines the first control point
  66805. * @param value2 defines the second control point
  66806. * @param value3 defines the third control point
  66807. * @param value4 defines the fourth control point
  66808. * @param amount defines the amount on the spline to use
  66809. * @returns the new Vector3
  66810. */
  66811. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66812. /**
  66813. * 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"
  66814. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66815. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66816. * @param value defines the current value
  66817. * @param min defines the lower range value
  66818. * @param max defines the upper range value
  66819. * @returns the new Vector3
  66820. */
  66821. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66822. /**
  66823. * 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"
  66824. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66825. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66826. * @param value defines the current value
  66827. * @param min defines the lower range value
  66828. * @param max defines the upper range value
  66829. * @param result defines the Vector3 where to store the result
  66830. */
  66831. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66832. /**
  66833. * Checks if a given vector is inside a specific range
  66834. * @param v defines the vector to test
  66835. * @param min defines the minimum range
  66836. * @param max defines the maximum range
  66837. */
  66838. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66839. /**
  66840. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66841. * @param value1 defines the first control point
  66842. * @param tangent1 defines the first tangent vector
  66843. * @param value2 defines the second control point
  66844. * @param tangent2 defines the second tangent vector
  66845. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66846. * @returns the new Vector3
  66847. */
  66848. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66849. /**
  66850. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66851. * @param start defines the start value
  66852. * @param end defines the end value
  66853. * @param amount max defines amount between both (between 0 and 1)
  66854. * @returns the new Vector3
  66855. */
  66856. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66857. /**
  66858. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66859. * @param start defines the start value
  66860. * @param end defines the end value
  66861. * @param amount max defines amount between both (between 0 and 1)
  66862. * @param result defines the Vector3 where to store the result
  66863. */
  66864. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66865. /**
  66866. * Returns the dot product (float) between the vectors "left" and "right"
  66867. * @param left defines the left operand
  66868. * @param right defines the right operand
  66869. * @returns the dot product
  66870. */
  66871. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66872. /**
  66873. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66874. * The cross product is then orthogonal to both "left" and "right"
  66875. * @param left defines the left operand
  66876. * @param right defines the right operand
  66877. * @returns the cross product
  66878. */
  66879. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66880. /**
  66881. * Sets the given vector "result" with the cross product of "left" and "right"
  66882. * The cross product is then orthogonal to both "left" and "right"
  66883. * @param left defines the left operand
  66884. * @param right defines the right operand
  66885. * @param result defines the Vector3 where to store the result
  66886. */
  66887. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66888. /**
  66889. * Returns a new Vector3 as the normalization of the given vector
  66890. * @param vector defines the Vector3 to normalize
  66891. * @returns the new Vector3
  66892. */
  66893. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66894. /**
  66895. * Sets the given vector "result" with the normalization of the given first vector
  66896. * @param vector defines the Vector3 to normalize
  66897. * @param result defines the Vector3 where to store the result
  66898. */
  66899. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66900. /**
  66901. * Project a Vector3 onto screen space
  66902. * @param vector defines the Vector3 to project
  66903. * @param world defines the world matrix to use
  66904. * @param transform defines the transform (view x projection) matrix to use
  66905. * @param viewport defines the screen viewport to use
  66906. * @returns the new Vector3
  66907. */
  66908. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66909. /** @hidden */
  66910. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66911. /**
  66912. * Unproject from screen space to object space
  66913. * @param source defines the screen space Vector3 to use
  66914. * @param viewportWidth defines the current width of the viewport
  66915. * @param viewportHeight defines the current height of the viewport
  66916. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66917. * @param transform defines the transform (view x projection) matrix to use
  66918. * @returns the new Vector3
  66919. */
  66920. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66921. /**
  66922. * Unproject from screen space to object space
  66923. * @param source defines the screen space Vector3 to use
  66924. * @param viewportWidth defines the current width of the viewport
  66925. * @param viewportHeight defines the current height of the viewport
  66926. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66927. * @param view defines the view matrix to use
  66928. * @param projection defines the projection matrix to use
  66929. * @returns the new Vector3
  66930. */
  66931. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66932. /**
  66933. * Unproject from screen space to object space
  66934. * @param source defines the screen space Vector3 to use
  66935. * @param viewportWidth defines the current width of the viewport
  66936. * @param viewportHeight defines the current height of the viewport
  66937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66938. * @param view defines the view matrix to use
  66939. * @param projection defines the projection matrix to use
  66940. * @param result defines the Vector3 where to store the result
  66941. */
  66942. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66943. /**
  66944. * Unproject from screen space to object space
  66945. * @param sourceX defines the screen space x coordinate to use
  66946. * @param sourceY defines the screen space y coordinate to use
  66947. * @param sourceZ defines the screen space z coordinate to use
  66948. * @param viewportWidth defines the current width of the viewport
  66949. * @param viewportHeight defines the current height of the viewport
  66950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66951. * @param view defines the view matrix to use
  66952. * @param projection defines the projection matrix to use
  66953. * @param result defines the Vector3 where to store the result
  66954. */
  66955. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66956. /**
  66957. * Gets the minimal coordinate values between two Vector3
  66958. * @param left defines the first operand
  66959. * @param right defines the second operand
  66960. * @returns the new Vector3
  66961. */
  66962. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66963. /**
  66964. * Gets the maximal coordinate values between two Vector3
  66965. * @param left defines the first operand
  66966. * @param right defines the second operand
  66967. * @returns the new Vector3
  66968. */
  66969. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66970. /**
  66971. * Returns the distance between the vectors "value1" and "value2"
  66972. * @param value1 defines the first operand
  66973. * @param value2 defines the second operand
  66974. * @returns the distance
  66975. */
  66976. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66977. /**
  66978. * Returns the squared distance between the vectors "value1" and "value2"
  66979. * @param value1 defines the first operand
  66980. * @param value2 defines the second operand
  66981. * @returns the squared distance
  66982. */
  66983. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66984. /**
  66985. * Returns a new Vector3 located at the center between "value1" and "value2"
  66986. * @param value1 defines the first operand
  66987. * @param value2 defines the second operand
  66988. * @returns the new Vector3
  66989. */
  66990. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66991. /**
  66992. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66993. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66994. * to something in order to rotate it from its local system to the given target system
  66995. * Note: axis1, axis2 and axis3 are normalized during this operation
  66996. * @param axis1 defines the first axis
  66997. * @param axis2 defines the second axis
  66998. * @param axis3 defines the third axis
  66999. * @returns a new Vector3
  67000. */
  67001. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67002. /**
  67003. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67004. * @param axis1 defines the first axis
  67005. * @param axis2 defines the second axis
  67006. * @param axis3 defines the third axis
  67007. * @param ref defines the Vector3 where to store the result
  67008. */
  67009. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67010. }
  67011. /**
  67012. * Vector4 class created for EulerAngle class conversion to Quaternion
  67013. */
  67014. export class Vector4 {
  67015. /** x value of the vector */
  67016. x: number;
  67017. /** y value of the vector */
  67018. y: number;
  67019. /** z value of the vector */
  67020. z: number;
  67021. /** w value of the vector */
  67022. w: number;
  67023. /**
  67024. * Creates a Vector4 object from the given floats.
  67025. * @param x x value of the vector
  67026. * @param y y value of the vector
  67027. * @param z z value of the vector
  67028. * @param w w value of the vector
  67029. */
  67030. constructor(
  67031. /** x value of the vector */
  67032. x: number,
  67033. /** y value of the vector */
  67034. y: number,
  67035. /** z value of the vector */
  67036. z: number,
  67037. /** w value of the vector */
  67038. w: number);
  67039. /**
  67040. * Returns the string with the Vector4 coordinates.
  67041. * @returns a string containing all the vector values
  67042. */
  67043. toString(): string;
  67044. /**
  67045. * Returns the string "Vector4".
  67046. * @returns "Vector4"
  67047. */
  67048. getClassName(): string;
  67049. /**
  67050. * Returns the Vector4 hash code.
  67051. * @returns a unique hash code
  67052. */
  67053. getHashCode(): number;
  67054. /**
  67055. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67056. * @returns the resulting array
  67057. */
  67058. asArray(): number[];
  67059. /**
  67060. * Populates the given array from the given index with the Vector4 coordinates.
  67061. * @param array array to populate
  67062. * @param index index of the array to start at (default: 0)
  67063. * @returns the Vector4.
  67064. */
  67065. toArray(array: FloatArray, index?: number): Vector4;
  67066. /**
  67067. * Adds the given vector to the current Vector4.
  67068. * @param otherVector the vector to add
  67069. * @returns the updated Vector4.
  67070. */
  67071. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67072. /**
  67073. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67074. * @param otherVector the vector to add
  67075. * @returns the resulting vector
  67076. */
  67077. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67078. /**
  67079. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67080. * @param otherVector the vector to add
  67081. * @param result the vector to store the result
  67082. * @returns the current Vector4.
  67083. */
  67084. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67085. /**
  67086. * Subtract in place the given vector from the current Vector4.
  67087. * @param otherVector the vector to subtract
  67088. * @returns the updated Vector4.
  67089. */
  67090. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67091. /**
  67092. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67093. * @param otherVector the vector to add
  67094. * @returns the new vector with the result
  67095. */
  67096. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67097. /**
  67098. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67099. * @param otherVector the vector to subtract
  67100. * @param result the vector to store the result
  67101. * @returns the current Vector4.
  67102. */
  67103. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67104. /**
  67105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67106. */
  67107. /**
  67108. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67109. * @param x value to subtract
  67110. * @param y value to subtract
  67111. * @param z value to subtract
  67112. * @param w value to subtract
  67113. * @returns new vector containing the result
  67114. */
  67115. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67116. /**
  67117. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67118. * @param x value to subtract
  67119. * @param y value to subtract
  67120. * @param z value to subtract
  67121. * @param w value to subtract
  67122. * @param result the vector to store the result in
  67123. * @returns the current Vector4.
  67124. */
  67125. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67126. /**
  67127. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67128. * @returns a new vector with the negated values
  67129. */
  67130. negate(): Vector4;
  67131. /**
  67132. * Multiplies the current Vector4 coordinates by scale (float).
  67133. * @param scale the number to scale with
  67134. * @returns the updated Vector4.
  67135. */
  67136. scaleInPlace(scale: number): Vector4;
  67137. /**
  67138. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67139. * @param scale the number to scale with
  67140. * @returns a new vector with the result
  67141. */
  67142. scale(scale: number): Vector4;
  67143. /**
  67144. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67145. * @param scale the number to scale with
  67146. * @param result a vector to store the result in
  67147. * @returns the current Vector4.
  67148. */
  67149. scaleToRef(scale: number, result: Vector4): Vector4;
  67150. /**
  67151. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67152. * @param scale defines the scale factor
  67153. * @param result defines the Vector4 object where to store the result
  67154. * @returns the unmodified current Vector4
  67155. */
  67156. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67157. /**
  67158. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67159. * @param otherVector the vector to compare against
  67160. * @returns true if they are equal
  67161. */
  67162. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67163. /**
  67164. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67165. * @param otherVector vector to compare against
  67166. * @param epsilon (Default: very small number)
  67167. * @returns true if they are equal
  67168. */
  67169. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67170. /**
  67171. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67172. * @param x x value to compare against
  67173. * @param y y value to compare against
  67174. * @param z z value to compare against
  67175. * @param w w value to compare against
  67176. * @returns true if equal
  67177. */
  67178. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67179. /**
  67180. * Multiplies in place the current Vector4 by the given one.
  67181. * @param otherVector vector to multiple with
  67182. * @returns the updated Vector4.
  67183. */
  67184. multiplyInPlace(otherVector: Vector4): Vector4;
  67185. /**
  67186. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67187. * @param otherVector vector to multiple with
  67188. * @returns resulting new vector
  67189. */
  67190. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67191. /**
  67192. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67193. * @param otherVector vector to multiple with
  67194. * @param result vector to store the result
  67195. * @returns the current Vector4.
  67196. */
  67197. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67198. /**
  67199. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67200. * @param x x value multiply with
  67201. * @param y y value multiply with
  67202. * @param z z value multiply with
  67203. * @param w w value multiply with
  67204. * @returns resulting new vector
  67205. */
  67206. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67207. /**
  67208. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67209. * @param otherVector vector to devide with
  67210. * @returns resulting new vector
  67211. */
  67212. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67213. /**
  67214. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67215. * @param otherVector vector to devide with
  67216. * @param result vector to store the result
  67217. * @returns the current Vector4.
  67218. */
  67219. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67220. /**
  67221. * Divides the current Vector3 coordinates by the given ones.
  67222. * @param otherVector vector to devide with
  67223. * @returns the updated Vector3.
  67224. */
  67225. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67226. /**
  67227. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67228. * @param other defines the second operand
  67229. * @returns the current updated Vector4
  67230. */
  67231. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67232. /**
  67233. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67234. * @param other defines the second operand
  67235. * @returns the current updated Vector4
  67236. */
  67237. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67238. /**
  67239. * Gets a new Vector4 from current Vector4 floored values
  67240. * @returns a new Vector4
  67241. */
  67242. floor(): Vector4;
  67243. /**
  67244. * Gets a new Vector4 from current Vector3 floored values
  67245. * @returns a new Vector4
  67246. */
  67247. fract(): Vector4;
  67248. /**
  67249. * Returns the Vector4 length (float).
  67250. * @returns the length
  67251. */
  67252. length(): number;
  67253. /**
  67254. * Returns the Vector4 squared length (float).
  67255. * @returns the length squared
  67256. */
  67257. lengthSquared(): number;
  67258. /**
  67259. * Normalizes in place the Vector4.
  67260. * @returns the updated Vector4.
  67261. */
  67262. normalize(): Vector4;
  67263. /**
  67264. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67265. * @returns this converted to a new vector3
  67266. */
  67267. toVector3(): Vector3;
  67268. /**
  67269. * Returns a new Vector4 copied from the current one.
  67270. * @returns the new cloned vector
  67271. */
  67272. clone(): Vector4;
  67273. /**
  67274. * Updates the current Vector4 with the given one coordinates.
  67275. * @param source the source vector to copy from
  67276. * @returns the updated Vector4.
  67277. */
  67278. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67279. /**
  67280. * Updates the current Vector4 coordinates with the given floats.
  67281. * @param x float to copy from
  67282. * @param y float to copy from
  67283. * @param z float to copy from
  67284. * @param w float to copy from
  67285. * @returns the updated Vector4.
  67286. */
  67287. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67288. /**
  67289. * Updates the current Vector4 coordinates with the given floats.
  67290. * @param x float to set from
  67291. * @param y float to set from
  67292. * @param z float to set from
  67293. * @param w float to set from
  67294. * @returns the updated Vector4.
  67295. */
  67296. set(x: number, y: number, z: number, w: number): Vector4;
  67297. /**
  67298. * Copies the given float to the current Vector3 coordinates
  67299. * @param v defines the x, y, z and w coordinates of the operand
  67300. * @returns the current updated Vector3
  67301. */
  67302. setAll(v: number): Vector4;
  67303. /**
  67304. * Returns a new Vector4 set from the starting index of the given array.
  67305. * @param array the array to pull values from
  67306. * @param offset the offset into the array to start at
  67307. * @returns the new vector
  67308. */
  67309. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67310. /**
  67311. * Updates the given vector "result" from the starting index of the given array.
  67312. * @param array the array to pull values from
  67313. * @param offset the offset into the array to start at
  67314. * @param result the vector to store the result in
  67315. */
  67316. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67317. /**
  67318. * Updates the given vector "result" from the starting index of the given Float32Array.
  67319. * @param array the array to pull values from
  67320. * @param offset the offset into the array to start at
  67321. * @param result the vector to store the result in
  67322. */
  67323. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67324. /**
  67325. * Updates the given vector "result" coordinates from the given floats.
  67326. * @param x float to set from
  67327. * @param y float to set from
  67328. * @param z float to set from
  67329. * @param w float to set from
  67330. * @param result the vector to the floats in
  67331. */
  67332. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67333. /**
  67334. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67335. * @returns the new vector
  67336. */
  67337. static Zero(): Vector4;
  67338. /**
  67339. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67340. * @returns the new vector
  67341. */
  67342. static One(): Vector4;
  67343. /**
  67344. * Returns a new normalized Vector4 from the given one.
  67345. * @param vector the vector to normalize
  67346. * @returns the vector
  67347. */
  67348. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67349. /**
  67350. * Updates the given vector "result" from the normalization of the given one.
  67351. * @param vector the vector to normalize
  67352. * @param result the vector to store the result in
  67353. */
  67354. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67355. /**
  67356. * Returns a vector with the minimum values from the left and right vectors
  67357. * @param left left vector to minimize
  67358. * @param right right vector to minimize
  67359. * @returns a new vector with the minimum of the left and right vector values
  67360. */
  67361. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67362. /**
  67363. * Returns a vector with the maximum values from the left and right vectors
  67364. * @param left left vector to maximize
  67365. * @param right right vector to maximize
  67366. * @returns a new vector with the maximum of the left and right vector values
  67367. */
  67368. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67369. /**
  67370. * Returns the distance (float) between the vectors "value1" and "value2".
  67371. * @param value1 value to calulate the distance between
  67372. * @param value2 value to calulate the distance between
  67373. * @return the distance between the two vectors
  67374. */
  67375. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67376. /**
  67377. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67378. * @param value1 value to calulate the distance between
  67379. * @param value2 value to calulate the distance between
  67380. * @return the distance between the two vectors squared
  67381. */
  67382. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67383. /**
  67384. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67385. * @param value1 value to calulate the center between
  67386. * @param value2 value to calulate the center between
  67387. * @return the center between the two vectors
  67388. */
  67389. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67390. /**
  67391. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67392. * This methods computes transformed normalized direction vectors only.
  67393. * @param vector the vector to transform
  67394. * @param transformation the transformation matrix to apply
  67395. * @returns the new vector
  67396. */
  67397. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67398. /**
  67399. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67400. * This methods computes transformed normalized direction vectors only.
  67401. * @param vector the vector to transform
  67402. * @param transformation the transformation matrix to apply
  67403. * @param result the vector to store the result in
  67404. */
  67405. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67406. /**
  67407. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67408. * This methods computes transformed normalized direction vectors only.
  67409. * @param x value to transform
  67410. * @param y value to transform
  67411. * @param z value to transform
  67412. * @param w value to transform
  67413. * @param transformation the transformation matrix to apply
  67414. * @param result the vector to store the results in
  67415. */
  67416. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67417. /**
  67418. * Creates a new Vector4 from a Vector3
  67419. * @param source defines the source data
  67420. * @param w defines the 4th component (default is 0)
  67421. * @returns a new Vector4
  67422. */
  67423. static FromVector3(source: Vector3, w?: number): Vector4;
  67424. }
  67425. /**
  67426. * Class used to store quaternion data
  67427. * @see https://en.wikipedia.org/wiki/Quaternion
  67428. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67429. */
  67430. export class Quaternion {
  67431. /** defines the first component (0 by default) */
  67432. x: number;
  67433. /** defines the second component (0 by default) */
  67434. y: number;
  67435. /** defines the third component (0 by default) */
  67436. z: number;
  67437. /** defines the fourth component (1.0 by default) */
  67438. w: number;
  67439. /**
  67440. * Creates a new Quaternion from the given floats
  67441. * @param x defines the first component (0 by default)
  67442. * @param y defines the second component (0 by default)
  67443. * @param z defines the third component (0 by default)
  67444. * @param w defines the fourth component (1.0 by default)
  67445. */
  67446. constructor(
  67447. /** defines the first component (0 by default) */
  67448. x?: number,
  67449. /** defines the second component (0 by default) */
  67450. y?: number,
  67451. /** defines the third component (0 by default) */
  67452. z?: number,
  67453. /** defines the fourth component (1.0 by default) */
  67454. w?: number);
  67455. /**
  67456. * Gets a string representation for the current quaternion
  67457. * @returns a string with the Quaternion coordinates
  67458. */
  67459. toString(): string;
  67460. /**
  67461. * Gets the class name of the quaternion
  67462. * @returns the string "Quaternion"
  67463. */
  67464. getClassName(): string;
  67465. /**
  67466. * Gets a hash code for this quaternion
  67467. * @returns the quaternion hash code
  67468. */
  67469. getHashCode(): number;
  67470. /**
  67471. * Copy the quaternion to an array
  67472. * @returns a new array populated with 4 elements from the quaternion coordinates
  67473. */
  67474. asArray(): number[];
  67475. /**
  67476. * Check if two quaternions are equals
  67477. * @param otherQuaternion defines the second operand
  67478. * @return true if the current quaternion and the given one coordinates are strictly equals
  67479. */
  67480. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67481. /**
  67482. * Clone the current quaternion
  67483. * @returns a new quaternion copied from the current one
  67484. */
  67485. clone(): Quaternion;
  67486. /**
  67487. * Copy a quaternion to the current one
  67488. * @param other defines the other quaternion
  67489. * @returns the updated current quaternion
  67490. */
  67491. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67492. /**
  67493. * Updates the current quaternion with the given float coordinates
  67494. * @param x defines the x coordinate
  67495. * @param y defines the y coordinate
  67496. * @param z defines the z coordinate
  67497. * @param w defines the w coordinate
  67498. * @returns the updated current quaternion
  67499. */
  67500. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67501. /**
  67502. * Updates the current quaternion from the given float coordinates
  67503. * @param x defines the x coordinate
  67504. * @param y defines the y coordinate
  67505. * @param z defines the z coordinate
  67506. * @param w defines the w coordinate
  67507. * @returns the updated current quaternion
  67508. */
  67509. set(x: number, y: number, z: number, w: number): Quaternion;
  67510. /**
  67511. * Adds two quaternions
  67512. * @param other defines the second operand
  67513. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67514. */
  67515. add(other: DeepImmutable<Quaternion>): Quaternion;
  67516. /**
  67517. * Add a quaternion to the current one
  67518. * @param other defines the quaternion to add
  67519. * @returns the current quaternion
  67520. */
  67521. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67522. /**
  67523. * Subtract two quaternions
  67524. * @param other defines the second operand
  67525. * @returns a new quaternion as the subtraction result of the given one from the current one
  67526. */
  67527. subtract(other: Quaternion): Quaternion;
  67528. /**
  67529. * Multiplies the current quaternion by a scale factor
  67530. * @param value defines the scale factor
  67531. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67532. */
  67533. scale(value: number): Quaternion;
  67534. /**
  67535. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67536. * @param scale defines the scale factor
  67537. * @param result defines the Quaternion object where to store the result
  67538. * @returns the unmodified current quaternion
  67539. */
  67540. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67541. /**
  67542. * Multiplies in place the current quaternion by a scale factor
  67543. * @param value defines the scale factor
  67544. * @returns the current modified quaternion
  67545. */
  67546. scaleInPlace(value: number): Quaternion;
  67547. /**
  67548. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67549. * @param scale defines the scale factor
  67550. * @param result defines the Quaternion object where to store the result
  67551. * @returns the unmodified current quaternion
  67552. */
  67553. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67554. /**
  67555. * Multiplies two quaternions
  67556. * @param q1 defines the second operand
  67557. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67558. */
  67559. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67560. /**
  67561. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67562. * @param q1 defines the second operand
  67563. * @param result defines the target quaternion
  67564. * @returns the current quaternion
  67565. */
  67566. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67567. /**
  67568. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67569. * @param q1 defines the second operand
  67570. * @returns the currentupdated quaternion
  67571. */
  67572. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67573. /**
  67574. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67575. * @param ref defines the target quaternion
  67576. * @returns the current quaternion
  67577. */
  67578. conjugateToRef(ref: Quaternion): Quaternion;
  67579. /**
  67580. * Conjugates in place (1-q) the current quaternion
  67581. * @returns the current updated quaternion
  67582. */
  67583. conjugateInPlace(): Quaternion;
  67584. /**
  67585. * Conjugates in place (1-q) the current quaternion
  67586. * @returns a new quaternion
  67587. */
  67588. conjugate(): Quaternion;
  67589. /**
  67590. * Gets length of current quaternion
  67591. * @returns the quaternion length (float)
  67592. */
  67593. length(): number;
  67594. /**
  67595. * Normalize in place the current quaternion
  67596. * @returns the current updated quaternion
  67597. */
  67598. normalize(): Quaternion;
  67599. /**
  67600. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67601. * @param order is a reserved parameter and is ignore for now
  67602. * @returns a new Vector3 containing the Euler angles
  67603. */
  67604. toEulerAngles(order?: string): Vector3;
  67605. /**
  67606. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67607. * @param result defines the vector which will be filled with the Euler angles
  67608. * @param order is a reserved parameter and is ignore for now
  67609. * @returns the current unchanged quaternion
  67610. */
  67611. toEulerAnglesToRef(result: Vector3): Quaternion;
  67612. /**
  67613. * Updates the given rotation matrix with the current quaternion values
  67614. * @param result defines the target matrix
  67615. * @returns the current unchanged quaternion
  67616. */
  67617. toRotationMatrix(result: Matrix): Quaternion;
  67618. /**
  67619. * Updates the current quaternion from the given rotation matrix values
  67620. * @param matrix defines the source matrix
  67621. * @returns the current updated quaternion
  67622. */
  67623. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67624. /**
  67625. * Creates a new quaternion from a rotation matrix
  67626. * @param matrix defines the source matrix
  67627. * @returns a new quaternion created from the given rotation matrix values
  67628. */
  67629. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67630. /**
  67631. * Updates the given quaternion with the given rotation matrix values
  67632. * @param matrix defines the source matrix
  67633. * @param result defines the target quaternion
  67634. */
  67635. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67636. /**
  67637. * Returns the dot product (float) between the quaternions "left" and "right"
  67638. * @param left defines the left operand
  67639. * @param right defines the right operand
  67640. * @returns the dot product
  67641. */
  67642. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67643. /**
  67644. * Checks if the two quaternions are close to each other
  67645. * @param quat0 defines the first quaternion to check
  67646. * @param quat1 defines the second quaternion to check
  67647. * @returns true if the two quaternions are close to each other
  67648. */
  67649. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67650. /**
  67651. * Creates an empty quaternion
  67652. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67653. */
  67654. static Zero(): Quaternion;
  67655. /**
  67656. * Inverse a given quaternion
  67657. * @param q defines the source quaternion
  67658. * @returns a new quaternion as the inverted current quaternion
  67659. */
  67660. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67661. /**
  67662. * Inverse a given quaternion
  67663. * @param q defines the source quaternion
  67664. * @param result the quaternion the result will be stored in
  67665. * @returns the result quaternion
  67666. */
  67667. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67668. /**
  67669. * Creates an identity quaternion
  67670. * @returns the identity quaternion
  67671. */
  67672. static Identity(): Quaternion;
  67673. /**
  67674. * Gets a boolean indicating if the given quaternion is identity
  67675. * @param quaternion defines the quaternion to check
  67676. * @returns true if the quaternion is identity
  67677. */
  67678. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67679. /**
  67680. * Creates a quaternion from a rotation around an axis
  67681. * @param axis defines the axis to use
  67682. * @param angle defines the angle to use
  67683. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67684. */
  67685. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67686. /**
  67687. * Creates a rotation around an axis and stores it into the given quaternion
  67688. * @param axis defines the axis to use
  67689. * @param angle defines the angle to use
  67690. * @param result defines the target quaternion
  67691. * @returns the target quaternion
  67692. */
  67693. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67694. /**
  67695. * Creates a new quaternion from data stored into an array
  67696. * @param array defines the data source
  67697. * @param offset defines the offset in the source array where the data starts
  67698. * @returns a new quaternion
  67699. */
  67700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67701. /**
  67702. * Create a quaternion from Euler rotation angles
  67703. * @param x Pitch
  67704. * @param y Yaw
  67705. * @param z Roll
  67706. * @returns the new Quaternion
  67707. */
  67708. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67709. /**
  67710. * Updates a quaternion from Euler rotation angles
  67711. * @param x Pitch
  67712. * @param y Yaw
  67713. * @param z Roll
  67714. * @param result the quaternion to store the result
  67715. * @returns the updated quaternion
  67716. */
  67717. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67718. /**
  67719. * Create a quaternion from Euler rotation vector
  67720. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67721. * @returns the new Quaternion
  67722. */
  67723. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67724. /**
  67725. * Updates a quaternion from Euler rotation vector
  67726. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67727. * @param result the quaternion to store the result
  67728. * @returns the updated quaternion
  67729. */
  67730. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67731. /**
  67732. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67733. * @param yaw defines the rotation around Y axis
  67734. * @param pitch defines the rotation around X axis
  67735. * @param roll defines the rotation around Z axis
  67736. * @returns the new quaternion
  67737. */
  67738. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67739. /**
  67740. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67741. * @param yaw defines the rotation around Y axis
  67742. * @param pitch defines the rotation around X axis
  67743. * @param roll defines the rotation around Z axis
  67744. * @param result defines the target quaternion
  67745. */
  67746. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67747. /**
  67748. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67749. * @param alpha defines the rotation around first axis
  67750. * @param beta defines the rotation around second axis
  67751. * @param gamma defines the rotation around third axis
  67752. * @returns the new quaternion
  67753. */
  67754. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67755. /**
  67756. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67757. * @param alpha defines the rotation around first axis
  67758. * @param beta defines the rotation around second axis
  67759. * @param gamma defines the rotation around third axis
  67760. * @param result defines the target quaternion
  67761. */
  67762. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67763. /**
  67764. * 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)
  67765. * @param axis1 defines the first axis
  67766. * @param axis2 defines the second axis
  67767. * @param axis3 defines the third axis
  67768. * @returns the new quaternion
  67769. */
  67770. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67771. /**
  67772. * 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
  67773. * @param axis1 defines the first axis
  67774. * @param axis2 defines the second axis
  67775. * @param axis3 defines the third axis
  67776. * @param ref defines the target quaternion
  67777. */
  67778. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67779. /**
  67780. * Interpolates between two quaternions
  67781. * @param left defines first quaternion
  67782. * @param right defines second quaternion
  67783. * @param amount defines the gradient to use
  67784. * @returns the new interpolated quaternion
  67785. */
  67786. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67787. /**
  67788. * Interpolates between two quaternions and stores it into a target quaternion
  67789. * @param left defines first quaternion
  67790. * @param right defines second quaternion
  67791. * @param amount defines the gradient to use
  67792. * @param result defines the target quaternion
  67793. */
  67794. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67795. /**
  67796. * Interpolate between two quaternions using Hermite interpolation
  67797. * @param value1 defines first quaternion
  67798. * @param tangent1 defines the incoming tangent
  67799. * @param value2 defines second quaternion
  67800. * @param tangent2 defines the outgoing tangent
  67801. * @param amount defines the target quaternion
  67802. * @returns the new interpolated quaternion
  67803. */
  67804. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67805. }
  67806. /**
  67807. * Class used to store matrix data (4x4)
  67808. */
  67809. export class Matrix {
  67810. private static _updateFlagSeed;
  67811. private static _identityReadOnly;
  67812. private _isIdentity;
  67813. private _isIdentityDirty;
  67814. private _isIdentity3x2;
  67815. private _isIdentity3x2Dirty;
  67816. /**
  67817. * Gets the update flag of the matrix which is an unique number for the matrix.
  67818. * It will be incremented every time the matrix data change.
  67819. * You can use it to speed the comparison between two versions of the same matrix.
  67820. */
  67821. updateFlag: number;
  67822. private readonly _m;
  67823. /**
  67824. * Gets the internal data of the matrix
  67825. */
  67826. readonly m: DeepImmutable<Float32Array>;
  67827. /** @hidden */
  67828. _markAsUpdated(): void;
  67829. /** @hidden */
  67830. private _updateIdentityStatus;
  67831. /**
  67832. * Creates an empty matrix (filled with zeros)
  67833. */
  67834. constructor();
  67835. /**
  67836. * Check if the current matrix is identity
  67837. * @returns true is the matrix is the identity matrix
  67838. */
  67839. isIdentity(): boolean;
  67840. /**
  67841. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67842. * @returns true is the matrix is the identity matrix
  67843. */
  67844. isIdentityAs3x2(): boolean;
  67845. /**
  67846. * Gets the determinant of the matrix
  67847. * @returns the matrix determinant
  67848. */
  67849. determinant(): number;
  67850. /**
  67851. * Returns the matrix as a Float32Array
  67852. * @returns the matrix underlying array
  67853. */
  67854. toArray(): DeepImmutable<Float32Array>;
  67855. /**
  67856. * Returns the matrix as a Float32Array
  67857. * @returns the matrix underlying array.
  67858. */
  67859. asArray(): DeepImmutable<Float32Array>;
  67860. /**
  67861. * Inverts the current matrix in place
  67862. * @returns the current inverted matrix
  67863. */
  67864. invert(): Matrix;
  67865. /**
  67866. * Sets all the matrix elements to zero
  67867. * @returns the current matrix
  67868. */
  67869. reset(): Matrix;
  67870. /**
  67871. * Adds the current matrix with a second one
  67872. * @param other defines the matrix to add
  67873. * @returns a new matrix as the addition of the current matrix and the given one
  67874. */
  67875. add(other: DeepImmutable<Matrix>): Matrix;
  67876. /**
  67877. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67878. * @param other defines the matrix to add
  67879. * @param result defines the target matrix
  67880. * @returns the current matrix
  67881. */
  67882. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67883. /**
  67884. * Adds in place the given matrix to the current matrix
  67885. * @param other defines the second operand
  67886. * @returns the current updated matrix
  67887. */
  67888. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67889. /**
  67890. * Sets the given matrix to the current inverted Matrix
  67891. * @param other defines the target matrix
  67892. * @returns the unmodified current matrix
  67893. */
  67894. invertToRef(other: Matrix): Matrix;
  67895. /**
  67896. * add a value at the specified position in the current Matrix
  67897. * @param index the index of the value within the matrix. between 0 and 15.
  67898. * @param value the value to be added
  67899. * @returns the current updated matrix
  67900. */
  67901. addAtIndex(index: number, value: number): Matrix;
  67902. /**
  67903. * mutiply the specified position in the current Matrix by a value
  67904. * @param index the index of the value within the matrix. between 0 and 15.
  67905. * @param value the value to be added
  67906. * @returns the current updated matrix
  67907. */
  67908. multiplyAtIndex(index: number, value: number): Matrix;
  67909. /**
  67910. * Inserts the translation vector (using 3 floats) in the current matrix
  67911. * @param x defines the 1st component of the translation
  67912. * @param y defines the 2nd component of the translation
  67913. * @param z defines the 3rd component of the translation
  67914. * @returns the current updated matrix
  67915. */
  67916. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67917. /**
  67918. * Adds the translation vector (using 3 floats) in the current matrix
  67919. * @param x defines the 1st component of the translation
  67920. * @param y defines the 2nd component of the translation
  67921. * @param z defines the 3rd component of the translation
  67922. * @returns the current updated matrix
  67923. */
  67924. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67925. /**
  67926. * Inserts the translation vector in the current matrix
  67927. * @param vector3 defines the translation to insert
  67928. * @returns the current updated matrix
  67929. */
  67930. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67931. /**
  67932. * Gets the translation value of the current matrix
  67933. * @returns a new Vector3 as the extracted translation from the matrix
  67934. */
  67935. getTranslation(): Vector3;
  67936. /**
  67937. * Fill a Vector3 with the extracted translation from the matrix
  67938. * @param result defines the Vector3 where to store the translation
  67939. * @returns the current matrix
  67940. */
  67941. getTranslationToRef(result: Vector3): Matrix;
  67942. /**
  67943. * Remove rotation and scaling part from the matrix
  67944. * @returns the updated matrix
  67945. */
  67946. removeRotationAndScaling(): Matrix;
  67947. /**
  67948. * Multiply two matrices
  67949. * @param other defines the second operand
  67950. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67951. */
  67952. multiply(other: DeepImmutable<Matrix>): Matrix;
  67953. /**
  67954. * Copy the current matrix from the given one
  67955. * @param other defines the source matrix
  67956. * @returns the current updated matrix
  67957. */
  67958. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67959. /**
  67960. * Populates the given array from the starting index with the current matrix values
  67961. * @param array defines the target array
  67962. * @param offset defines the offset in the target array where to start storing values
  67963. * @returns the current matrix
  67964. */
  67965. copyToArray(array: Float32Array, offset?: number): Matrix;
  67966. /**
  67967. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67968. * @param other defines the second operand
  67969. * @param result defines the matrix where to store the multiplication
  67970. * @returns the current matrix
  67971. */
  67972. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67973. /**
  67974. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67975. * @param other defines the second operand
  67976. * @param result defines the array where to store the multiplication
  67977. * @param offset defines the offset in the target array where to start storing values
  67978. * @returns the current matrix
  67979. */
  67980. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67981. /**
  67982. * Check equality between this matrix and a second one
  67983. * @param value defines the second matrix to compare
  67984. * @returns true is the current matrix and the given one values are strictly equal
  67985. */
  67986. equals(value: DeepImmutable<Matrix>): boolean;
  67987. /**
  67988. * Clone the current matrix
  67989. * @returns a new matrix from the current matrix
  67990. */
  67991. clone(): Matrix;
  67992. /**
  67993. * Returns the name of the current matrix class
  67994. * @returns the string "Matrix"
  67995. */
  67996. getClassName(): string;
  67997. /**
  67998. * Gets the hash code of the current matrix
  67999. * @returns the hash code
  68000. */
  68001. getHashCode(): number;
  68002. /**
  68003. * Decomposes the current Matrix into a translation, rotation and scaling components
  68004. * @param scale defines the scale vector3 given as a reference to update
  68005. * @param rotation defines the rotation quaternion given as a reference to update
  68006. * @param translation defines the translation vector3 given as a reference to update
  68007. * @returns true if operation was successful
  68008. */
  68009. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68010. /**
  68011. * Gets specific row of the matrix
  68012. * @param index defines the number of the row to get
  68013. * @returns the index-th row of the current matrix as a new Vector4
  68014. */
  68015. getRow(index: number): Nullable<Vector4>;
  68016. /**
  68017. * Sets the index-th row of the current matrix to the vector4 values
  68018. * @param index defines the number of the row to set
  68019. * @param row defines the target vector4
  68020. * @returns the updated current matrix
  68021. */
  68022. setRow(index: number, row: Vector4): Matrix;
  68023. /**
  68024. * Compute the transpose of the matrix
  68025. * @returns the new transposed matrix
  68026. */
  68027. transpose(): Matrix;
  68028. /**
  68029. * Compute the transpose of the matrix and store it in a given matrix
  68030. * @param result defines the target matrix
  68031. * @returns the current matrix
  68032. */
  68033. transposeToRef(result: Matrix): Matrix;
  68034. /**
  68035. * Sets the index-th row of the current matrix with the given 4 x float values
  68036. * @param index defines the row index
  68037. * @param x defines the x component to set
  68038. * @param y defines the y component to set
  68039. * @param z defines the z component to set
  68040. * @param w defines the w component to set
  68041. * @returns the updated current matrix
  68042. */
  68043. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68044. /**
  68045. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68046. * @param scale defines the scale factor
  68047. * @returns a new matrix
  68048. */
  68049. scale(scale: number): Matrix;
  68050. /**
  68051. * Scale the current matrix values by a factor to a given result matrix
  68052. * @param scale defines the scale factor
  68053. * @param result defines the matrix to store the result
  68054. * @returns the current matrix
  68055. */
  68056. scaleToRef(scale: number, result: Matrix): Matrix;
  68057. /**
  68058. * Scale the current matrix values by a factor and add the result to a given matrix
  68059. * @param scale defines the scale factor
  68060. * @param result defines the Matrix to store the result
  68061. * @returns the current matrix
  68062. */
  68063. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68064. /**
  68065. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68066. * @param ref matrix to store the result
  68067. */
  68068. toNormalMatrix(ref: Matrix): void;
  68069. /**
  68070. * Gets only rotation part of the current matrix
  68071. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68072. */
  68073. getRotationMatrix(): Matrix;
  68074. /**
  68075. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68076. * @param result defines the target matrix to store data to
  68077. * @returns the current matrix
  68078. */
  68079. getRotationMatrixToRef(result: Matrix): Matrix;
  68080. /**
  68081. * Toggles model matrix from being right handed to left handed in place and vice versa
  68082. */
  68083. toggleModelMatrixHandInPlace(): void;
  68084. /**
  68085. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68086. */
  68087. toggleProjectionMatrixHandInPlace(): void;
  68088. /**
  68089. * Creates a matrix from an array
  68090. * @param array defines the source array
  68091. * @param offset defines an offset in the source array
  68092. * @returns a new Matrix set from the starting index of the given array
  68093. */
  68094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68095. /**
  68096. * Copy the content of an array into a given matrix
  68097. * @param array defines the source array
  68098. * @param offset defines an offset in the source array
  68099. * @param result defines the target matrix
  68100. */
  68101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68102. /**
  68103. * Stores an array into a matrix after having multiplied each component by a given factor
  68104. * @param array defines the source array
  68105. * @param offset defines the offset in the source array
  68106. * @param scale defines the scaling factor
  68107. * @param result defines the target matrix
  68108. */
  68109. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68110. /**
  68111. * Gets an identity matrix that must not be updated
  68112. */
  68113. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68114. /**
  68115. * Stores a list of values (16) inside a given matrix
  68116. * @param initialM11 defines 1st value of 1st row
  68117. * @param initialM12 defines 2nd value of 1st row
  68118. * @param initialM13 defines 3rd value of 1st row
  68119. * @param initialM14 defines 4th value of 1st row
  68120. * @param initialM21 defines 1st value of 2nd row
  68121. * @param initialM22 defines 2nd value of 2nd row
  68122. * @param initialM23 defines 3rd value of 2nd row
  68123. * @param initialM24 defines 4th value of 2nd row
  68124. * @param initialM31 defines 1st value of 3rd row
  68125. * @param initialM32 defines 2nd value of 3rd row
  68126. * @param initialM33 defines 3rd value of 3rd row
  68127. * @param initialM34 defines 4th value of 3rd row
  68128. * @param initialM41 defines 1st value of 4th row
  68129. * @param initialM42 defines 2nd value of 4th row
  68130. * @param initialM43 defines 3rd value of 4th row
  68131. * @param initialM44 defines 4th value of 4th row
  68132. * @param result defines the target matrix
  68133. */
  68134. 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;
  68135. /**
  68136. * Creates new matrix from a list of values (16)
  68137. * @param initialM11 defines 1st value of 1st row
  68138. * @param initialM12 defines 2nd value of 1st row
  68139. * @param initialM13 defines 3rd value of 1st row
  68140. * @param initialM14 defines 4th value of 1st row
  68141. * @param initialM21 defines 1st value of 2nd row
  68142. * @param initialM22 defines 2nd value of 2nd row
  68143. * @param initialM23 defines 3rd value of 2nd row
  68144. * @param initialM24 defines 4th value of 2nd row
  68145. * @param initialM31 defines 1st value of 3rd row
  68146. * @param initialM32 defines 2nd value of 3rd row
  68147. * @param initialM33 defines 3rd value of 3rd row
  68148. * @param initialM34 defines 4th value of 3rd row
  68149. * @param initialM41 defines 1st value of 4th row
  68150. * @param initialM42 defines 2nd value of 4th row
  68151. * @param initialM43 defines 3rd value of 4th row
  68152. * @param initialM44 defines 4th value of 4th row
  68153. * @returns the new matrix
  68154. */
  68155. 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;
  68156. /**
  68157. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68158. * @param scale defines the scale vector3
  68159. * @param rotation defines the rotation quaternion
  68160. * @param translation defines the translation vector3
  68161. * @returns a new matrix
  68162. */
  68163. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68164. /**
  68165. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68166. * @param scale defines the scale vector3
  68167. * @param rotation defines the rotation quaternion
  68168. * @param translation defines the translation vector3
  68169. * @param result defines the target matrix
  68170. */
  68171. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68172. /**
  68173. * Creates a new identity matrix
  68174. * @returns a new identity matrix
  68175. */
  68176. static Identity(): Matrix;
  68177. /**
  68178. * Creates a new identity matrix and stores the result in a given matrix
  68179. * @param result defines the target matrix
  68180. */
  68181. static IdentityToRef(result: Matrix): void;
  68182. /**
  68183. * Creates a new zero matrix
  68184. * @returns a new zero matrix
  68185. */
  68186. static Zero(): Matrix;
  68187. /**
  68188. * Creates a new rotation matrix for "angle" radians around the X axis
  68189. * @param angle defines the angle (in radians) to use
  68190. * @return the new matrix
  68191. */
  68192. static RotationX(angle: number): Matrix;
  68193. /**
  68194. * Creates a new matrix as the invert of a given matrix
  68195. * @param source defines the source matrix
  68196. * @returns the new matrix
  68197. */
  68198. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68199. /**
  68200. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68201. * @param angle defines the angle (in radians) to use
  68202. * @param result defines the target matrix
  68203. */
  68204. static RotationXToRef(angle: number, result: Matrix): void;
  68205. /**
  68206. * Creates a new rotation matrix for "angle" radians around the Y axis
  68207. * @param angle defines the angle (in radians) to use
  68208. * @return the new matrix
  68209. */
  68210. static RotationY(angle: number): Matrix;
  68211. /**
  68212. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68213. * @param angle defines the angle (in radians) to use
  68214. * @param result defines the target matrix
  68215. */
  68216. static RotationYToRef(angle: number, result: Matrix): void;
  68217. /**
  68218. * Creates a new rotation matrix for "angle" radians around the Z axis
  68219. * @param angle defines the angle (in radians) to use
  68220. * @return the new matrix
  68221. */
  68222. static RotationZ(angle: number): Matrix;
  68223. /**
  68224. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68225. * @param angle defines the angle (in radians) to use
  68226. * @param result defines the target matrix
  68227. */
  68228. static RotationZToRef(angle: number, result: Matrix): void;
  68229. /**
  68230. * Creates a new rotation matrix for "angle" radians around the given axis
  68231. * @param axis defines the axis to use
  68232. * @param angle defines the angle (in radians) to use
  68233. * @return the new matrix
  68234. */
  68235. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68236. /**
  68237. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68238. * @param axis defines the axis to use
  68239. * @param angle defines the angle (in radians) to use
  68240. * @param result defines the target matrix
  68241. */
  68242. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68243. /**
  68244. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68245. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68246. * @param from defines the vector to align
  68247. * @param to defines the vector to align to
  68248. * @param result defines the target matrix
  68249. */
  68250. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68251. /**
  68252. * Creates a rotation matrix
  68253. * @param yaw defines the yaw angle in radians (Y axis)
  68254. * @param pitch defines the pitch angle in radians (X axis)
  68255. * @param roll defines the roll angle in radians (X axis)
  68256. * @returns the new rotation matrix
  68257. */
  68258. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68259. /**
  68260. * Creates a rotation matrix and stores it in a given matrix
  68261. * @param yaw defines the yaw angle in radians (Y axis)
  68262. * @param pitch defines the pitch angle in radians (X axis)
  68263. * @param roll defines the roll angle in radians (X axis)
  68264. * @param result defines the target matrix
  68265. */
  68266. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68267. /**
  68268. * Creates a scaling matrix
  68269. * @param x defines the scale factor on X axis
  68270. * @param y defines the scale factor on Y axis
  68271. * @param z defines the scale factor on Z axis
  68272. * @returns the new matrix
  68273. */
  68274. static Scaling(x: number, y: number, z: number): Matrix;
  68275. /**
  68276. * Creates a scaling matrix and stores it in a given matrix
  68277. * @param x defines the scale factor on X axis
  68278. * @param y defines the scale factor on Y axis
  68279. * @param z defines the scale factor on Z axis
  68280. * @param result defines the target matrix
  68281. */
  68282. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68283. /**
  68284. * Creates a translation matrix
  68285. * @param x defines the translation on X axis
  68286. * @param y defines the translation on Y axis
  68287. * @param z defines the translationon Z axis
  68288. * @returns the new matrix
  68289. */
  68290. static Translation(x: number, y: number, z: number): Matrix;
  68291. /**
  68292. * Creates a translation matrix and stores it in a given matrix
  68293. * @param x defines the translation on X axis
  68294. * @param y defines the translation on Y axis
  68295. * @param z defines the translationon Z axis
  68296. * @param result defines the target matrix
  68297. */
  68298. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68299. /**
  68300. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68301. * @param startValue defines the start value
  68302. * @param endValue defines the end value
  68303. * @param gradient defines the gradient factor
  68304. * @returns the new matrix
  68305. */
  68306. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68307. /**
  68308. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68309. * @param startValue defines the start value
  68310. * @param endValue defines the end value
  68311. * @param gradient defines the gradient factor
  68312. * @param result defines the Matrix object where to store data
  68313. */
  68314. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68315. /**
  68316. * Builds a new matrix whose values are computed by:
  68317. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68318. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68319. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68320. * @param startValue defines the first matrix
  68321. * @param endValue defines the second matrix
  68322. * @param gradient defines the gradient between the two matrices
  68323. * @returns the new matrix
  68324. */
  68325. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68326. /**
  68327. * Update a matrix to values which are computed by:
  68328. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68329. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68330. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68331. * @param startValue defines the first matrix
  68332. * @param endValue defines the second matrix
  68333. * @param gradient defines the gradient between the two matrices
  68334. * @param result defines the target matrix
  68335. */
  68336. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68337. /**
  68338. * 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"
  68339. * This function works in left handed mode
  68340. * @param eye defines the final position of the entity
  68341. * @param target defines where the entity should look at
  68342. * @param up defines the up vector for the entity
  68343. * @returns the new matrix
  68344. */
  68345. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68346. /**
  68347. * 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".
  68348. * This function works in left handed mode
  68349. * @param eye defines the final position of the entity
  68350. * @param target defines where the entity should look at
  68351. * @param up defines the up vector for the entity
  68352. * @param result defines the target matrix
  68353. */
  68354. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68355. /**
  68356. * 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"
  68357. * This function works in right handed mode
  68358. * @param eye defines the final position of the entity
  68359. * @param target defines where the entity should look at
  68360. * @param up defines the up vector for the entity
  68361. * @returns the new matrix
  68362. */
  68363. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68364. /**
  68365. * 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".
  68366. * This function works in right handed mode
  68367. * @param eye defines the final position of the entity
  68368. * @param target defines where the entity should look at
  68369. * @param up defines the up vector for the entity
  68370. * @param result defines the target matrix
  68371. */
  68372. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68373. /**
  68374. * Create a left-handed orthographic projection matrix
  68375. * @param width defines the viewport width
  68376. * @param height defines the viewport height
  68377. * @param znear defines the near clip plane
  68378. * @param zfar defines the far clip plane
  68379. * @returns a new matrix as a left-handed orthographic projection matrix
  68380. */
  68381. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68382. /**
  68383. * Store a left-handed orthographic projection to a given matrix
  68384. * @param width defines the viewport width
  68385. * @param height defines the viewport height
  68386. * @param znear defines the near clip plane
  68387. * @param zfar defines the far clip plane
  68388. * @param result defines the target matrix
  68389. */
  68390. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68391. /**
  68392. * Create a left-handed orthographic projection matrix
  68393. * @param left defines the viewport left coordinate
  68394. * @param right defines the viewport right coordinate
  68395. * @param bottom defines the viewport bottom coordinate
  68396. * @param top defines the viewport top coordinate
  68397. * @param znear defines the near clip plane
  68398. * @param zfar defines the far clip plane
  68399. * @returns a new matrix as a left-handed orthographic projection matrix
  68400. */
  68401. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68402. /**
  68403. * Stores a left-handed orthographic projection into a given matrix
  68404. * @param left defines the viewport left coordinate
  68405. * @param right defines the viewport right coordinate
  68406. * @param bottom defines the viewport bottom coordinate
  68407. * @param top defines the viewport top coordinate
  68408. * @param znear defines the near clip plane
  68409. * @param zfar defines the far clip plane
  68410. * @param result defines the target matrix
  68411. */
  68412. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68413. /**
  68414. * Creates a right-handed orthographic projection matrix
  68415. * @param left defines the viewport left coordinate
  68416. * @param right defines the viewport right coordinate
  68417. * @param bottom defines the viewport bottom coordinate
  68418. * @param top defines the viewport top coordinate
  68419. * @param znear defines the near clip plane
  68420. * @param zfar defines the far clip plane
  68421. * @returns a new matrix as a right-handed orthographic projection matrix
  68422. */
  68423. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68424. /**
  68425. * Stores a right-handed orthographic projection into a given matrix
  68426. * @param left defines the viewport left coordinate
  68427. * @param right defines the viewport right coordinate
  68428. * @param bottom defines the viewport bottom coordinate
  68429. * @param top defines the viewport top coordinate
  68430. * @param znear defines the near clip plane
  68431. * @param zfar defines the far clip plane
  68432. * @param result defines the target matrix
  68433. */
  68434. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68435. /**
  68436. * Creates a left-handed perspective projection matrix
  68437. * @param width defines the viewport width
  68438. * @param height defines the viewport height
  68439. * @param znear defines the near clip plane
  68440. * @param zfar defines the far clip plane
  68441. * @returns a new matrix as a left-handed perspective projection matrix
  68442. */
  68443. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68444. /**
  68445. * Creates a left-handed perspective projection matrix
  68446. * @param fov defines the horizontal field of view
  68447. * @param aspect defines the aspect ratio
  68448. * @param znear defines the near clip plane
  68449. * @param zfar defines the far clip plane
  68450. * @returns a new matrix as a left-handed perspective projection matrix
  68451. */
  68452. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68453. /**
  68454. * Stores a left-handed perspective projection into a given matrix
  68455. * @param fov defines the horizontal field of view
  68456. * @param aspect defines the aspect ratio
  68457. * @param znear defines the near clip plane
  68458. * @param zfar defines the far clip plane
  68459. * @param result defines the target matrix
  68460. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68461. */
  68462. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68463. /**
  68464. * Creates a right-handed perspective projection matrix
  68465. * @param fov defines the horizontal field of view
  68466. * @param aspect defines the aspect ratio
  68467. * @param znear defines the near clip plane
  68468. * @param zfar defines the far clip plane
  68469. * @returns a new matrix as a right-handed perspective projection matrix
  68470. */
  68471. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68472. /**
  68473. * Stores a right-handed perspective projection into a given matrix
  68474. * @param fov defines the horizontal field of view
  68475. * @param aspect defines the aspect ratio
  68476. * @param znear defines the near clip plane
  68477. * @param zfar defines the far clip plane
  68478. * @param result defines the target matrix
  68479. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68480. */
  68481. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68482. /**
  68483. * Stores a perspective projection for WebVR info a given matrix
  68484. * @param fov defines the field of view
  68485. * @param znear defines the near clip plane
  68486. * @param zfar defines the far clip plane
  68487. * @param result defines the target matrix
  68488. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68489. */
  68490. static PerspectiveFovWebVRToRef(fov: {
  68491. upDegrees: number;
  68492. downDegrees: number;
  68493. leftDegrees: number;
  68494. rightDegrees: number;
  68495. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68496. /**
  68497. * Computes a complete transformation matrix
  68498. * @param viewport defines the viewport to use
  68499. * @param world defines the world matrix
  68500. * @param view defines the view matrix
  68501. * @param projection defines the projection matrix
  68502. * @param zmin defines the near clip plane
  68503. * @param zmax defines the far clip plane
  68504. * @returns the transformation matrix
  68505. */
  68506. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68507. /**
  68508. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68509. * @param matrix defines the matrix to use
  68510. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68511. */
  68512. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68513. /**
  68514. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68515. * @param matrix defines the matrix to use
  68516. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68517. */
  68518. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68519. /**
  68520. * Compute the transpose of a given matrix
  68521. * @param matrix defines the matrix to transpose
  68522. * @returns the new matrix
  68523. */
  68524. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68525. /**
  68526. * Compute the transpose of a matrix and store it in a target matrix
  68527. * @param matrix defines the matrix to transpose
  68528. * @param result defines the target matrix
  68529. */
  68530. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68531. /**
  68532. * Computes a reflection matrix from a plane
  68533. * @param plane defines the reflection plane
  68534. * @returns a new matrix
  68535. */
  68536. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68537. /**
  68538. * Computes a reflection matrix from a plane
  68539. * @param plane defines the reflection plane
  68540. * @param result defines the target matrix
  68541. */
  68542. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68543. /**
  68544. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68545. * @param xaxis defines the value of the 1st axis
  68546. * @param yaxis defines the value of the 2nd axis
  68547. * @param zaxis defines the value of the 3rd axis
  68548. * @param result defines the target matrix
  68549. */
  68550. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68551. /**
  68552. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68553. * @param quat defines the quaternion to use
  68554. * @param result defines the target matrix
  68555. */
  68556. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68557. }
  68558. /**
  68559. * @hidden
  68560. */
  68561. export class TmpVectors {
  68562. static Vector2: Vector2[];
  68563. static Vector3: Vector3[];
  68564. static Vector4: Vector4[];
  68565. static Quaternion: Quaternion[];
  68566. static Matrix: Matrix[];
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /** Defines the cross module used constants to avoid circular dependncies */
  68571. export class Constants {
  68572. /** Defines that alpha blending is disabled */
  68573. static readonly ALPHA_DISABLE: number;
  68574. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68575. static readonly ALPHA_ADD: number;
  68576. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68577. static readonly ALPHA_COMBINE: number;
  68578. /** Defines that alpha blending to DEST - SRC * DEST */
  68579. static readonly ALPHA_SUBTRACT: number;
  68580. /** Defines that alpha blending to SRC * DEST */
  68581. static readonly ALPHA_MULTIPLY: number;
  68582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68583. static readonly ALPHA_MAXIMIZED: number;
  68584. /** Defines that alpha blending to SRC + DEST */
  68585. static readonly ALPHA_ONEONE: number;
  68586. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68587. static readonly ALPHA_PREMULTIPLIED: number;
  68588. /**
  68589. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68590. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68591. */
  68592. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68593. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68594. static readonly ALPHA_INTERPOLATE: number;
  68595. /**
  68596. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68597. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68598. */
  68599. static readonly ALPHA_SCREENMODE: number;
  68600. /** Defines that the ressource is not delayed*/
  68601. static readonly DELAYLOADSTATE_NONE: number;
  68602. /** Defines that the ressource was successfully delay loaded */
  68603. static readonly DELAYLOADSTATE_LOADED: number;
  68604. /** Defines that the ressource is currently delay loading */
  68605. static readonly DELAYLOADSTATE_LOADING: number;
  68606. /** Defines that the ressource is delayed and has not started loading */
  68607. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68609. static readonly NEVER: number;
  68610. /** 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 */
  68611. static readonly ALWAYS: number;
  68612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68613. static readonly LESS: number;
  68614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68615. static readonly EQUAL: number;
  68616. /** 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 */
  68617. static readonly LEQUAL: number;
  68618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68619. static readonly GREATER: number;
  68620. /** 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 */
  68621. static readonly GEQUAL: number;
  68622. /** 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 */
  68623. static readonly NOTEQUAL: number;
  68624. /** Passed to stencilOperation to specify that stencil value must be kept */
  68625. static readonly KEEP: number;
  68626. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68627. static readonly REPLACE: number;
  68628. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68629. static readonly INCR: number;
  68630. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68631. static readonly DECR: number;
  68632. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68633. static readonly INVERT: number;
  68634. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68635. static readonly INCR_WRAP: number;
  68636. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68637. static readonly DECR_WRAP: number;
  68638. /** Texture is not repeating outside of 0..1 UVs */
  68639. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68640. /** Texture is repeating outside of 0..1 UVs */
  68641. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68642. /** Texture is repeating and mirrored */
  68643. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68644. /** ALPHA */
  68645. static readonly TEXTUREFORMAT_ALPHA: number;
  68646. /** LUMINANCE */
  68647. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68648. /** LUMINANCE_ALPHA */
  68649. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68650. /** RGB */
  68651. static readonly TEXTUREFORMAT_RGB: number;
  68652. /** RGBA */
  68653. static readonly TEXTUREFORMAT_RGBA: number;
  68654. /** RED */
  68655. static readonly TEXTUREFORMAT_RED: number;
  68656. /** RED (2nd reference) */
  68657. static readonly TEXTUREFORMAT_R: number;
  68658. /** RG */
  68659. static readonly TEXTUREFORMAT_RG: number;
  68660. /** RED_INTEGER */
  68661. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68662. /** RED_INTEGER (2nd reference) */
  68663. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68664. /** RG_INTEGER */
  68665. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68666. /** RGB_INTEGER */
  68667. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68668. /** RGBA_INTEGER */
  68669. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68670. /** UNSIGNED_BYTE */
  68671. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68672. /** UNSIGNED_BYTE (2nd reference) */
  68673. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68674. /** FLOAT */
  68675. static readonly TEXTURETYPE_FLOAT: number;
  68676. /** HALF_FLOAT */
  68677. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68678. /** BYTE */
  68679. static readonly TEXTURETYPE_BYTE: number;
  68680. /** SHORT */
  68681. static readonly TEXTURETYPE_SHORT: number;
  68682. /** UNSIGNED_SHORT */
  68683. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68684. /** INT */
  68685. static readonly TEXTURETYPE_INT: number;
  68686. /** UNSIGNED_INT */
  68687. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68688. /** UNSIGNED_SHORT_4_4_4_4 */
  68689. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68690. /** UNSIGNED_SHORT_5_5_5_1 */
  68691. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68692. /** UNSIGNED_SHORT_5_6_5 */
  68693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68694. /** UNSIGNED_INT_2_10_10_10_REV */
  68695. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68696. /** UNSIGNED_INT_24_8 */
  68697. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68698. /** UNSIGNED_INT_10F_11F_11F_REV */
  68699. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68700. /** UNSIGNED_INT_5_9_9_9_REV */
  68701. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68702. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68703. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68704. /** nearest is mag = nearest and min = nearest and mip = linear */
  68705. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68707. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68708. /** Trilinear is mag = linear and min = linear and mip = linear */
  68709. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68710. /** nearest is mag = nearest and min = nearest and mip = linear */
  68711. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68713. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68714. /** Trilinear is mag = linear and min = linear and mip = linear */
  68715. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68716. /** mag = nearest and min = nearest and mip = nearest */
  68717. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68718. /** mag = nearest and min = linear and mip = nearest */
  68719. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68720. /** mag = nearest and min = linear and mip = linear */
  68721. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68722. /** mag = nearest and min = linear and mip = none */
  68723. static readonly TEXTURE_NEAREST_LINEAR: number;
  68724. /** mag = nearest and min = nearest and mip = none */
  68725. static readonly TEXTURE_NEAREST_NEAREST: number;
  68726. /** mag = linear and min = nearest and mip = nearest */
  68727. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68728. /** mag = linear and min = nearest and mip = linear */
  68729. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68730. /** mag = linear and min = linear and mip = none */
  68731. static readonly TEXTURE_LINEAR_LINEAR: number;
  68732. /** mag = linear and min = nearest and mip = none */
  68733. static readonly TEXTURE_LINEAR_NEAREST: number;
  68734. /** Explicit coordinates mode */
  68735. static readonly TEXTURE_EXPLICIT_MODE: number;
  68736. /** Spherical coordinates mode */
  68737. static readonly TEXTURE_SPHERICAL_MODE: number;
  68738. /** Planar coordinates mode */
  68739. static readonly TEXTURE_PLANAR_MODE: number;
  68740. /** Cubic coordinates mode */
  68741. static readonly TEXTURE_CUBIC_MODE: number;
  68742. /** Projection coordinates mode */
  68743. static readonly TEXTURE_PROJECTION_MODE: number;
  68744. /** Skybox coordinates mode */
  68745. static readonly TEXTURE_SKYBOX_MODE: number;
  68746. /** Inverse Cubic coordinates mode */
  68747. static readonly TEXTURE_INVCUBIC_MODE: number;
  68748. /** Equirectangular coordinates mode */
  68749. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68750. /** Equirectangular Fixed coordinates mode */
  68751. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68752. /** Equirectangular Fixed Mirrored coordinates mode */
  68753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68754. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68755. static readonly SCALEMODE_FLOOR: number;
  68756. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68757. static readonly SCALEMODE_NEAREST: number;
  68758. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68759. static readonly SCALEMODE_CEILING: number;
  68760. /**
  68761. * The dirty texture flag value
  68762. */
  68763. static readonly MATERIAL_TextureDirtyFlag: number;
  68764. /**
  68765. * The dirty light flag value
  68766. */
  68767. static readonly MATERIAL_LightDirtyFlag: number;
  68768. /**
  68769. * The dirty fresnel flag value
  68770. */
  68771. static readonly MATERIAL_FresnelDirtyFlag: number;
  68772. /**
  68773. * The dirty attribute flag value
  68774. */
  68775. static readonly MATERIAL_AttributesDirtyFlag: number;
  68776. /**
  68777. * The dirty misc flag value
  68778. */
  68779. static readonly MATERIAL_MiscDirtyFlag: number;
  68780. /**
  68781. * The all dirty flag value
  68782. */
  68783. static readonly MATERIAL_AllDirtyFlag: number;
  68784. /**
  68785. * Returns the triangle fill mode
  68786. */
  68787. static readonly MATERIAL_TriangleFillMode: number;
  68788. /**
  68789. * Returns the wireframe mode
  68790. */
  68791. static readonly MATERIAL_WireFrameFillMode: number;
  68792. /**
  68793. * Returns the point fill mode
  68794. */
  68795. static readonly MATERIAL_PointFillMode: number;
  68796. /**
  68797. * Returns the point list draw mode
  68798. */
  68799. static readonly MATERIAL_PointListDrawMode: number;
  68800. /**
  68801. * Returns the line list draw mode
  68802. */
  68803. static readonly MATERIAL_LineListDrawMode: number;
  68804. /**
  68805. * Returns the line loop draw mode
  68806. */
  68807. static readonly MATERIAL_LineLoopDrawMode: number;
  68808. /**
  68809. * Returns the line strip draw mode
  68810. */
  68811. static readonly MATERIAL_LineStripDrawMode: number;
  68812. /**
  68813. * Returns the triangle strip draw mode
  68814. */
  68815. static readonly MATERIAL_TriangleStripDrawMode: number;
  68816. /**
  68817. * Returns the triangle fan draw mode
  68818. */
  68819. static readonly MATERIAL_TriangleFanDrawMode: number;
  68820. /**
  68821. * Stores the clock-wise side orientation
  68822. */
  68823. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68824. /**
  68825. * Stores the counter clock-wise side orientation
  68826. */
  68827. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68828. /**
  68829. * Nothing
  68830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68831. */
  68832. static readonly ACTION_NothingTrigger: number;
  68833. /**
  68834. * On pick
  68835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68836. */
  68837. static readonly ACTION_OnPickTrigger: number;
  68838. /**
  68839. * On left pick
  68840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68841. */
  68842. static readonly ACTION_OnLeftPickTrigger: number;
  68843. /**
  68844. * On right pick
  68845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68846. */
  68847. static readonly ACTION_OnRightPickTrigger: number;
  68848. /**
  68849. * On center pick
  68850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68851. */
  68852. static readonly ACTION_OnCenterPickTrigger: number;
  68853. /**
  68854. * On pick down
  68855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68856. */
  68857. static readonly ACTION_OnPickDownTrigger: number;
  68858. /**
  68859. * On double pick
  68860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68861. */
  68862. static readonly ACTION_OnDoublePickTrigger: number;
  68863. /**
  68864. * On pick up
  68865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68866. */
  68867. static readonly ACTION_OnPickUpTrigger: number;
  68868. /**
  68869. * On pick out.
  68870. * This trigger will only be raised if you also declared a OnPickDown
  68871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68872. */
  68873. static readonly ACTION_OnPickOutTrigger: number;
  68874. /**
  68875. * On long press
  68876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68877. */
  68878. static readonly ACTION_OnLongPressTrigger: number;
  68879. /**
  68880. * On pointer over
  68881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68882. */
  68883. static readonly ACTION_OnPointerOverTrigger: number;
  68884. /**
  68885. * On pointer out
  68886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68887. */
  68888. static readonly ACTION_OnPointerOutTrigger: number;
  68889. /**
  68890. * On every frame
  68891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68892. */
  68893. static readonly ACTION_OnEveryFrameTrigger: number;
  68894. /**
  68895. * On intersection enter
  68896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68897. */
  68898. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68899. /**
  68900. * On intersection exit
  68901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68902. */
  68903. static readonly ACTION_OnIntersectionExitTrigger: number;
  68904. /**
  68905. * On key down
  68906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68907. */
  68908. static readonly ACTION_OnKeyDownTrigger: number;
  68909. /**
  68910. * On key up
  68911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68912. */
  68913. static readonly ACTION_OnKeyUpTrigger: number;
  68914. /**
  68915. * Billboard mode will only apply to Y axis
  68916. */
  68917. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68918. /**
  68919. * Billboard mode will apply to all axes
  68920. */
  68921. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68922. /**
  68923. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68924. */
  68925. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68926. /**
  68927. * Gets or sets base Assets URL
  68928. */
  68929. static PARTICLES_BaseAssetsUrl: string;
  68930. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68931. * Test order :
  68932. * Is the bounding sphere outside the frustum ?
  68933. * If not, are the bounding box vertices outside the frustum ?
  68934. * It not, then the cullable object is in the frustum.
  68935. */
  68936. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68937. /** Culling strategy : Bounding Sphere Only.
  68938. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68939. * It's also less accurate than the standard because some not visible objects can still be selected.
  68940. * Test : is the bounding sphere outside the frustum ?
  68941. * If not, then the cullable object is in the frustum.
  68942. */
  68943. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68944. /** Culling strategy : Optimistic Inclusion.
  68945. * This in an inclusion test first, then the standard exclusion test.
  68946. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68947. * 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.
  68948. * Anyway, it's as accurate as the standard strategy.
  68949. * Test :
  68950. * Is the cullable object bounding sphere center in the frustum ?
  68951. * If not, apply the default culling strategy.
  68952. */
  68953. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68954. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68955. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68956. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68957. * 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.
  68958. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68959. * Test :
  68960. * Is the cullable object bounding sphere center in the frustum ?
  68961. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68962. */
  68963. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68964. /**
  68965. * No logging while loading
  68966. */
  68967. static readonly SCENELOADER_NO_LOGGING: number;
  68968. /**
  68969. * Minimal logging while loading
  68970. */
  68971. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68972. /**
  68973. * Summary logging while loading
  68974. */
  68975. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68976. /**
  68977. * Detailled logging while loading
  68978. */
  68979. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68980. }
  68981. }
  68982. declare module BABYLON {
  68983. /**
  68984. * Class used to store and describe the pipeline context associated with an effect
  68985. */
  68986. export interface IPipelineContext {
  68987. /**
  68988. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68989. */
  68990. isAsync: boolean;
  68991. /**
  68992. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68993. */
  68994. isReady: boolean;
  68995. /** @hidden */
  68996. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /** @hidden */
  69001. export interface IShaderProcessor {
  69002. attributeProcessor?: (attribute: string) => string;
  69003. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69004. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69005. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69006. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69007. lineProcessor?: (line: string, isFragment: boolean) => string;
  69008. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69009. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69010. }
  69011. }
  69012. declare module BABYLON {
  69013. /** @hidden */
  69014. export interface ProcessingOptions {
  69015. defines: string[];
  69016. indexParameters: any;
  69017. isFragment: boolean;
  69018. shouldUseHighPrecisionShader: boolean;
  69019. supportsUniformBuffers: boolean;
  69020. shadersRepository: string;
  69021. includesShadersStore: {
  69022. [key: string]: string;
  69023. };
  69024. processor?: IShaderProcessor;
  69025. version: string;
  69026. platformName: string;
  69027. lookForClosingBracketForUniformBuffer?: boolean;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * Helper to manipulate strings
  69033. */
  69034. export class StringTools {
  69035. /**
  69036. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69037. * @param str Source string
  69038. * @param suffix Suffix to search for in the source string
  69039. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69040. */
  69041. static EndsWith(str: string, suffix: string): boolean;
  69042. /**
  69043. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69044. * @param str Source string
  69045. * @param suffix Suffix to search for in the source string
  69046. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69047. */
  69048. static StartsWith(str: string, suffix: string): boolean;
  69049. }
  69050. }
  69051. declare module BABYLON {
  69052. /** @hidden */
  69053. export class ShaderCodeNode {
  69054. line: string;
  69055. children: ShaderCodeNode[];
  69056. additionalDefineKey?: string;
  69057. additionalDefineValue?: string;
  69058. isValid(preprocessors: {
  69059. [key: string]: string;
  69060. }): boolean;
  69061. process(preprocessors: {
  69062. [key: string]: string;
  69063. }, options: ProcessingOptions): string;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /** @hidden */
  69068. export class ShaderCodeCursor {
  69069. private _lines;
  69070. lineIndex: number;
  69071. readonly currentLine: string;
  69072. readonly canRead: boolean;
  69073. lines: string[];
  69074. }
  69075. }
  69076. declare module BABYLON {
  69077. /** @hidden */
  69078. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69079. process(preprocessors: {
  69080. [key: string]: string;
  69081. }, options: ProcessingOptions): string;
  69082. }
  69083. }
  69084. declare module BABYLON {
  69085. /** @hidden */
  69086. export class ShaderDefineExpression {
  69087. isTrue(preprocessors: {
  69088. [key: string]: string;
  69089. }): boolean;
  69090. }
  69091. }
  69092. declare module BABYLON {
  69093. /** @hidden */
  69094. export class ShaderCodeTestNode extends ShaderCodeNode {
  69095. testExpression: ShaderDefineExpression;
  69096. isValid(preprocessors: {
  69097. [key: string]: string;
  69098. }): boolean;
  69099. }
  69100. }
  69101. declare module BABYLON {
  69102. /** @hidden */
  69103. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69104. define: string;
  69105. not: boolean;
  69106. constructor(define: string, not?: boolean);
  69107. isTrue(preprocessors: {
  69108. [key: string]: string;
  69109. }): boolean;
  69110. }
  69111. }
  69112. declare module BABYLON {
  69113. /** @hidden */
  69114. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69115. leftOperand: ShaderDefineExpression;
  69116. rightOperand: ShaderDefineExpression;
  69117. isTrue(preprocessors: {
  69118. [key: string]: string;
  69119. }): boolean;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /** @hidden */
  69124. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69125. leftOperand: ShaderDefineExpression;
  69126. rightOperand: ShaderDefineExpression;
  69127. isTrue(preprocessors: {
  69128. [key: string]: string;
  69129. }): boolean;
  69130. }
  69131. }
  69132. declare module BABYLON {
  69133. /** @hidden */
  69134. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69135. define: string;
  69136. operand: string;
  69137. testValue: string;
  69138. constructor(define: string, operand: string, testValue: string);
  69139. isTrue(preprocessors: {
  69140. [key: string]: string;
  69141. }): boolean;
  69142. }
  69143. }
  69144. declare module BABYLON {
  69145. /**
  69146. * @ignore
  69147. * Application error to support additional information when loading a file
  69148. */
  69149. export class LoadFileError extends Error {
  69150. /** defines the optional web request */
  69151. request?: WebRequest | undefined;
  69152. private static _setPrototypeOf;
  69153. /**
  69154. * Creates a new LoadFileError
  69155. * @param message defines the message of the error
  69156. * @param request defines the optional web request
  69157. */
  69158. constructor(message: string,
  69159. /** defines the optional web request */
  69160. request?: WebRequest | undefined);
  69161. }
  69162. }
  69163. declare module BABYLON {
  69164. /**
  69165. * Class used to enable access to offline support
  69166. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69167. */
  69168. export interface IOfflineProvider {
  69169. /**
  69170. * Gets a boolean indicating if scene must be saved in the database
  69171. */
  69172. enableSceneOffline: boolean;
  69173. /**
  69174. * Gets a boolean indicating if textures must be saved in the database
  69175. */
  69176. enableTexturesOffline: boolean;
  69177. /**
  69178. * Open the offline support and make it available
  69179. * @param successCallback defines the callback to call on success
  69180. * @param errorCallback defines the callback to call on error
  69181. */
  69182. open(successCallback: () => void, errorCallback: () => void): void;
  69183. /**
  69184. * Loads an image from the offline support
  69185. * @param url defines the url to load from
  69186. * @param image defines the target DOM image
  69187. */
  69188. loadImage(url: string, image: HTMLImageElement): void;
  69189. /**
  69190. * Loads a file from offline support
  69191. * @param url defines the URL to load from
  69192. * @param sceneLoaded defines a callback to call on success
  69193. * @param progressCallBack defines a callback to call when progress changed
  69194. * @param errorCallback defines a callback to call on error
  69195. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69196. */
  69197. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69198. }
  69199. }
  69200. declare module BABYLON {
  69201. /**
  69202. * Class used to help managing file picking and drag'n'drop
  69203. * File Storage
  69204. */
  69205. export class FilesInputStore {
  69206. /**
  69207. * List of files ready to be loaded
  69208. */
  69209. static FilesToLoad: {
  69210. [key: string]: File;
  69211. };
  69212. }
  69213. }
  69214. declare module BABYLON {
  69215. /**
  69216. * Class used to define a retry strategy when error happens while loading assets
  69217. */
  69218. export class RetryStrategy {
  69219. /**
  69220. * Function used to defines an exponential back off strategy
  69221. * @param maxRetries defines the maximum number of retries (3 by default)
  69222. * @param baseInterval defines the interval between retries
  69223. * @returns the strategy function to use
  69224. */
  69225. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69226. }
  69227. }
  69228. declare module BABYLON {
  69229. /**
  69230. * @hidden
  69231. */
  69232. export class FileTools {
  69233. /**
  69234. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69235. */
  69236. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69237. /**
  69238. * Gets or sets the base URL to use to load assets
  69239. */
  69240. static BaseUrl: string;
  69241. /**
  69242. * Default behaviour for cors in the application.
  69243. * It can be a string if the expected behavior is identical in the entire app.
  69244. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69245. */
  69246. static CorsBehavior: string | ((url: string | string[]) => string);
  69247. /**
  69248. * Gets or sets a function used to pre-process url before using them to load assets
  69249. */
  69250. static PreprocessUrl: (url: string) => string;
  69251. /**
  69252. * Removes unwanted characters from an url
  69253. * @param url defines the url to clean
  69254. * @returns the cleaned url
  69255. */
  69256. private static _CleanUrl;
  69257. /**
  69258. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69259. * @param url define the url we are trying
  69260. * @param element define the dom element where to configure the cors policy
  69261. */
  69262. static SetCorsBehavior(url: string | string[], element: {
  69263. crossOrigin: string | null;
  69264. }): void;
  69265. /**
  69266. * Loads an image as an HTMLImageElement.
  69267. * @param input url string, ArrayBuffer, or Blob to load
  69268. * @param onLoad callback called when the image successfully loads
  69269. * @param onError callback called when the image fails to load
  69270. * @param offlineProvider offline provider for caching
  69271. * @returns the HTMLImageElement of the loaded image
  69272. */
  69273. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69274. /**
  69275. * Loads a file
  69276. * @param fileToLoad defines the file to load
  69277. * @param callback defines the callback to call when data is loaded
  69278. * @param progressCallBack defines the callback to call during loading process
  69279. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69280. * @returns a file request object
  69281. */
  69282. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69283. /**
  69284. * Loads a file
  69285. * @param url url string, ArrayBuffer, or Blob to load
  69286. * @param onSuccess callback called when the file successfully loads
  69287. * @param onProgress callback called while file is loading (if the server supports this mode)
  69288. * @param offlineProvider defines the offline provider for caching
  69289. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69290. * @param onError callback called when the file fails to load
  69291. * @returns a file request object
  69292. */
  69293. 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;
  69294. /**
  69295. * Checks if the loaded document was accessed via `file:`-Protocol.
  69296. * @returns boolean
  69297. */
  69298. static IsFileURL(): boolean;
  69299. }
  69300. }
  69301. declare module BABYLON {
  69302. /** @hidden */
  69303. export class ShaderProcessor {
  69304. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69305. private static _ProcessPrecision;
  69306. private static _ExtractOperation;
  69307. private static _BuildSubExpression;
  69308. private static _BuildExpression;
  69309. private static _MoveCursorWithinIf;
  69310. private static _MoveCursor;
  69311. private static _EvaluatePreProcessors;
  69312. private static _PreparePreProcessors;
  69313. private static _ProcessShaderConversion;
  69314. private static _ProcessIncludes;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /**
  69319. * Class used to hold a RBG color
  69320. */
  69321. export class Color3 {
  69322. /**
  69323. * Defines the red component (between 0 and 1, default is 0)
  69324. */
  69325. r: number;
  69326. /**
  69327. * Defines the green component (between 0 and 1, default is 0)
  69328. */
  69329. g: number;
  69330. /**
  69331. * Defines the blue component (between 0 and 1, default is 0)
  69332. */
  69333. b: number;
  69334. /**
  69335. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69336. * @param r defines the red component (between 0 and 1, default is 0)
  69337. * @param g defines the green component (between 0 and 1, default is 0)
  69338. * @param b defines the blue component (between 0 and 1, default is 0)
  69339. */
  69340. constructor(
  69341. /**
  69342. * Defines the red component (between 0 and 1, default is 0)
  69343. */
  69344. r?: number,
  69345. /**
  69346. * Defines the green component (between 0 and 1, default is 0)
  69347. */
  69348. g?: number,
  69349. /**
  69350. * Defines the blue component (between 0 and 1, default is 0)
  69351. */
  69352. b?: number);
  69353. /**
  69354. * Creates a string with the Color3 current values
  69355. * @returns the string representation of the Color3 object
  69356. */
  69357. toString(): string;
  69358. /**
  69359. * Returns the string "Color3"
  69360. * @returns "Color3"
  69361. */
  69362. getClassName(): string;
  69363. /**
  69364. * Compute the Color3 hash code
  69365. * @returns an unique number that can be used to hash Color3 objects
  69366. */
  69367. getHashCode(): number;
  69368. /**
  69369. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69370. * @param array defines the array where to store the r,g,b components
  69371. * @param index defines an optional index in the target array to define where to start storing values
  69372. * @returns the current Color3 object
  69373. */
  69374. toArray(array: FloatArray, index?: number): Color3;
  69375. /**
  69376. * Returns a new Color4 object from the current Color3 and the given alpha
  69377. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69378. * @returns a new Color4 object
  69379. */
  69380. toColor4(alpha?: number): Color4;
  69381. /**
  69382. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69383. * @returns the new array
  69384. */
  69385. asArray(): number[];
  69386. /**
  69387. * Returns the luminance value
  69388. * @returns a float value
  69389. */
  69390. toLuminance(): number;
  69391. /**
  69392. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69393. * @param otherColor defines the second operand
  69394. * @returns the new Color3 object
  69395. */
  69396. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69397. /**
  69398. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69399. * @param otherColor defines the second operand
  69400. * @param result defines the Color3 object where to store the result
  69401. * @returns the current Color3
  69402. */
  69403. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69404. /**
  69405. * Determines equality between Color3 objects
  69406. * @param otherColor defines the second operand
  69407. * @returns true if the rgb values are equal to the given ones
  69408. */
  69409. equals(otherColor: DeepImmutable<Color3>): boolean;
  69410. /**
  69411. * Determines equality between the current Color3 object and a set of r,b,g values
  69412. * @param r defines the red component to check
  69413. * @param g defines the green component to check
  69414. * @param b defines the blue component to check
  69415. * @returns true if the rgb values are equal to the given ones
  69416. */
  69417. equalsFloats(r: number, g: number, b: number): boolean;
  69418. /**
  69419. * Multiplies in place each rgb value by scale
  69420. * @param scale defines the scaling factor
  69421. * @returns the updated Color3
  69422. */
  69423. scale(scale: number): Color3;
  69424. /**
  69425. * Multiplies the rgb values by scale and stores the result into "result"
  69426. * @param scale defines the scaling factor
  69427. * @param result defines the Color3 object where to store the result
  69428. * @returns the unmodified current Color3
  69429. */
  69430. scaleToRef(scale: number, result: Color3): Color3;
  69431. /**
  69432. * Scale the current Color3 values by a factor and add the result to a given Color3
  69433. * @param scale defines the scale factor
  69434. * @param result defines color to store the result into
  69435. * @returns the unmodified current Color3
  69436. */
  69437. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69438. /**
  69439. * Clamps the rgb values by the min and max values and stores the result into "result"
  69440. * @param min defines minimum clamping value (default is 0)
  69441. * @param max defines maximum clamping value (default is 1)
  69442. * @param result defines color to store the result into
  69443. * @returns the original Color3
  69444. */
  69445. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69446. /**
  69447. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69448. * @param otherColor defines the second operand
  69449. * @returns the new Color3
  69450. */
  69451. add(otherColor: DeepImmutable<Color3>): Color3;
  69452. /**
  69453. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69454. * @param otherColor defines the second operand
  69455. * @param result defines Color3 object to store the result into
  69456. * @returns the unmodified current Color3
  69457. */
  69458. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69459. /**
  69460. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69461. * @param otherColor defines the second operand
  69462. * @returns the new Color3
  69463. */
  69464. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69465. /**
  69466. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69467. * @param otherColor defines the second operand
  69468. * @param result defines Color3 object to store the result into
  69469. * @returns the unmodified current Color3
  69470. */
  69471. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69472. /**
  69473. * Copy the current object
  69474. * @returns a new Color3 copied the current one
  69475. */
  69476. clone(): Color3;
  69477. /**
  69478. * Copies the rgb values from the source in the current Color3
  69479. * @param source defines the source Color3 object
  69480. * @returns the updated Color3 object
  69481. */
  69482. copyFrom(source: DeepImmutable<Color3>): Color3;
  69483. /**
  69484. * Updates the Color3 rgb values from the given floats
  69485. * @param r defines the red component to read from
  69486. * @param g defines the green component to read from
  69487. * @param b defines the blue component to read from
  69488. * @returns the current Color3 object
  69489. */
  69490. copyFromFloats(r: number, g: number, b: number): Color3;
  69491. /**
  69492. * Updates the Color3 rgb values from the given floats
  69493. * @param r defines the red component to read from
  69494. * @param g defines the green component to read from
  69495. * @param b defines the blue component to read from
  69496. * @returns the current Color3 object
  69497. */
  69498. set(r: number, g: number, b: number): Color3;
  69499. /**
  69500. * Compute the Color3 hexadecimal code as a string
  69501. * @returns a string containing the hexadecimal representation of the Color3 object
  69502. */
  69503. toHexString(): string;
  69504. /**
  69505. * Computes a new Color3 converted from the current one to linear space
  69506. * @returns a new Color3 object
  69507. */
  69508. toLinearSpace(): Color3;
  69509. /**
  69510. * Converts current color in rgb space to HSV values
  69511. * @returns a new color3 representing the HSV values
  69512. */
  69513. toHSV(): Color3;
  69514. /**
  69515. * Converts current color in rgb space to HSV values
  69516. * @param result defines the Color3 where to store the HSV values
  69517. */
  69518. toHSVToRef(result: Color3): void;
  69519. /**
  69520. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69521. * @param convertedColor defines the Color3 object where to store the linear space version
  69522. * @returns the unmodified Color3
  69523. */
  69524. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69525. /**
  69526. * Computes a new Color3 converted from the current one to gamma space
  69527. * @returns a new Color3 object
  69528. */
  69529. toGammaSpace(): Color3;
  69530. /**
  69531. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69532. * @param convertedColor defines the Color3 object where to store the gamma space version
  69533. * @returns the unmodified Color3
  69534. */
  69535. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69536. private static _BlackReadOnly;
  69537. /**
  69538. * Convert Hue, saturation and value to a Color3 (RGB)
  69539. * @param hue defines the hue
  69540. * @param saturation defines the saturation
  69541. * @param value defines the value
  69542. * @param result defines the Color3 where to store the RGB values
  69543. */
  69544. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69545. /**
  69546. * Creates a new Color3 from the string containing valid hexadecimal values
  69547. * @param hex defines a string containing valid hexadecimal values
  69548. * @returns a new Color3 object
  69549. */
  69550. static FromHexString(hex: string): Color3;
  69551. /**
  69552. * Creates a new Color3 from the starting index of the given array
  69553. * @param array defines the source array
  69554. * @param offset defines an offset in the source array
  69555. * @returns a new Color3 object
  69556. */
  69557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69558. /**
  69559. * Creates a new Color3 from integer values (< 256)
  69560. * @param r defines the red component to read from (value between 0 and 255)
  69561. * @param g defines the green component to read from (value between 0 and 255)
  69562. * @param b defines the blue component to read from (value between 0 and 255)
  69563. * @returns a new Color3 object
  69564. */
  69565. static FromInts(r: number, g: number, b: number): Color3;
  69566. /**
  69567. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69568. * @param start defines the start Color3 value
  69569. * @param end defines the end Color3 value
  69570. * @param amount defines the gradient value between start and end
  69571. * @returns a new Color3 object
  69572. */
  69573. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69574. /**
  69575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69576. * @param left defines the start value
  69577. * @param right defines the end value
  69578. * @param amount defines the gradient factor
  69579. * @param result defines the Color3 object where to store the result
  69580. */
  69581. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69582. /**
  69583. * Returns a Color3 value containing a red color
  69584. * @returns a new Color3 object
  69585. */
  69586. static Red(): Color3;
  69587. /**
  69588. * Returns a Color3 value containing a green color
  69589. * @returns a new Color3 object
  69590. */
  69591. static Green(): Color3;
  69592. /**
  69593. * Returns a Color3 value containing a blue color
  69594. * @returns a new Color3 object
  69595. */
  69596. static Blue(): Color3;
  69597. /**
  69598. * Returns a Color3 value containing a black color
  69599. * @returns a new Color3 object
  69600. */
  69601. static Black(): Color3;
  69602. /**
  69603. * Gets a Color3 value containing a black color that must not be updated
  69604. */
  69605. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69606. /**
  69607. * Returns a Color3 value containing a white color
  69608. * @returns a new Color3 object
  69609. */
  69610. static White(): Color3;
  69611. /**
  69612. * Returns a Color3 value containing a purple color
  69613. * @returns a new Color3 object
  69614. */
  69615. static Purple(): Color3;
  69616. /**
  69617. * Returns a Color3 value containing a magenta color
  69618. * @returns a new Color3 object
  69619. */
  69620. static Magenta(): Color3;
  69621. /**
  69622. * Returns a Color3 value containing a yellow color
  69623. * @returns a new Color3 object
  69624. */
  69625. static Yellow(): Color3;
  69626. /**
  69627. * Returns a Color3 value containing a gray color
  69628. * @returns a new Color3 object
  69629. */
  69630. static Gray(): Color3;
  69631. /**
  69632. * Returns a Color3 value containing a teal color
  69633. * @returns a new Color3 object
  69634. */
  69635. static Teal(): Color3;
  69636. /**
  69637. * Returns a Color3 value containing a random color
  69638. * @returns a new Color3 object
  69639. */
  69640. static Random(): Color3;
  69641. }
  69642. /**
  69643. * Class used to hold a RBGA color
  69644. */
  69645. export class Color4 {
  69646. /**
  69647. * Defines the red component (between 0 and 1, default is 0)
  69648. */
  69649. r: number;
  69650. /**
  69651. * Defines the green component (between 0 and 1, default is 0)
  69652. */
  69653. g: number;
  69654. /**
  69655. * Defines the blue component (between 0 and 1, default is 0)
  69656. */
  69657. b: number;
  69658. /**
  69659. * Defines the alpha component (between 0 and 1, default is 1)
  69660. */
  69661. a: number;
  69662. /**
  69663. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69664. * @param r defines the red component (between 0 and 1, default is 0)
  69665. * @param g defines the green component (between 0 and 1, default is 0)
  69666. * @param b defines the blue component (between 0 and 1, default is 0)
  69667. * @param a defines the alpha component (between 0 and 1, default is 1)
  69668. */
  69669. constructor(
  69670. /**
  69671. * Defines the red component (between 0 and 1, default is 0)
  69672. */
  69673. r?: number,
  69674. /**
  69675. * Defines the green component (between 0 and 1, default is 0)
  69676. */
  69677. g?: number,
  69678. /**
  69679. * Defines the blue component (between 0 and 1, default is 0)
  69680. */
  69681. b?: number,
  69682. /**
  69683. * Defines the alpha component (between 0 and 1, default is 1)
  69684. */
  69685. a?: number);
  69686. /**
  69687. * Adds in place the given Color4 values to the current Color4 object
  69688. * @param right defines the second operand
  69689. * @returns the current updated Color4 object
  69690. */
  69691. addInPlace(right: DeepImmutable<Color4>): Color4;
  69692. /**
  69693. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69694. * @returns the new array
  69695. */
  69696. asArray(): number[];
  69697. /**
  69698. * Stores from the starting index in the given array the Color4 successive values
  69699. * @param array defines the array where to store the r,g,b components
  69700. * @param index defines an optional index in the target array to define where to start storing values
  69701. * @returns the current Color4 object
  69702. */
  69703. toArray(array: number[], index?: number): Color4;
  69704. /**
  69705. * Determines equality between Color4 objects
  69706. * @param otherColor defines the second operand
  69707. * @returns true if the rgba values are equal to the given ones
  69708. */
  69709. equals(otherColor: DeepImmutable<Color4>): boolean;
  69710. /**
  69711. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69712. * @param right defines the second operand
  69713. * @returns a new Color4 object
  69714. */
  69715. add(right: DeepImmutable<Color4>): Color4;
  69716. /**
  69717. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69718. * @param right defines the second operand
  69719. * @returns a new Color4 object
  69720. */
  69721. subtract(right: DeepImmutable<Color4>): Color4;
  69722. /**
  69723. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69724. * @param right defines the second operand
  69725. * @param result defines the Color4 object where to store the result
  69726. * @returns the current Color4 object
  69727. */
  69728. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69729. /**
  69730. * Creates a new Color4 with the current Color4 values multiplied by scale
  69731. * @param scale defines the scaling factor to apply
  69732. * @returns a new Color4 object
  69733. */
  69734. scale(scale: number): Color4;
  69735. /**
  69736. * Multiplies the current Color4 values by scale and stores the result in "result"
  69737. * @param scale defines the scaling factor to apply
  69738. * @param result defines the Color4 object where to store the result
  69739. * @returns the current unmodified Color4
  69740. */
  69741. scaleToRef(scale: number, result: Color4): Color4;
  69742. /**
  69743. * Scale the current Color4 values by a factor and add the result to a given Color4
  69744. * @param scale defines the scale factor
  69745. * @param result defines the Color4 object where to store the result
  69746. * @returns the unmodified current Color4
  69747. */
  69748. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69749. /**
  69750. * Clamps the rgb values by the min and max values and stores the result into "result"
  69751. * @param min defines minimum clamping value (default is 0)
  69752. * @param max defines maximum clamping value (default is 1)
  69753. * @param result defines color to store the result into.
  69754. * @returns the cuurent Color4
  69755. */
  69756. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69757. /**
  69758. * Multipy an Color4 value by another and return a new Color4 object
  69759. * @param color defines the Color4 value to multiply by
  69760. * @returns a new Color4 object
  69761. */
  69762. multiply(color: Color4): Color4;
  69763. /**
  69764. * Multipy a Color4 value by another and push the result in a reference value
  69765. * @param color defines the Color4 value to multiply by
  69766. * @param result defines the Color4 to fill the result in
  69767. * @returns the result Color4
  69768. */
  69769. multiplyToRef(color: Color4, result: Color4): Color4;
  69770. /**
  69771. * Creates a string with the Color4 current values
  69772. * @returns the string representation of the Color4 object
  69773. */
  69774. toString(): string;
  69775. /**
  69776. * Returns the string "Color4"
  69777. * @returns "Color4"
  69778. */
  69779. getClassName(): string;
  69780. /**
  69781. * Compute the Color4 hash code
  69782. * @returns an unique number that can be used to hash Color4 objects
  69783. */
  69784. getHashCode(): number;
  69785. /**
  69786. * Creates a new Color4 copied from the current one
  69787. * @returns a new Color4 object
  69788. */
  69789. clone(): Color4;
  69790. /**
  69791. * Copies the given Color4 values into the current one
  69792. * @param source defines the source Color4 object
  69793. * @returns the current updated Color4 object
  69794. */
  69795. copyFrom(source: Color4): Color4;
  69796. /**
  69797. * Copies the given float values into the current one
  69798. * @param r defines the red component to read from
  69799. * @param g defines the green component to read from
  69800. * @param b defines the blue component to read from
  69801. * @param a defines the alpha component to read from
  69802. * @returns the current updated Color4 object
  69803. */
  69804. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69805. /**
  69806. * Copies the given float values into the current one
  69807. * @param r defines the red component to read from
  69808. * @param g defines the green component to read from
  69809. * @param b defines the blue component to read from
  69810. * @param a defines the alpha component to read from
  69811. * @returns the current updated Color4 object
  69812. */
  69813. set(r: number, g: number, b: number, a: number): Color4;
  69814. /**
  69815. * Compute the Color4 hexadecimal code as a string
  69816. * @returns a string containing the hexadecimal representation of the Color4 object
  69817. */
  69818. toHexString(): string;
  69819. /**
  69820. * Computes a new Color4 converted from the current one to linear space
  69821. * @returns a new Color4 object
  69822. */
  69823. toLinearSpace(): Color4;
  69824. /**
  69825. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69826. * @param convertedColor defines the Color4 object where to store the linear space version
  69827. * @returns the unmodified Color4
  69828. */
  69829. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69830. /**
  69831. * Computes a new Color4 converted from the current one to gamma space
  69832. * @returns a new Color4 object
  69833. */
  69834. toGammaSpace(): Color4;
  69835. /**
  69836. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69837. * @param convertedColor defines the Color4 object where to store the gamma space version
  69838. * @returns the unmodified Color4
  69839. */
  69840. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69841. /**
  69842. * Creates a new Color4 from the string containing valid hexadecimal values
  69843. * @param hex defines a string containing valid hexadecimal values
  69844. * @returns a new Color4 object
  69845. */
  69846. static FromHexString(hex: string): Color4;
  69847. /**
  69848. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69849. * @param left defines the start value
  69850. * @param right defines the end value
  69851. * @param amount defines the gradient factor
  69852. * @returns a new Color4 object
  69853. */
  69854. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69855. /**
  69856. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69857. * @param left defines the start value
  69858. * @param right defines the end value
  69859. * @param amount defines the gradient factor
  69860. * @param result defines the Color4 object where to store data
  69861. */
  69862. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69863. /**
  69864. * Creates a new Color4 from a Color3 and an alpha value
  69865. * @param color3 defines the source Color3 to read from
  69866. * @param alpha defines the alpha component (1.0 by default)
  69867. * @returns a new Color4 object
  69868. */
  69869. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69870. /**
  69871. * Creates a new Color4 from the starting index element of the given array
  69872. * @param array defines the source array to read from
  69873. * @param offset defines the offset in the source array
  69874. * @returns a new Color4 object
  69875. */
  69876. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69877. /**
  69878. * Creates a new Color3 from integer values (< 256)
  69879. * @param r defines the red component to read from (value between 0 and 255)
  69880. * @param g defines the green component to read from (value between 0 and 255)
  69881. * @param b defines the blue component to read from (value between 0 and 255)
  69882. * @param a defines the alpha component to read from (value between 0 and 255)
  69883. * @returns a new Color3 object
  69884. */
  69885. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69886. /**
  69887. * Check the content of a given array and convert it to an array containing RGBA data
  69888. * If the original array was already containing count * 4 values then it is returned directly
  69889. * @param colors defines the array to check
  69890. * @param count defines the number of RGBA data to expect
  69891. * @returns an array containing count * 4 values (RGBA)
  69892. */
  69893. static CheckColors4(colors: number[], count: number): number[];
  69894. }
  69895. /**
  69896. * @hidden
  69897. */
  69898. export class TmpColors {
  69899. static Color3: Color3[];
  69900. static Color4: Color4[];
  69901. }
  69902. }
  69903. declare module BABYLON {
  69904. /**
  69905. * Class representing spherical harmonics coefficients to the 3rd degree
  69906. */
  69907. export class SphericalHarmonics {
  69908. /**
  69909. * Defines whether or not the harmonics have been prescaled for rendering.
  69910. */
  69911. preScaled: boolean;
  69912. /**
  69913. * The l0,0 coefficients of the spherical harmonics
  69914. */
  69915. l00: Vector3;
  69916. /**
  69917. * The l1,-1 coefficients of the spherical harmonics
  69918. */
  69919. l1_1: Vector3;
  69920. /**
  69921. * The l1,0 coefficients of the spherical harmonics
  69922. */
  69923. l10: Vector3;
  69924. /**
  69925. * The l1,1 coefficients of the spherical harmonics
  69926. */
  69927. l11: Vector3;
  69928. /**
  69929. * The l2,-2 coefficients of the spherical harmonics
  69930. */
  69931. l2_2: Vector3;
  69932. /**
  69933. * The l2,-1 coefficients of the spherical harmonics
  69934. */
  69935. l2_1: Vector3;
  69936. /**
  69937. * The l2,0 coefficients of the spherical harmonics
  69938. */
  69939. l20: Vector3;
  69940. /**
  69941. * The l2,1 coefficients of the spherical harmonics
  69942. */
  69943. l21: Vector3;
  69944. /**
  69945. * The l2,2 coefficients of the spherical harmonics
  69946. */
  69947. l22: Vector3;
  69948. /**
  69949. * Adds a light to the spherical harmonics
  69950. * @param direction the direction of the light
  69951. * @param color the color of the light
  69952. * @param deltaSolidAngle the delta solid angle of the light
  69953. */
  69954. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69955. /**
  69956. * Scales the spherical harmonics by the given amount
  69957. * @param scale the amount to scale
  69958. */
  69959. scaleInPlace(scale: number): void;
  69960. /**
  69961. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69962. *
  69963. * ```
  69964. * E_lm = A_l * L_lm
  69965. * ```
  69966. *
  69967. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69968. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69969. * the scaling factors are given in equation 9.
  69970. */
  69971. convertIncidentRadianceToIrradiance(): void;
  69972. /**
  69973. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69974. *
  69975. * ```
  69976. * L = (1/pi) * E * rho
  69977. * ```
  69978. *
  69979. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69980. */
  69981. convertIrradianceToLambertianRadiance(): void;
  69982. /**
  69983. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69984. * required operations at run time.
  69985. *
  69986. * This is simply done by scaling back the SH with Ylm constants parameter.
  69987. * The trigonometric part being applied by the shader at run time.
  69988. */
  69989. preScaleForRendering(): void;
  69990. /**
  69991. * Constructs a spherical harmonics from an array.
  69992. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69993. * @returns the spherical harmonics
  69994. */
  69995. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69996. /**
  69997. * Gets the spherical harmonics from polynomial
  69998. * @param polynomial the spherical polynomial
  69999. * @returns the spherical harmonics
  70000. */
  70001. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70002. }
  70003. /**
  70004. * Class representing spherical polynomial coefficients to the 3rd degree
  70005. */
  70006. export class SphericalPolynomial {
  70007. private _harmonics;
  70008. /**
  70009. * The spherical harmonics used to create the polynomials.
  70010. */
  70011. readonly preScaledHarmonics: SphericalHarmonics;
  70012. /**
  70013. * The x coefficients of the spherical polynomial
  70014. */
  70015. x: Vector3;
  70016. /**
  70017. * The y coefficients of the spherical polynomial
  70018. */
  70019. y: Vector3;
  70020. /**
  70021. * The z coefficients of the spherical polynomial
  70022. */
  70023. z: Vector3;
  70024. /**
  70025. * The xx coefficients of the spherical polynomial
  70026. */
  70027. xx: Vector3;
  70028. /**
  70029. * The yy coefficients of the spherical polynomial
  70030. */
  70031. yy: Vector3;
  70032. /**
  70033. * The zz coefficients of the spherical polynomial
  70034. */
  70035. zz: Vector3;
  70036. /**
  70037. * The xy coefficients of the spherical polynomial
  70038. */
  70039. xy: Vector3;
  70040. /**
  70041. * The yz coefficients of the spherical polynomial
  70042. */
  70043. yz: Vector3;
  70044. /**
  70045. * The zx coefficients of the spherical polynomial
  70046. */
  70047. zx: Vector3;
  70048. /**
  70049. * Adds an ambient color to the spherical polynomial
  70050. * @param color the color to add
  70051. */
  70052. addAmbient(color: Color3): void;
  70053. /**
  70054. * Scales the spherical polynomial by the given amount
  70055. * @param scale the amount to scale
  70056. */
  70057. scaleInPlace(scale: number): void;
  70058. /**
  70059. * Gets the spherical polynomial from harmonics
  70060. * @param harmonics the spherical harmonics
  70061. * @returns the spherical polynomial
  70062. */
  70063. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70064. /**
  70065. * Constructs a spherical polynomial from an array.
  70066. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70067. * @returns the spherical polynomial
  70068. */
  70069. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70070. }
  70071. }
  70072. declare module BABYLON {
  70073. /**
  70074. * Define options used to create a render target texture
  70075. */
  70076. export class RenderTargetCreationOptions {
  70077. /**
  70078. * Specifies is mipmaps must be generated
  70079. */
  70080. generateMipMaps?: boolean;
  70081. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70082. generateDepthBuffer?: boolean;
  70083. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70084. generateStencilBuffer?: boolean;
  70085. /** Defines texture type (int by default) */
  70086. type?: number;
  70087. /** Defines sampling mode (trilinear by default) */
  70088. samplingMode?: number;
  70089. /** Defines format (RGBA by default) */
  70090. format?: number;
  70091. }
  70092. }
  70093. declare module BABYLON {
  70094. /**
  70095. * @hidden
  70096. **/
  70097. export class _AlphaState {
  70098. private _isAlphaBlendDirty;
  70099. private _isBlendFunctionParametersDirty;
  70100. private _isBlendEquationParametersDirty;
  70101. private _isBlendConstantsDirty;
  70102. private _alphaBlend;
  70103. private _blendFunctionParameters;
  70104. private _blendEquationParameters;
  70105. private _blendConstants;
  70106. /**
  70107. * Initializes the state.
  70108. */
  70109. constructor();
  70110. readonly isDirty: boolean;
  70111. alphaBlend: boolean;
  70112. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70113. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70114. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70115. reset(): void;
  70116. apply(gl: WebGLRenderingContext): void;
  70117. }
  70118. }
  70119. declare module BABYLON {
  70120. /**
  70121. * @hidden
  70122. **/
  70123. export class _DepthCullingState {
  70124. private _isDepthTestDirty;
  70125. private _isDepthMaskDirty;
  70126. private _isDepthFuncDirty;
  70127. private _isCullFaceDirty;
  70128. private _isCullDirty;
  70129. private _isZOffsetDirty;
  70130. private _isFrontFaceDirty;
  70131. private _depthTest;
  70132. private _depthMask;
  70133. private _depthFunc;
  70134. private _cull;
  70135. private _cullFace;
  70136. private _zOffset;
  70137. private _frontFace;
  70138. /**
  70139. * Initializes the state.
  70140. */
  70141. constructor();
  70142. readonly isDirty: boolean;
  70143. zOffset: number;
  70144. cullFace: Nullable<number>;
  70145. cull: Nullable<boolean>;
  70146. depthFunc: Nullable<number>;
  70147. depthMask: boolean;
  70148. depthTest: boolean;
  70149. frontFace: Nullable<number>;
  70150. reset(): void;
  70151. apply(gl: WebGLRenderingContext): void;
  70152. }
  70153. }
  70154. declare module BABYLON {
  70155. /**
  70156. * @hidden
  70157. **/
  70158. export class _StencilState {
  70159. /** 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 */
  70160. static readonly ALWAYS: number;
  70161. /** Passed to stencilOperation to specify that stencil value must be kept */
  70162. static readonly KEEP: number;
  70163. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70164. static readonly REPLACE: number;
  70165. private _isStencilTestDirty;
  70166. private _isStencilMaskDirty;
  70167. private _isStencilFuncDirty;
  70168. private _isStencilOpDirty;
  70169. private _stencilTest;
  70170. private _stencilMask;
  70171. private _stencilFunc;
  70172. private _stencilFuncRef;
  70173. private _stencilFuncMask;
  70174. private _stencilOpStencilFail;
  70175. private _stencilOpDepthFail;
  70176. private _stencilOpStencilDepthPass;
  70177. readonly isDirty: boolean;
  70178. stencilFunc: number;
  70179. stencilFuncRef: number;
  70180. stencilFuncMask: number;
  70181. stencilOpStencilFail: number;
  70182. stencilOpDepthFail: number;
  70183. stencilOpStencilDepthPass: number;
  70184. stencilMask: number;
  70185. stencilTest: boolean;
  70186. constructor();
  70187. reset(): void;
  70188. apply(gl: WebGLRenderingContext): void;
  70189. }
  70190. }
  70191. declare module BABYLON {
  70192. /**
  70193. * @hidden
  70194. **/
  70195. export class _TimeToken {
  70196. _startTimeQuery: Nullable<WebGLQuery>;
  70197. _endTimeQuery: Nullable<WebGLQuery>;
  70198. _timeElapsedQuery: Nullable<WebGLQuery>;
  70199. _timeElapsedQueryEnded: boolean;
  70200. }
  70201. }
  70202. declare module BABYLON {
  70203. /**
  70204. * Class used to evalaute queries containing `and` and `or` operators
  70205. */
  70206. export class AndOrNotEvaluator {
  70207. /**
  70208. * Evaluate a query
  70209. * @param query defines the query to evaluate
  70210. * @param evaluateCallback defines the callback used to filter result
  70211. * @returns true if the query matches
  70212. */
  70213. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70214. private static _HandleParenthesisContent;
  70215. private static _SimplifyNegation;
  70216. }
  70217. }
  70218. declare module BABYLON {
  70219. /**
  70220. * Class used to store custom tags
  70221. */
  70222. export class Tags {
  70223. /**
  70224. * Adds support for tags on the given object
  70225. * @param obj defines the object to use
  70226. */
  70227. static EnableFor(obj: any): void;
  70228. /**
  70229. * Removes tags support
  70230. * @param obj defines the object to use
  70231. */
  70232. static DisableFor(obj: any): void;
  70233. /**
  70234. * Gets a boolean indicating if the given object has tags
  70235. * @param obj defines the object to use
  70236. * @returns a boolean
  70237. */
  70238. static HasTags(obj: any): boolean;
  70239. /**
  70240. * Gets the tags available on a given object
  70241. * @param obj defines the object to use
  70242. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70243. * @returns the tags
  70244. */
  70245. static GetTags(obj: any, asString?: boolean): any;
  70246. /**
  70247. * Adds tags to an object
  70248. * @param obj defines the object to use
  70249. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70250. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70251. */
  70252. static AddTagsTo(obj: any, tagsString: string): void;
  70253. /**
  70254. * @hidden
  70255. */
  70256. static _AddTagTo(obj: any, tag: string): void;
  70257. /**
  70258. * Removes specific tags from a specific object
  70259. * @param obj defines the object to use
  70260. * @param tagsString defines the tags to remove
  70261. */
  70262. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70263. /**
  70264. * @hidden
  70265. */
  70266. static _RemoveTagFrom(obj: any, tag: string): void;
  70267. /**
  70268. * Defines if tags hosted on an object match a given query
  70269. * @param obj defines the object to use
  70270. * @param tagsQuery defines the tag query
  70271. * @returns a boolean
  70272. */
  70273. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70274. }
  70275. }
  70276. declare module BABYLON {
  70277. /**
  70278. * Defines potential orientation for back face culling
  70279. */
  70280. export enum Orientation {
  70281. /**
  70282. * Clockwise
  70283. */
  70284. CW = 0,
  70285. /** Counter clockwise */
  70286. CCW = 1
  70287. }
  70288. /** Class used to represent a Bezier curve */
  70289. export class BezierCurve {
  70290. /**
  70291. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70292. * @param t defines the time
  70293. * @param x1 defines the left coordinate on X axis
  70294. * @param y1 defines the left coordinate on Y axis
  70295. * @param x2 defines the right coordinate on X axis
  70296. * @param y2 defines the right coordinate on Y axis
  70297. * @returns the interpolated value
  70298. */
  70299. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70300. }
  70301. /**
  70302. * Defines angle representation
  70303. */
  70304. export class Angle {
  70305. private _radians;
  70306. /**
  70307. * Creates an Angle object of "radians" radians (float).
  70308. * @param radians the angle in radians
  70309. */
  70310. constructor(radians: number);
  70311. /**
  70312. * Get value in degrees
  70313. * @returns the Angle value in degrees (float)
  70314. */
  70315. degrees(): number;
  70316. /**
  70317. * Get value in radians
  70318. * @returns the Angle value in radians (float)
  70319. */
  70320. radians(): number;
  70321. /**
  70322. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70323. * @param a defines first vector
  70324. * @param b defines second vector
  70325. * @returns a new Angle
  70326. */
  70327. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70328. /**
  70329. * Gets a new Angle object from the given float in radians
  70330. * @param radians defines the angle value in radians
  70331. * @returns a new Angle
  70332. */
  70333. static FromRadians(radians: number): Angle;
  70334. /**
  70335. * Gets a new Angle object from the given float in degrees
  70336. * @param degrees defines the angle value in degrees
  70337. * @returns a new Angle
  70338. */
  70339. static FromDegrees(degrees: number): Angle;
  70340. }
  70341. /**
  70342. * This represents an arc in a 2d space.
  70343. */
  70344. export class Arc2 {
  70345. /** Defines the start point of the arc */
  70346. startPoint: Vector2;
  70347. /** Defines the mid point of the arc */
  70348. midPoint: Vector2;
  70349. /** Defines the end point of the arc */
  70350. endPoint: Vector2;
  70351. /**
  70352. * Defines the center point of the arc.
  70353. */
  70354. centerPoint: Vector2;
  70355. /**
  70356. * Defines the radius of the arc.
  70357. */
  70358. radius: number;
  70359. /**
  70360. * Defines the angle of the arc (from mid point to end point).
  70361. */
  70362. angle: Angle;
  70363. /**
  70364. * Defines the start angle of the arc (from start point to middle point).
  70365. */
  70366. startAngle: Angle;
  70367. /**
  70368. * Defines the orientation of the arc (clock wise/counter clock wise).
  70369. */
  70370. orientation: Orientation;
  70371. /**
  70372. * Creates an Arc object from the three given points : start, middle and end.
  70373. * @param startPoint Defines the start point of the arc
  70374. * @param midPoint Defines the midlle point of the arc
  70375. * @param endPoint Defines the end point of the arc
  70376. */
  70377. constructor(
  70378. /** Defines the start point of the arc */
  70379. startPoint: Vector2,
  70380. /** Defines the mid point of the arc */
  70381. midPoint: Vector2,
  70382. /** Defines the end point of the arc */
  70383. endPoint: Vector2);
  70384. }
  70385. /**
  70386. * Represents a 2D path made up of multiple 2D points
  70387. */
  70388. export class Path2 {
  70389. private _points;
  70390. private _length;
  70391. /**
  70392. * If the path start and end point are the same
  70393. */
  70394. closed: boolean;
  70395. /**
  70396. * Creates a Path2 object from the starting 2D coordinates x and y.
  70397. * @param x the starting points x value
  70398. * @param y the starting points y value
  70399. */
  70400. constructor(x: number, y: number);
  70401. /**
  70402. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70403. * @param x the added points x value
  70404. * @param y the added points y value
  70405. * @returns the updated Path2.
  70406. */
  70407. addLineTo(x: number, y: number): Path2;
  70408. /**
  70409. * 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.
  70410. * @param midX middle point x value
  70411. * @param midY middle point y value
  70412. * @param endX end point x value
  70413. * @param endY end point y value
  70414. * @param numberOfSegments (default: 36)
  70415. * @returns the updated Path2.
  70416. */
  70417. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70418. /**
  70419. * Closes the Path2.
  70420. * @returns the Path2.
  70421. */
  70422. close(): Path2;
  70423. /**
  70424. * Gets the sum of the distance between each sequential point in the path
  70425. * @returns the Path2 total length (float).
  70426. */
  70427. length(): number;
  70428. /**
  70429. * Gets the points which construct the path
  70430. * @returns the Path2 internal array of points.
  70431. */
  70432. getPoints(): Vector2[];
  70433. /**
  70434. * Retreives the point at the distance aways from the starting point
  70435. * @param normalizedLengthPosition the length along the path to retreive the point from
  70436. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70437. */
  70438. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70439. /**
  70440. * Creates a new path starting from an x and y position
  70441. * @param x starting x value
  70442. * @param y starting y value
  70443. * @returns a new Path2 starting at the coordinates (x, y).
  70444. */
  70445. static StartingAt(x: number, y: number): Path2;
  70446. }
  70447. /**
  70448. * Represents a 3D path made up of multiple 3D points
  70449. */
  70450. export class Path3D {
  70451. /**
  70452. * an array of Vector3, the curve axis of the Path3D
  70453. */
  70454. path: Vector3[];
  70455. private _curve;
  70456. private _distances;
  70457. private _tangents;
  70458. private _normals;
  70459. private _binormals;
  70460. private _raw;
  70461. /**
  70462. * new Path3D(path, normal, raw)
  70463. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70464. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70465. * @param path an array of Vector3, the curve axis of the Path3D
  70466. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70467. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70468. */
  70469. constructor(
  70470. /**
  70471. * an array of Vector3, the curve axis of the Path3D
  70472. */
  70473. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70474. /**
  70475. * Returns the Path3D array of successive Vector3 designing its curve.
  70476. * @returns the Path3D array of successive Vector3 designing its curve.
  70477. */
  70478. getCurve(): Vector3[];
  70479. /**
  70480. * Returns an array populated with tangent vectors on each Path3D curve point.
  70481. * @returns an array populated with tangent vectors on each Path3D curve point.
  70482. */
  70483. getTangents(): Vector3[];
  70484. /**
  70485. * Returns an array populated with normal vectors on each Path3D curve point.
  70486. * @returns an array populated with normal vectors on each Path3D curve point.
  70487. */
  70488. getNormals(): Vector3[];
  70489. /**
  70490. * Returns an array populated with binormal vectors on each Path3D curve point.
  70491. * @returns an array populated with binormal vectors on each Path3D curve point.
  70492. */
  70493. getBinormals(): Vector3[];
  70494. /**
  70495. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70496. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70497. */
  70498. getDistances(): number[];
  70499. /**
  70500. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70501. * @param path path which all values are copied into the curves points
  70502. * @param firstNormal which should be projected onto the curve
  70503. * @returns the same object updated.
  70504. */
  70505. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70506. private _compute;
  70507. private _getFirstNonNullVector;
  70508. private _getLastNonNullVector;
  70509. private _normalVector;
  70510. }
  70511. /**
  70512. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70513. * A Curve3 is designed from a series of successive Vector3.
  70514. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70515. */
  70516. export class Curve3 {
  70517. private _points;
  70518. private _length;
  70519. /**
  70520. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70521. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70522. * @param v1 (Vector3) the control point
  70523. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70524. * @param nbPoints (integer) the wanted number of points in the curve
  70525. * @returns the created Curve3
  70526. */
  70527. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70528. /**
  70529. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70530. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70531. * @param v1 (Vector3) the first control point
  70532. * @param v2 (Vector3) the second control point
  70533. * @param v3 (Vector3) the end point of the Cubic Bezier
  70534. * @param nbPoints (integer) the wanted number of points in the curve
  70535. * @returns the created Curve3
  70536. */
  70537. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70538. /**
  70539. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70540. * @param p1 (Vector3) the origin point of the Hermite Spline
  70541. * @param t1 (Vector3) the tangent vector at the origin point
  70542. * @param p2 (Vector3) the end point of the Hermite Spline
  70543. * @param t2 (Vector3) the tangent vector at the end point
  70544. * @param nbPoints (integer) the wanted number of points in the curve
  70545. * @returns the created Curve3
  70546. */
  70547. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70548. /**
  70549. * Returns a Curve3 object along a CatmullRom Spline curve :
  70550. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70551. * @param nbPoints (integer) the wanted number of points between each curve control points
  70552. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70553. * @returns the created Curve3
  70554. */
  70555. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70556. /**
  70557. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70558. * A Curve3 is designed from a series of successive Vector3.
  70559. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70560. * @param points points which make up the curve
  70561. */
  70562. constructor(points: Vector3[]);
  70563. /**
  70564. * @returns the Curve3 stored array of successive Vector3
  70565. */
  70566. getPoints(): Vector3[];
  70567. /**
  70568. * @returns the computed length (float) of the curve.
  70569. */
  70570. length(): number;
  70571. /**
  70572. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70573. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70574. * curveA and curveB keep unchanged.
  70575. * @param curve the curve to continue from this curve
  70576. * @returns the newly constructed curve
  70577. */
  70578. continue(curve: DeepImmutable<Curve3>): Curve3;
  70579. private _computeLength;
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /**
  70584. * This represents the main contract an easing function should follow.
  70585. * Easing functions are used throughout the animation system.
  70586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70587. */
  70588. export interface IEasingFunction {
  70589. /**
  70590. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70591. * of the easing function.
  70592. * The link below provides some of the most common examples of easing functions.
  70593. * @see https://easings.net/
  70594. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70595. * @returns the corresponding value on the curve defined by the easing function
  70596. */
  70597. ease(gradient: number): number;
  70598. }
  70599. /**
  70600. * Base class used for every default easing function.
  70601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70602. */
  70603. export class EasingFunction implements IEasingFunction {
  70604. /**
  70605. * Interpolation follows the mathematical formula associated with the easing function.
  70606. */
  70607. static readonly EASINGMODE_EASEIN: number;
  70608. /**
  70609. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70610. */
  70611. static readonly EASINGMODE_EASEOUT: number;
  70612. /**
  70613. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70614. */
  70615. static readonly EASINGMODE_EASEINOUT: number;
  70616. private _easingMode;
  70617. /**
  70618. * Sets the easing mode of the current function.
  70619. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70620. */
  70621. setEasingMode(easingMode: number): void;
  70622. /**
  70623. * Gets the current easing mode.
  70624. * @returns the easing mode
  70625. */
  70626. getEasingMode(): number;
  70627. /**
  70628. * @hidden
  70629. */
  70630. easeInCore(gradient: number): number;
  70631. /**
  70632. * Given an input gradient between 0 and 1, this returns the corresponding value
  70633. * of the easing function.
  70634. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70635. * @returns the corresponding value on the curve defined by the easing function
  70636. */
  70637. ease(gradient: number): number;
  70638. }
  70639. /**
  70640. * Easing function with a circle shape (see link below).
  70641. * @see https://easings.net/#easeInCirc
  70642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70643. */
  70644. export class CircleEase extends EasingFunction implements IEasingFunction {
  70645. /** @hidden */
  70646. easeInCore(gradient: number): number;
  70647. }
  70648. /**
  70649. * Easing function with a ease back shape (see link below).
  70650. * @see https://easings.net/#easeInBack
  70651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70652. */
  70653. export class BackEase extends EasingFunction implements IEasingFunction {
  70654. /** Defines the amplitude of the function */
  70655. amplitude: number;
  70656. /**
  70657. * Instantiates a back ease easing
  70658. * @see https://easings.net/#easeInBack
  70659. * @param amplitude Defines the amplitude of the function
  70660. */
  70661. constructor(
  70662. /** Defines the amplitude of the function */
  70663. amplitude?: number);
  70664. /** @hidden */
  70665. easeInCore(gradient: number): number;
  70666. }
  70667. /**
  70668. * Easing function with a bouncing shape (see link below).
  70669. * @see https://easings.net/#easeInBounce
  70670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70671. */
  70672. export class BounceEase extends EasingFunction implements IEasingFunction {
  70673. /** Defines the number of bounces */
  70674. bounces: number;
  70675. /** Defines the amplitude of the bounce */
  70676. bounciness: number;
  70677. /**
  70678. * Instantiates a bounce easing
  70679. * @see https://easings.net/#easeInBounce
  70680. * @param bounces Defines the number of bounces
  70681. * @param bounciness Defines the amplitude of the bounce
  70682. */
  70683. constructor(
  70684. /** Defines the number of bounces */
  70685. bounces?: number,
  70686. /** Defines the amplitude of the bounce */
  70687. bounciness?: number);
  70688. /** @hidden */
  70689. easeInCore(gradient: number): number;
  70690. }
  70691. /**
  70692. * Easing function with a power of 3 shape (see link below).
  70693. * @see https://easings.net/#easeInCubic
  70694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70695. */
  70696. export class CubicEase extends EasingFunction implements IEasingFunction {
  70697. /** @hidden */
  70698. easeInCore(gradient: number): number;
  70699. }
  70700. /**
  70701. * Easing function with an elastic shape (see link below).
  70702. * @see https://easings.net/#easeInElastic
  70703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70704. */
  70705. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70706. /** Defines the number of oscillations*/
  70707. oscillations: number;
  70708. /** Defines the amplitude of the oscillations*/
  70709. springiness: number;
  70710. /**
  70711. * Instantiates an elastic easing function
  70712. * @see https://easings.net/#easeInElastic
  70713. * @param oscillations Defines the number of oscillations
  70714. * @param springiness Defines the amplitude of the oscillations
  70715. */
  70716. constructor(
  70717. /** Defines the number of oscillations*/
  70718. oscillations?: number,
  70719. /** Defines the amplitude of the oscillations*/
  70720. springiness?: number);
  70721. /** @hidden */
  70722. easeInCore(gradient: number): number;
  70723. }
  70724. /**
  70725. * Easing function with an exponential shape (see link below).
  70726. * @see https://easings.net/#easeInExpo
  70727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70728. */
  70729. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70730. /** Defines the exponent of the function */
  70731. exponent: number;
  70732. /**
  70733. * Instantiates an exponential easing function
  70734. * @see https://easings.net/#easeInExpo
  70735. * @param exponent Defines the exponent of the function
  70736. */
  70737. constructor(
  70738. /** Defines the exponent of the function */
  70739. exponent?: number);
  70740. /** @hidden */
  70741. easeInCore(gradient: number): number;
  70742. }
  70743. /**
  70744. * Easing function with a power shape (see link below).
  70745. * @see https://easings.net/#easeInQuad
  70746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70747. */
  70748. export class PowerEase extends EasingFunction implements IEasingFunction {
  70749. /** Defines the power of the function */
  70750. power: number;
  70751. /**
  70752. * Instantiates an power base easing function
  70753. * @see https://easings.net/#easeInQuad
  70754. * @param power Defines the power of the function
  70755. */
  70756. constructor(
  70757. /** Defines the power of the function */
  70758. power?: number);
  70759. /** @hidden */
  70760. easeInCore(gradient: number): number;
  70761. }
  70762. /**
  70763. * Easing function with a power of 2 shape (see link below).
  70764. * @see https://easings.net/#easeInQuad
  70765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70766. */
  70767. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70768. /** @hidden */
  70769. easeInCore(gradient: number): number;
  70770. }
  70771. /**
  70772. * Easing function with a power of 4 shape (see link below).
  70773. * @see https://easings.net/#easeInQuart
  70774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70775. */
  70776. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70777. /** @hidden */
  70778. easeInCore(gradient: number): number;
  70779. }
  70780. /**
  70781. * Easing function with a power of 5 shape (see link below).
  70782. * @see https://easings.net/#easeInQuint
  70783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70784. */
  70785. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70786. /** @hidden */
  70787. easeInCore(gradient: number): number;
  70788. }
  70789. /**
  70790. * Easing function with a sin shape (see link below).
  70791. * @see https://easings.net/#easeInSine
  70792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70793. */
  70794. export class SineEase extends EasingFunction implements IEasingFunction {
  70795. /** @hidden */
  70796. easeInCore(gradient: number): number;
  70797. }
  70798. /**
  70799. * Easing function with a bezier shape (see link below).
  70800. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70802. */
  70803. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70804. /** Defines the x component of the start tangent in the bezier curve */
  70805. x1: number;
  70806. /** Defines the y component of the start tangent in the bezier curve */
  70807. y1: number;
  70808. /** Defines the x component of the end tangent in the bezier curve */
  70809. x2: number;
  70810. /** Defines the y component of the end tangent in the bezier curve */
  70811. y2: number;
  70812. /**
  70813. * Instantiates a bezier function
  70814. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70815. * @param x1 Defines the x component of the start tangent in the bezier curve
  70816. * @param y1 Defines the y component of the start tangent in the bezier curve
  70817. * @param x2 Defines the x component of the end tangent in the bezier curve
  70818. * @param y2 Defines the y component of the end tangent in the bezier curve
  70819. */
  70820. constructor(
  70821. /** Defines the x component of the start tangent in the bezier curve */
  70822. x1?: number,
  70823. /** Defines the y component of the start tangent in the bezier curve */
  70824. y1?: number,
  70825. /** Defines the x component of the end tangent in the bezier curve */
  70826. x2?: number,
  70827. /** Defines the y component of the end tangent in the bezier curve */
  70828. y2?: number);
  70829. /** @hidden */
  70830. easeInCore(gradient: number): number;
  70831. }
  70832. }
  70833. declare module BABYLON {
  70834. /**
  70835. * Defines an interface which represents an animation key frame
  70836. */
  70837. export interface IAnimationKey {
  70838. /**
  70839. * Frame of the key frame
  70840. */
  70841. frame: number;
  70842. /**
  70843. * Value at the specifies key frame
  70844. */
  70845. value: any;
  70846. /**
  70847. * The input tangent for the cubic hermite spline
  70848. */
  70849. inTangent?: any;
  70850. /**
  70851. * The output tangent for the cubic hermite spline
  70852. */
  70853. outTangent?: any;
  70854. /**
  70855. * The animation interpolation type
  70856. */
  70857. interpolation?: AnimationKeyInterpolation;
  70858. }
  70859. /**
  70860. * Enum for the animation key frame interpolation type
  70861. */
  70862. export enum AnimationKeyInterpolation {
  70863. /**
  70864. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70865. */
  70866. STEP = 1
  70867. }
  70868. }
  70869. declare module BABYLON {
  70870. /**
  70871. * Represents the range of an animation
  70872. */
  70873. export class AnimationRange {
  70874. /**The name of the animation range**/
  70875. name: string;
  70876. /**The starting frame of the animation */
  70877. from: number;
  70878. /**The ending frame of the animation*/
  70879. to: number;
  70880. /**
  70881. * Initializes the range of an animation
  70882. * @param name The name of the animation range
  70883. * @param from The starting frame of the animation
  70884. * @param to The ending frame of the animation
  70885. */
  70886. constructor(
  70887. /**The name of the animation range**/
  70888. name: string,
  70889. /**The starting frame of the animation */
  70890. from: number,
  70891. /**The ending frame of the animation*/
  70892. to: number);
  70893. /**
  70894. * Makes a copy of the animation range
  70895. * @returns A copy of the animation range
  70896. */
  70897. clone(): AnimationRange;
  70898. }
  70899. }
  70900. declare module BABYLON {
  70901. /**
  70902. * Composed of a frame, and an action function
  70903. */
  70904. export class AnimationEvent {
  70905. /** The frame for which the event is triggered **/
  70906. frame: number;
  70907. /** The event to perform when triggered **/
  70908. action: (currentFrame: number) => void;
  70909. /** Specifies if the event should be triggered only once**/
  70910. onlyOnce?: boolean | undefined;
  70911. /**
  70912. * Specifies if the animation event is done
  70913. */
  70914. isDone: boolean;
  70915. /**
  70916. * Initializes the animation event
  70917. * @param frame The frame for which the event is triggered
  70918. * @param action The event to perform when triggered
  70919. * @param onlyOnce Specifies if the event should be triggered only once
  70920. */
  70921. constructor(
  70922. /** The frame for which the event is triggered **/
  70923. frame: number,
  70924. /** The event to perform when triggered **/
  70925. action: (currentFrame: number) => void,
  70926. /** Specifies if the event should be triggered only once**/
  70927. onlyOnce?: boolean | undefined);
  70928. /** @hidden */
  70929. _clone(): AnimationEvent;
  70930. }
  70931. }
  70932. declare module BABYLON {
  70933. /**
  70934. * Interface used to define a behavior
  70935. */
  70936. export interface Behavior<T> {
  70937. /** gets or sets behavior's name */
  70938. name: string;
  70939. /**
  70940. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70941. */
  70942. init(): void;
  70943. /**
  70944. * Called when the behavior is attached to a target
  70945. * @param target defines the target where the behavior is attached to
  70946. */
  70947. attach(target: T): void;
  70948. /**
  70949. * Called when the behavior is detached from its target
  70950. */
  70951. detach(): void;
  70952. }
  70953. /**
  70954. * Interface implemented by classes supporting behaviors
  70955. */
  70956. export interface IBehaviorAware<T> {
  70957. /**
  70958. * Attach a behavior
  70959. * @param behavior defines the behavior to attach
  70960. * @returns the current host
  70961. */
  70962. addBehavior(behavior: Behavior<T>): T;
  70963. /**
  70964. * Remove a behavior from the current object
  70965. * @param behavior defines the behavior to detach
  70966. * @returns the current host
  70967. */
  70968. removeBehavior(behavior: Behavior<T>): T;
  70969. /**
  70970. * Gets a behavior using its name to search
  70971. * @param name defines the name to search
  70972. * @returns the behavior or null if not found
  70973. */
  70974. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /**
  70979. * Defines an array and its length.
  70980. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70981. */
  70982. export interface ISmartArrayLike<T> {
  70983. /**
  70984. * The data of the array.
  70985. */
  70986. data: Array<T>;
  70987. /**
  70988. * The active length of the array.
  70989. */
  70990. length: number;
  70991. }
  70992. /**
  70993. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70994. */
  70995. export class SmartArray<T> implements ISmartArrayLike<T> {
  70996. /**
  70997. * The full set of data from the array.
  70998. */
  70999. data: Array<T>;
  71000. /**
  71001. * The active length of the array.
  71002. */
  71003. length: number;
  71004. protected _id: number;
  71005. /**
  71006. * Instantiates a Smart Array.
  71007. * @param capacity defines the default capacity of the array.
  71008. */
  71009. constructor(capacity: number);
  71010. /**
  71011. * Pushes a value at the end of the active data.
  71012. * @param value defines the object to push in the array.
  71013. */
  71014. push(value: T): void;
  71015. /**
  71016. * Iterates over the active data and apply the lambda to them.
  71017. * @param func defines the action to apply on each value.
  71018. */
  71019. forEach(func: (content: T) => void): void;
  71020. /**
  71021. * Sorts the full sets of data.
  71022. * @param compareFn defines the comparison function to apply.
  71023. */
  71024. sort(compareFn: (a: T, b: T) => number): void;
  71025. /**
  71026. * Resets the active data to an empty array.
  71027. */
  71028. reset(): void;
  71029. /**
  71030. * Releases all the data from the array as well as the array.
  71031. */
  71032. dispose(): void;
  71033. /**
  71034. * Concats the active data with a given array.
  71035. * @param array defines the data to concatenate with.
  71036. */
  71037. concat(array: any): void;
  71038. /**
  71039. * Returns the position of a value in the active data.
  71040. * @param value defines the value to find the index for
  71041. * @returns the index if found in the active data otherwise -1
  71042. */
  71043. indexOf(value: T): number;
  71044. /**
  71045. * Returns whether an element is part of the active data.
  71046. * @param value defines the value to look for
  71047. * @returns true if found in the active data otherwise false
  71048. */
  71049. contains(value: T): boolean;
  71050. private static _GlobalId;
  71051. }
  71052. /**
  71053. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71054. * The data in this array can only be present once
  71055. */
  71056. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71057. private _duplicateId;
  71058. /**
  71059. * Pushes a value at the end of the active data.
  71060. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71061. * @param value defines the object to push in the array.
  71062. */
  71063. push(value: T): void;
  71064. /**
  71065. * Pushes a value at the end of the active data.
  71066. * If the data is already present, it won t be added again
  71067. * @param value defines the object to push in the array.
  71068. * @returns true if added false if it was already present
  71069. */
  71070. pushNoDuplicate(value: T): boolean;
  71071. /**
  71072. * Resets the active data to an empty array.
  71073. */
  71074. reset(): void;
  71075. /**
  71076. * Concats the active data with a given array.
  71077. * This ensures no dupplicate will be present in the result.
  71078. * @param array defines the data to concatenate with.
  71079. */
  71080. concatWithNoDuplicate(array: any): void;
  71081. }
  71082. }
  71083. declare module BABYLON {
  71084. /**
  71085. * @ignore
  71086. * This is a list of all the different input types that are available in the application.
  71087. * Fo instance: ArcRotateCameraGamepadInput...
  71088. */
  71089. export var CameraInputTypes: {};
  71090. /**
  71091. * This is the contract to implement in order to create a new input class.
  71092. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71093. */
  71094. export interface ICameraInput<TCamera extends Camera> {
  71095. /**
  71096. * Defines the camera the input is attached to.
  71097. */
  71098. camera: Nullable<TCamera>;
  71099. /**
  71100. * Gets the class name of the current intput.
  71101. * @returns the class name
  71102. */
  71103. getClassName(): string;
  71104. /**
  71105. * Get the friendly name associated with the input class.
  71106. * @returns the input friendly name
  71107. */
  71108. getSimpleName(): string;
  71109. /**
  71110. * Attach the input controls to a specific dom element to get the input from.
  71111. * @param element Defines the element the controls should be listened from
  71112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71113. */
  71114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71115. /**
  71116. * Detach the current controls from the specified dom element.
  71117. * @param element Defines the element to stop listening the inputs from
  71118. */
  71119. detachControl(element: Nullable<HTMLElement>): void;
  71120. /**
  71121. * Update the current camera state depending on the inputs that have been used this frame.
  71122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71123. */
  71124. checkInputs?: () => void;
  71125. }
  71126. /**
  71127. * Represents a map of input types to input instance or input index to input instance.
  71128. */
  71129. export interface CameraInputsMap<TCamera extends Camera> {
  71130. /**
  71131. * Accessor to the input by input type.
  71132. */
  71133. [name: string]: ICameraInput<TCamera>;
  71134. /**
  71135. * Accessor to the input by input index.
  71136. */
  71137. [idx: number]: ICameraInput<TCamera>;
  71138. }
  71139. /**
  71140. * This represents the input manager used within a camera.
  71141. * It helps dealing with all the different kind of input attached to a camera.
  71142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71143. */
  71144. export class CameraInputsManager<TCamera extends Camera> {
  71145. /**
  71146. * Defines the list of inputs attahed to the camera.
  71147. */
  71148. attached: CameraInputsMap<TCamera>;
  71149. /**
  71150. * Defines the dom element the camera is collecting inputs from.
  71151. * This is null if the controls have not been attached.
  71152. */
  71153. attachedElement: Nullable<HTMLElement>;
  71154. /**
  71155. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71156. */
  71157. noPreventDefault: boolean;
  71158. /**
  71159. * Defined the camera the input manager belongs to.
  71160. */
  71161. camera: TCamera;
  71162. /**
  71163. * Update the current camera state depending on the inputs that have been used this frame.
  71164. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71165. */
  71166. checkInputs: () => void;
  71167. /**
  71168. * Instantiate a new Camera Input Manager.
  71169. * @param camera Defines the camera the input manager blongs to
  71170. */
  71171. constructor(camera: TCamera);
  71172. /**
  71173. * Add an input method to a camera
  71174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71175. * @param input camera input method
  71176. */
  71177. add(input: ICameraInput<TCamera>): void;
  71178. /**
  71179. * Remove a specific input method from a camera
  71180. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71181. * @param inputToRemove camera input method
  71182. */
  71183. remove(inputToRemove: ICameraInput<TCamera>): void;
  71184. /**
  71185. * Remove a specific input type from a camera
  71186. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71187. * @param inputType the type of the input to remove
  71188. */
  71189. removeByType(inputType: string): void;
  71190. private _addCheckInputs;
  71191. /**
  71192. * Attach the input controls to the currently attached dom element to listen the events from.
  71193. * @param input Defines the input to attach
  71194. */
  71195. attachInput(input: ICameraInput<TCamera>): void;
  71196. /**
  71197. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71198. * @param element Defines the dom element to collect the events from
  71199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71200. */
  71201. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71202. /**
  71203. * Detach the current manager inputs controls from a specific dom element.
  71204. * @param element Defines the dom element to collect the events from
  71205. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71206. */
  71207. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71208. /**
  71209. * Rebuild the dynamic inputCheck function from the current list of
  71210. * defined inputs in the manager.
  71211. */
  71212. rebuildInputCheck(): void;
  71213. /**
  71214. * Remove all attached input methods from a camera
  71215. */
  71216. clear(): void;
  71217. /**
  71218. * Serialize the current input manager attached to a camera.
  71219. * This ensures than once parsed,
  71220. * the input associated to the camera will be identical to the current ones
  71221. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71222. */
  71223. serialize(serializedCamera: any): void;
  71224. /**
  71225. * Parses an input manager serialized JSON to restore the previous list of inputs
  71226. * and states associated to a camera.
  71227. * @param parsedCamera Defines the JSON to parse
  71228. */
  71229. parse(parsedCamera: any): void;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /**
  71234. * @hidden
  71235. */
  71236. export class IntersectionInfo {
  71237. bu: Nullable<number>;
  71238. bv: Nullable<number>;
  71239. distance: number;
  71240. faceId: number;
  71241. subMeshId: number;
  71242. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71243. }
  71244. }
  71245. declare module BABYLON {
  71246. /**
  71247. * Represens a plane by the equation ax + by + cz + d = 0
  71248. */
  71249. export class Plane {
  71250. private static _TmpMatrix;
  71251. /**
  71252. * Normal of the plane (a,b,c)
  71253. */
  71254. normal: Vector3;
  71255. /**
  71256. * d component of the plane
  71257. */
  71258. d: number;
  71259. /**
  71260. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71261. * @param a a component of the plane
  71262. * @param b b component of the plane
  71263. * @param c c component of the plane
  71264. * @param d d component of the plane
  71265. */
  71266. constructor(a: number, b: number, c: number, d: number);
  71267. /**
  71268. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71269. */
  71270. asArray(): number[];
  71271. /**
  71272. * @returns a new plane copied from the current Plane.
  71273. */
  71274. clone(): Plane;
  71275. /**
  71276. * @returns the string "Plane".
  71277. */
  71278. getClassName(): string;
  71279. /**
  71280. * @returns the Plane hash code.
  71281. */
  71282. getHashCode(): number;
  71283. /**
  71284. * Normalize the current Plane in place.
  71285. * @returns the updated Plane.
  71286. */
  71287. normalize(): Plane;
  71288. /**
  71289. * Applies a transformation the plane and returns the result
  71290. * @param transformation the transformation matrix to be applied to the plane
  71291. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71292. */
  71293. transform(transformation: DeepImmutable<Matrix>): Plane;
  71294. /**
  71295. * Calcualtte the dot product between the point and the plane normal
  71296. * @param point point to calculate the dot product with
  71297. * @returns the dot product (float) of the point coordinates and the plane normal.
  71298. */
  71299. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71300. /**
  71301. * Updates the current Plane from the plane defined by the three given points.
  71302. * @param point1 one of the points used to contruct the plane
  71303. * @param point2 one of the points used to contruct the plane
  71304. * @param point3 one of the points used to contruct the plane
  71305. * @returns the updated Plane.
  71306. */
  71307. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71308. /**
  71309. * Checks if the plane is facing a given direction
  71310. * @param direction the direction to check if the plane is facing
  71311. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71312. * @returns True is the vector "direction" is the same side than the plane normal.
  71313. */
  71314. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71315. /**
  71316. * Calculates the distance to a point
  71317. * @param point point to calculate distance to
  71318. * @returns the signed distance (float) from the given point to the Plane.
  71319. */
  71320. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71321. /**
  71322. * Creates a plane from an array
  71323. * @param array the array to create a plane from
  71324. * @returns a new Plane from the given array.
  71325. */
  71326. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71327. /**
  71328. * Creates a plane from three points
  71329. * @param point1 point used to create the plane
  71330. * @param point2 point used to create the plane
  71331. * @param point3 point used to create the plane
  71332. * @returns a new Plane defined by the three given points.
  71333. */
  71334. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71335. /**
  71336. * Creates a plane from an origin point and a normal
  71337. * @param origin origin of the plane to be constructed
  71338. * @param normal normal of the plane to be constructed
  71339. * @returns a new Plane the normal vector to this plane at the given origin point.
  71340. * Note : the vector "normal" is updated because normalized.
  71341. */
  71342. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71343. /**
  71344. * Calculates the distance from a plane and a point
  71345. * @param origin origin of the plane to be constructed
  71346. * @param normal normal of the plane to be constructed
  71347. * @param point point to calculate distance to
  71348. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71349. */
  71350. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71351. }
  71352. }
  71353. declare module BABYLON {
  71354. /**
  71355. * Class used to store bounding sphere information
  71356. */
  71357. export class BoundingSphere {
  71358. /**
  71359. * Gets the center of the bounding sphere in local space
  71360. */
  71361. readonly center: Vector3;
  71362. /**
  71363. * Radius of the bounding sphere in local space
  71364. */
  71365. radius: number;
  71366. /**
  71367. * Gets the center of the bounding sphere in world space
  71368. */
  71369. readonly centerWorld: Vector3;
  71370. /**
  71371. * Radius of the bounding sphere in world space
  71372. */
  71373. radiusWorld: number;
  71374. /**
  71375. * Gets the minimum vector in local space
  71376. */
  71377. readonly minimum: Vector3;
  71378. /**
  71379. * Gets the maximum vector in local space
  71380. */
  71381. readonly maximum: Vector3;
  71382. private _worldMatrix;
  71383. private static readonly TmpVector3;
  71384. /**
  71385. * Creates a new bounding sphere
  71386. * @param min defines the minimum vector (in local space)
  71387. * @param max defines the maximum vector (in local space)
  71388. * @param worldMatrix defines the new world matrix
  71389. */
  71390. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71391. /**
  71392. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71393. * @param min defines the new minimum vector (in local space)
  71394. * @param max defines the new maximum vector (in local space)
  71395. * @param worldMatrix defines the new world matrix
  71396. */
  71397. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71398. /**
  71399. * Scale the current bounding sphere by applying a scale factor
  71400. * @param factor defines the scale factor to apply
  71401. * @returns the current bounding box
  71402. */
  71403. scale(factor: number): BoundingSphere;
  71404. /**
  71405. * Gets the world matrix of the bounding box
  71406. * @returns a matrix
  71407. */
  71408. getWorldMatrix(): DeepImmutable<Matrix>;
  71409. /** @hidden */
  71410. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71411. /**
  71412. * Tests if the bounding sphere is intersecting the frustum planes
  71413. * @param frustumPlanes defines the frustum planes to test
  71414. * @returns true if there is an intersection
  71415. */
  71416. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71417. /**
  71418. * Tests if the bounding sphere center is in between the frustum planes.
  71419. * Used for optimistic fast inclusion.
  71420. * @param frustumPlanes defines the frustum planes to test
  71421. * @returns true if the sphere center is in between the frustum planes
  71422. */
  71423. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71424. /**
  71425. * Tests if a point is inside the bounding sphere
  71426. * @param point defines the point to test
  71427. * @returns true if the point is inside the bounding sphere
  71428. */
  71429. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71430. /**
  71431. * Checks if two sphere intersct
  71432. * @param sphere0 sphere 0
  71433. * @param sphere1 sphere 1
  71434. * @returns true if the speres intersect
  71435. */
  71436. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71437. }
  71438. }
  71439. declare module BABYLON {
  71440. /**
  71441. * Class used to store bounding box information
  71442. */
  71443. export class BoundingBox implements ICullable {
  71444. /**
  71445. * Gets the 8 vectors representing the bounding box in local space
  71446. */
  71447. readonly vectors: Vector3[];
  71448. /**
  71449. * Gets the center of the bounding box in local space
  71450. */
  71451. readonly center: Vector3;
  71452. /**
  71453. * Gets the center of the bounding box in world space
  71454. */
  71455. readonly centerWorld: Vector3;
  71456. /**
  71457. * Gets the extend size in local space
  71458. */
  71459. readonly extendSize: Vector3;
  71460. /**
  71461. * Gets the extend size in world space
  71462. */
  71463. readonly extendSizeWorld: Vector3;
  71464. /**
  71465. * Gets the OBB (object bounding box) directions
  71466. */
  71467. readonly directions: Vector3[];
  71468. /**
  71469. * Gets the 8 vectors representing the bounding box in world space
  71470. */
  71471. readonly vectorsWorld: Vector3[];
  71472. /**
  71473. * Gets the minimum vector in world space
  71474. */
  71475. readonly minimumWorld: Vector3;
  71476. /**
  71477. * Gets the maximum vector in world space
  71478. */
  71479. readonly maximumWorld: Vector3;
  71480. /**
  71481. * Gets the minimum vector in local space
  71482. */
  71483. readonly minimum: Vector3;
  71484. /**
  71485. * Gets the maximum vector in local space
  71486. */
  71487. readonly maximum: Vector3;
  71488. private _worldMatrix;
  71489. private static readonly TmpVector3;
  71490. /**
  71491. * @hidden
  71492. */
  71493. _tag: number;
  71494. /**
  71495. * Creates a new bounding box
  71496. * @param min defines the minimum vector (in local space)
  71497. * @param max defines the maximum vector (in local space)
  71498. * @param worldMatrix defines the new world matrix
  71499. */
  71500. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71501. /**
  71502. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71503. * @param min defines the new minimum vector (in local space)
  71504. * @param max defines the new maximum vector (in local space)
  71505. * @param worldMatrix defines the new world matrix
  71506. */
  71507. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71508. /**
  71509. * Scale the current bounding box by applying a scale factor
  71510. * @param factor defines the scale factor to apply
  71511. * @returns the current bounding box
  71512. */
  71513. scale(factor: number): BoundingBox;
  71514. /**
  71515. * Gets the world matrix of the bounding box
  71516. * @returns a matrix
  71517. */
  71518. getWorldMatrix(): DeepImmutable<Matrix>;
  71519. /** @hidden */
  71520. _update(world: DeepImmutable<Matrix>): void;
  71521. /**
  71522. * Tests if the bounding box is intersecting the frustum planes
  71523. * @param frustumPlanes defines the frustum planes to test
  71524. * @returns true if there is an intersection
  71525. */
  71526. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71527. /**
  71528. * Tests if the bounding box is entirely inside the frustum planes
  71529. * @param frustumPlanes defines the frustum planes to test
  71530. * @returns true if there is an inclusion
  71531. */
  71532. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71533. /**
  71534. * Tests if a point is inside the bounding box
  71535. * @param point defines the point to test
  71536. * @returns true if the point is inside the bounding box
  71537. */
  71538. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71539. /**
  71540. * Tests if the bounding box intersects with a bounding sphere
  71541. * @param sphere defines the sphere to test
  71542. * @returns true if there is an intersection
  71543. */
  71544. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71545. /**
  71546. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71547. * @param min defines the min vector to use
  71548. * @param max defines the max vector to use
  71549. * @returns true if there is an intersection
  71550. */
  71551. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71552. /**
  71553. * Tests if two bounding boxes are intersections
  71554. * @param box0 defines the first box to test
  71555. * @param box1 defines the second box to test
  71556. * @returns true if there is an intersection
  71557. */
  71558. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71559. /**
  71560. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71561. * @param minPoint defines the minimum vector of the bounding box
  71562. * @param maxPoint defines the maximum vector of the bounding box
  71563. * @param sphereCenter defines the sphere center
  71564. * @param sphereRadius defines the sphere radius
  71565. * @returns true if there is an intersection
  71566. */
  71567. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71568. /**
  71569. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71570. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71571. * @param frustumPlanes defines the frustum planes to test
  71572. * @return true if there is an inclusion
  71573. */
  71574. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71575. /**
  71576. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71577. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71578. * @param frustumPlanes defines the frustum planes to test
  71579. * @return true if there is an intersection
  71580. */
  71581. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71582. }
  71583. }
  71584. declare module BABYLON {
  71585. /** @hidden */
  71586. export class Collider {
  71587. /** Define if a collision was found */
  71588. collisionFound: boolean;
  71589. /**
  71590. * Define last intersection point in local space
  71591. */
  71592. intersectionPoint: Vector3;
  71593. /**
  71594. * Define last collided mesh
  71595. */
  71596. collidedMesh: Nullable<AbstractMesh>;
  71597. private _collisionPoint;
  71598. private _planeIntersectionPoint;
  71599. private _tempVector;
  71600. private _tempVector2;
  71601. private _tempVector3;
  71602. private _tempVector4;
  71603. private _edge;
  71604. private _baseToVertex;
  71605. private _destinationPoint;
  71606. private _slidePlaneNormal;
  71607. private _displacementVector;
  71608. /** @hidden */
  71609. _radius: Vector3;
  71610. /** @hidden */
  71611. _retry: number;
  71612. private _velocity;
  71613. private _basePoint;
  71614. private _epsilon;
  71615. /** @hidden */
  71616. _velocityWorldLength: number;
  71617. /** @hidden */
  71618. _basePointWorld: Vector3;
  71619. private _velocityWorld;
  71620. private _normalizedVelocity;
  71621. /** @hidden */
  71622. _initialVelocity: Vector3;
  71623. /** @hidden */
  71624. _initialPosition: Vector3;
  71625. private _nearestDistance;
  71626. private _collisionMask;
  71627. collisionMask: number;
  71628. /**
  71629. * Gets the plane normal used to compute the sliding response (in local space)
  71630. */
  71631. readonly slidePlaneNormal: Vector3;
  71632. /** @hidden */
  71633. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71634. /** @hidden */
  71635. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71636. /** @hidden */
  71637. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71638. /** @hidden */
  71639. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71640. /** @hidden */
  71641. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71642. /** @hidden */
  71643. _getResponse(pos: Vector3, vel: Vector3): void;
  71644. }
  71645. }
  71646. declare module BABYLON {
  71647. /**
  71648. * Interface for cullable objects
  71649. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71650. */
  71651. export interface ICullable {
  71652. /**
  71653. * Checks if the object or part of the object is in the frustum
  71654. * @param frustumPlanes Camera near/planes
  71655. * @returns true if the object is in frustum otherwise false
  71656. */
  71657. isInFrustum(frustumPlanes: Plane[]): boolean;
  71658. /**
  71659. * Checks if a cullable object (mesh...) is in the camera frustum
  71660. * Unlike isInFrustum this cheks the full bounding box
  71661. * @param frustumPlanes Camera near/planes
  71662. * @returns true if the object is in frustum otherwise false
  71663. */
  71664. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71665. }
  71666. /**
  71667. * Info for a bounding data of a mesh
  71668. */
  71669. export class BoundingInfo implements ICullable {
  71670. /**
  71671. * Bounding box for the mesh
  71672. */
  71673. readonly boundingBox: BoundingBox;
  71674. /**
  71675. * Bounding sphere for the mesh
  71676. */
  71677. readonly boundingSphere: BoundingSphere;
  71678. private _isLocked;
  71679. private static readonly TmpVector3;
  71680. /**
  71681. * Constructs bounding info
  71682. * @param minimum min vector of the bounding box/sphere
  71683. * @param maximum max vector of the bounding box/sphere
  71684. * @param worldMatrix defines the new world matrix
  71685. */
  71686. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71687. /**
  71688. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71689. * @param min defines the new minimum vector (in local space)
  71690. * @param max defines the new maximum vector (in local space)
  71691. * @param worldMatrix defines the new world matrix
  71692. */
  71693. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71694. /**
  71695. * min vector of the bounding box/sphere
  71696. */
  71697. readonly minimum: Vector3;
  71698. /**
  71699. * max vector of the bounding box/sphere
  71700. */
  71701. readonly maximum: Vector3;
  71702. /**
  71703. * If the info is locked and won't be updated to avoid perf overhead
  71704. */
  71705. isLocked: boolean;
  71706. /**
  71707. * Updates the bounding sphere and box
  71708. * @param world world matrix to be used to update
  71709. */
  71710. update(world: DeepImmutable<Matrix>): void;
  71711. /**
  71712. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71713. * @param center New center of the bounding info
  71714. * @param extend New extend of the bounding info
  71715. * @returns the current bounding info
  71716. */
  71717. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71718. /**
  71719. * Scale the current bounding info by applying a scale factor
  71720. * @param factor defines the scale factor to apply
  71721. * @returns the current bounding info
  71722. */
  71723. scale(factor: number): BoundingInfo;
  71724. /**
  71725. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71726. * @param frustumPlanes defines the frustum to test
  71727. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71728. * @returns true if the bounding info is in the frustum planes
  71729. */
  71730. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71731. /**
  71732. * Gets the world distance between the min and max points of the bounding box
  71733. */
  71734. readonly diagonalLength: number;
  71735. /**
  71736. * Checks if a cullable object (mesh...) is in the camera frustum
  71737. * Unlike isInFrustum this cheks the full bounding box
  71738. * @param frustumPlanes Camera near/planes
  71739. * @returns true if the object is in frustum otherwise false
  71740. */
  71741. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71742. /** @hidden */
  71743. _checkCollision(collider: Collider): boolean;
  71744. /**
  71745. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71746. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71747. * @param point the point to check intersection with
  71748. * @returns if the point intersects
  71749. */
  71750. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71751. /**
  71752. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71753. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71754. * @param boundingInfo the bounding info to check intersection with
  71755. * @param precise if the intersection should be done using OBB
  71756. * @returns if the bounding info intersects
  71757. */
  71758. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /**
  71763. * Extracts minimum and maximum values from a list of indexed positions
  71764. * @param positions defines the positions to use
  71765. * @param indices defines the indices to the positions
  71766. * @param indexStart defines the start index
  71767. * @param indexCount defines the end index
  71768. * @param bias defines bias value to add to the result
  71769. * @return minimum and maximum values
  71770. */
  71771. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71772. minimum: Vector3;
  71773. maximum: Vector3;
  71774. };
  71775. /**
  71776. * Extracts minimum and maximum values from a list of positions
  71777. * @param positions defines the positions to use
  71778. * @param start defines the start index in the positions array
  71779. * @param count defines the number of positions to handle
  71780. * @param bias defines bias value to add to the result
  71781. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71782. * @return minimum and maximum values
  71783. */
  71784. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71785. minimum: Vector3;
  71786. maximum: Vector3;
  71787. };
  71788. }
  71789. declare module BABYLON {
  71790. /**
  71791. * Enum that determines the text-wrapping mode to use.
  71792. */
  71793. export enum InspectableType {
  71794. /**
  71795. * Checkbox for booleans
  71796. */
  71797. Checkbox = 0,
  71798. /**
  71799. * Sliders for numbers
  71800. */
  71801. Slider = 1,
  71802. /**
  71803. * Vector3
  71804. */
  71805. Vector3 = 2,
  71806. /**
  71807. * Quaternions
  71808. */
  71809. Quaternion = 3,
  71810. /**
  71811. * Color3
  71812. */
  71813. Color3 = 4,
  71814. /**
  71815. * String
  71816. */
  71817. String = 5
  71818. }
  71819. /**
  71820. * Interface used to define custom inspectable properties.
  71821. * This interface is used by the inspector to display custom property grids
  71822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71823. */
  71824. export interface IInspectable {
  71825. /**
  71826. * Gets the label to display
  71827. */
  71828. label: string;
  71829. /**
  71830. * Gets the name of the property to edit
  71831. */
  71832. propertyName: string;
  71833. /**
  71834. * Gets the type of the editor to use
  71835. */
  71836. type: InspectableType;
  71837. /**
  71838. * Gets the minimum value of the property when using in "slider" mode
  71839. */
  71840. min?: number;
  71841. /**
  71842. * Gets the maximum value of the property when using in "slider" mode
  71843. */
  71844. max?: number;
  71845. /**
  71846. * Gets the setp to use when using in "slider" mode
  71847. */
  71848. step?: number;
  71849. }
  71850. }
  71851. declare module BABYLON {
  71852. /**
  71853. * Class used to provide helper for timing
  71854. */
  71855. export class TimingTools {
  71856. /**
  71857. * Polyfill for setImmediate
  71858. * @param action defines the action to execute after the current execution block
  71859. */
  71860. static SetImmediate(action: () => void): void;
  71861. }
  71862. }
  71863. declare module BABYLON {
  71864. /**
  71865. * Class used to enable instatition of objects by class name
  71866. */
  71867. export class InstantiationTools {
  71868. /**
  71869. * Use this object to register external classes like custom textures or material
  71870. * to allow the laoders to instantiate them
  71871. */
  71872. static RegisteredExternalClasses: {
  71873. [key: string]: Object;
  71874. };
  71875. /**
  71876. * Tries to instantiate a new object from a given class name
  71877. * @param className defines the class name to instantiate
  71878. * @returns the new object or null if the system was not able to do the instantiation
  71879. */
  71880. static Instantiate(className: string): any;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. /**
  71885. * This represents the required contract to create a new type of texture loader.
  71886. */
  71887. export interface IInternalTextureLoader {
  71888. /**
  71889. * Defines wether the loader supports cascade loading the different faces.
  71890. */
  71891. supportCascades: boolean;
  71892. /**
  71893. * This returns if the loader support the current file information.
  71894. * @param extension defines the file extension of the file being loaded
  71895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71896. * @param fallback defines the fallback internal texture if any
  71897. * @param isBase64 defines whether the texture is encoded as a base64
  71898. * @param isBuffer defines whether the texture data are stored as a buffer
  71899. * @returns true if the loader can load the specified file
  71900. */
  71901. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71902. /**
  71903. * Transform the url before loading if required.
  71904. * @param rootUrl the url of the texture
  71905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71906. * @returns the transformed texture
  71907. */
  71908. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71909. /**
  71910. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71911. * @param rootUrl the url of the texture
  71912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71913. * @returns the fallback texture
  71914. */
  71915. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71916. /**
  71917. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71918. * @param data contains the texture data
  71919. * @param texture defines the BabylonJS internal texture
  71920. * @param createPolynomials will be true if polynomials have been requested
  71921. * @param onLoad defines the callback to trigger once the texture is ready
  71922. * @param onError defines the callback to trigger in case of error
  71923. */
  71924. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71925. /**
  71926. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71927. * @param data contains the texture data
  71928. * @param texture defines the BabylonJS internal texture
  71929. * @param callback defines the method to call once ready to upload
  71930. */
  71931. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71932. }
  71933. }
  71934. declare module BABYLON {
  71935. interface Engine {
  71936. /**
  71937. * Creates a depth stencil cube texture.
  71938. * This is only available in WebGL 2.
  71939. * @param size The size of face edge in the cube texture.
  71940. * @param options The options defining the cube texture.
  71941. * @returns The cube texture
  71942. */
  71943. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71944. /**
  71945. * Creates a cube texture
  71946. * @param rootUrl defines the url where the files to load is located
  71947. * @param scene defines the current scene
  71948. * @param files defines the list of files to load (1 per face)
  71949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71950. * @param onLoad defines an optional callback raised when the texture is loaded
  71951. * @param onError defines an optional callback raised if there is an issue to load the texture
  71952. * @param format defines the format of the data
  71953. * @param forcedExtension defines the extension to use to pick the right loader
  71954. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71957. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71958. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71959. * @returns the cube texture as an InternalTexture
  71960. */
  71961. 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;
  71962. /**
  71963. * Creates a cube texture
  71964. * @param rootUrl defines the url where the files to load is located
  71965. * @param scene defines the current scene
  71966. * @param files defines the list of files to load (1 per face)
  71967. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71968. * @param onLoad defines an optional callback raised when the texture is loaded
  71969. * @param onError defines an optional callback raised if there is an issue to load the texture
  71970. * @param format defines the format of the data
  71971. * @param forcedExtension defines the extension to use to pick the right loader
  71972. * @returns the cube texture as an InternalTexture
  71973. */
  71974. 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;
  71975. /**
  71976. * Creates a cube texture
  71977. * @param rootUrl defines the url where the files to load is located
  71978. * @param scene defines the current scene
  71979. * @param files defines the list of files to load (1 per face)
  71980. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71981. * @param onLoad defines an optional callback raised when the texture is loaded
  71982. * @param onError defines an optional callback raised if there is an issue to load the texture
  71983. * @param format defines the format of the data
  71984. * @param forcedExtension defines the extension to use to pick the right loader
  71985. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71986. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71987. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71988. * @returns the cube texture as an InternalTexture
  71989. */
  71990. 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;
  71991. /** @hidden */
  71992. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71993. /** @hidden */
  71994. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71995. /** @hidden */
  71996. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71997. /** @hidden */
  71998. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71999. }
  72000. }
  72001. declare module BABYLON {
  72002. /**
  72003. * Class for creating a cube texture
  72004. */
  72005. export class CubeTexture extends BaseTexture {
  72006. private _delayedOnLoad;
  72007. /**
  72008. * The url of the texture
  72009. */
  72010. url: string;
  72011. /**
  72012. * Gets or sets the center of the bounding box associated with the cube texture.
  72013. * It must define where the camera used to render the texture was set
  72014. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72015. */
  72016. boundingBoxPosition: Vector3;
  72017. private _boundingBoxSize;
  72018. /**
  72019. * Gets or sets the size of the bounding box associated with the cube texture
  72020. * When defined, the cubemap will switch to local mode
  72021. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72022. * @example https://www.babylonjs-playground.com/#RNASML
  72023. */
  72024. /**
  72025. * Returns the bounding box size
  72026. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72027. */
  72028. boundingBoxSize: Vector3;
  72029. protected _rotationY: number;
  72030. /**
  72031. * Sets texture matrix rotation angle around Y axis in radians.
  72032. */
  72033. /**
  72034. * Gets texture matrix rotation angle around Y axis radians.
  72035. */
  72036. rotationY: number;
  72037. /**
  72038. * Are mip maps generated for this texture or not.
  72039. */
  72040. readonly noMipmap: boolean;
  72041. private _noMipmap;
  72042. private _files;
  72043. private _extensions;
  72044. private _textureMatrix;
  72045. private _format;
  72046. private _createPolynomials;
  72047. /** @hidden */
  72048. _prefiltered: boolean;
  72049. /**
  72050. * Creates a cube texture from an array of image urls
  72051. * @param files defines an array of image urls
  72052. * @param scene defines the hosting scene
  72053. * @param noMipmap specifies if mip maps are not used
  72054. * @returns a cube texture
  72055. */
  72056. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72057. /**
  72058. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72059. * @param url defines the url of the prefiltered texture
  72060. * @param scene defines the scene the texture is attached to
  72061. * @param forcedExtension defines the extension of the file if different from the url
  72062. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72063. * @return the prefiltered texture
  72064. */
  72065. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72066. /**
  72067. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72068. * as prefiltered data.
  72069. * @param rootUrl defines the url of the texture or the root name of the six images
  72070. * @param scene defines the scene the texture is attached to
  72071. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72072. * @param noMipmap defines if mipmaps should be created or not
  72073. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72074. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72075. * @param onError defines a callback triggered in case of error during load
  72076. * @param format defines the internal format to use for the texture once loaded
  72077. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72078. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72079. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72080. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72081. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72082. * @return the cube texture
  72083. */
  72084. 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);
  72085. /**
  72086. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72087. */
  72088. readonly isPrefiltered: boolean;
  72089. /**
  72090. * Get the current class name of the texture useful for serialization or dynamic coding.
  72091. * @returns "CubeTexture"
  72092. */
  72093. getClassName(): string;
  72094. /**
  72095. * Update the url (and optional buffer) of this texture if url was null during construction.
  72096. * @param url the url of the texture
  72097. * @param forcedExtension defines the extension to use
  72098. * @param onLoad callback called when the texture is loaded (defaults to null)
  72099. */
  72100. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72101. /**
  72102. * Delays loading of the cube texture
  72103. * @param forcedExtension defines the extension to use
  72104. */
  72105. delayLoad(forcedExtension?: string): void;
  72106. /**
  72107. * Returns the reflection texture matrix
  72108. * @returns the reflection texture matrix
  72109. */
  72110. getReflectionTextureMatrix(): Matrix;
  72111. /**
  72112. * Sets the reflection texture matrix
  72113. * @param value Reflection texture matrix
  72114. */
  72115. setReflectionTextureMatrix(value: Matrix): void;
  72116. /**
  72117. * Parses text to create a cube texture
  72118. * @param parsedTexture define the serialized text to read from
  72119. * @param scene defines the hosting scene
  72120. * @param rootUrl defines the root url of the cube texture
  72121. * @returns a cube texture
  72122. */
  72123. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72124. /**
  72125. * Makes a clone, or deep copy, of the cube texture
  72126. * @returns a new cube texture
  72127. */
  72128. clone(): CubeTexture;
  72129. }
  72130. }
  72131. declare module BABYLON {
  72132. /**
  72133. * Manages the defines for the Material
  72134. */
  72135. export class MaterialDefines {
  72136. /** @hidden */
  72137. protected _keys: string[];
  72138. private _isDirty;
  72139. /** @hidden */
  72140. _renderId: number;
  72141. /** @hidden */
  72142. _areLightsDirty: boolean;
  72143. /** @hidden */
  72144. _areAttributesDirty: boolean;
  72145. /** @hidden */
  72146. _areTexturesDirty: boolean;
  72147. /** @hidden */
  72148. _areFresnelDirty: boolean;
  72149. /** @hidden */
  72150. _areMiscDirty: boolean;
  72151. /** @hidden */
  72152. _areImageProcessingDirty: boolean;
  72153. /** @hidden */
  72154. _normals: boolean;
  72155. /** @hidden */
  72156. _uvs: boolean;
  72157. /** @hidden */
  72158. _needNormals: boolean;
  72159. /** @hidden */
  72160. _needUVs: boolean;
  72161. [id: string]: any;
  72162. /**
  72163. * Specifies if the material needs to be re-calculated
  72164. */
  72165. readonly isDirty: boolean;
  72166. /**
  72167. * Marks the material to indicate that it has been re-calculated
  72168. */
  72169. markAsProcessed(): void;
  72170. /**
  72171. * Marks the material to indicate that it needs to be re-calculated
  72172. */
  72173. markAsUnprocessed(): void;
  72174. /**
  72175. * Marks the material to indicate all of its defines need to be re-calculated
  72176. */
  72177. markAllAsDirty(): void;
  72178. /**
  72179. * Marks the material to indicate that image processing needs to be re-calculated
  72180. */
  72181. markAsImageProcessingDirty(): void;
  72182. /**
  72183. * Marks the material to indicate the lights need to be re-calculated
  72184. */
  72185. markAsLightDirty(): void;
  72186. /**
  72187. * Marks the attribute state as changed
  72188. */
  72189. markAsAttributesDirty(): void;
  72190. /**
  72191. * Marks the texture state as changed
  72192. */
  72193. markAsTexturesDirty(): void;
  72194. /**
  72195. * Marks the fresnel state as changed
  72196. */
  72197. markAsFresnelDirty(): void;
  72198. /**
  72199. * Marks the misc state as changed
  72200. */
  72201. markAsMiscDirty(): void;
  72202. /**
  72203. * Rebuilds the material defines
  72204. */
  72205. rebuild(): void;
  72206. /**
  72207. * Specifies if two material defines are equal
  72208. * @param other - A material define instance to compare to
  72209. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72210. */
  72211. isEqual(other: MaterialDefines): boolean;
  72212. /**
  72213. * Clones this instance's defines to another instance
  72214. * @param other - material defines to clone values to
  72215. */
  72216. cloneTo(other: MaterialDefines): void;
  72217. /**
  72218. * Resets the material define values
  72219. */
  72220. reset(): void;
  72221. /**
  72222. * Converts the material define values to a string
  72223. * @returns - String of material define information
  72224. */
  72225. toString(): string;
  72226. }
  72227. }
  72228. declare module BABYLON {
  72229. /**
  72230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72232. * 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;
  72233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72234. */
  72235. export class ColorCurves {
  72236. private _dirty;
  72237. private _tempColor;
  72238. private _globalCurve;
  72239. private _highlightsCurve;
  72240. private _midtonesCurve;
  72241. private _shadowsCurve;
  72242. private _positiveCurve;
  72243. private _negativeCurve;
  72244. private _globalHue;
  72245. private _globalDensity;
  72246. private _globalSaturation;
  72247. private _globalExposure;
  72248. /**
  72249. * Gets the global Hue value.
  72250. * 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).
  72251. */
  72252. /**
  72253. * Sets the global Hue value.
  72254. * 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).
  72255. */
  72256. globalHue: number;
  72257. /**
  72258. * Gets the global Density value.
  72259. * 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.
  72260. * Values less than zero provide a filter of opposite hue.
  72261. */
  72262. /**
  72263. * Sets the global Density value.
  72264. * 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.
  72265. * Values less than zero provide a filter of opposite hue.
  72266. */
  72267. globalDensity: number;
  72268. /**
  72269. * Gets the global Saturation value.
  72270. * 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.
  72271. */
  72272. /**
  72273. * Sets the global Saturation value.
  72274. * 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.
  72275. */
  72276. globalSaturation: number;
  72277. /**
  72278. * Gets the global Exposure value.
  72279. * 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.
  72280. */
  72281. /**
  72282. * Sets the global Exposure value.
  72283. * 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.
  72284. */
  72285. globalExposure: number;
  72286. private _highlightsHue;
  72287. private _highlightsDensity;
  72288. private _highlightsSaturation;
  72289. private _highlightsExposure;
  72290. /**
  72291. * Gets the highlights Hue value.
  72292. * 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).
  72293. */
  72294. /**
  72295. * Sets the highlights Hue value.
  72296. * 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).
  72297. */
  72298. highlightsHue: number;
  72299. /**
  72300. * Gets the highlights Density value.
  72301. * 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.
  72302. * Values less than zero provide a filter of opposite hue.
  72303. */
  72304. /**
  72305. * Sets the highlights Density value.
  72306. * 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.
  72307. * Values less than zero provide a filter of opposite hue.
  72308. */
  72309. highlightsDensity: number;
  72310. /**
  72311. * Gets the highlights Saturation value.
  72312. * 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.
  72313. */
  72314. /**
  72315. * Sets the highlights Saturation value.
  72316. * 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.
  72317. */
  72318. highlightsSaturation: number;
  72319. /**
  72320. * Gets the highlights Exposure value.
  72321. * 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.
  72322. */
  72323. /**
  72324. * Sets the highlights Exposure value.
  72325. * 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.
  72326. */
  72327. highlightsExposure: number;
  72328. private _midtonesHue;
  72329. private _midtonesDensity;
  72330. private _midtonesSaturation;
  72331. private _midtonesExposure;
  72332. /**
  72333. * Gets the midtones Hue value.
  72334. * 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).
  72335. */
  72336. /**
  72337. * Sets the midtones Hue value.
  72338. * 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).
  72339. */
  72340. midtonesHue: number;
  72341. /**
  72342. * Gets the midtones Density value.
  72343. * 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.
  72344. * Values less than zero provide a filter of opposite hue.
  72345. */
  72346. /**
  72347. * Sets the midtones Density value.
  72348. * 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.
  72349. * Values less than zero provide a filter of opposite hue.
  72350. */
  72351. midtonesDensity: number;
  72352. /**
  72353. * Gets the midtones Saturation value.
  72354. * 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.
  72355. */
  72356. /**
  72357. * Sets the midtones Saturation value.
  72358. * 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.
  72359. */
  72360. midtonesSaturation: number;
  72361. /**
  72362. * Gets the midtones Exposure value.
  72363. * 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.
  72364. */
  72365. /**
  72366. * Sets the midtones Exposure value.
  72367. * 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.
  72368. */
  72369. midtonesExposure: number;
  72370. private _shadowsHue;
  72371. private _shadowsDensity;
  72372. private _shadowsSaturation;
  72373. private _shadowsExposure;
  72374. /**
  72375. * Gets the shadows Hue value.
  72376. * 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).
  72377. */
  72378. /**
  72379. * Sets the shadows Hue value.
  72380. * 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).
  72381. */
  72382. shadowsHue: number;
  72383. /**
  72384. * Gets the shadows Density value.
  72385. * 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.
  72386. * Values less than zero provide a filter of opposite hue.
  72387. */
  72388. /**
  72389. * Sets the shadows Density value.
  72390. * 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.
  72391. * Values less than zero provide a filter of opposite hue.
  72392. */
  72393. shadowsDensity: number;
  72394. /**
  72395. * Gets the shadows Saturation value.
  72396. * 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.
  72397. */
  72398. /**
  72399. * Sets the shadows Saturation value.
  72400. * 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.
  72401. */
  72402. shadowsSaturation: number;
  72403. /**
  72404. * Gets the shadows Exposure value.
  72405. * 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.
  72406. */
  72407. /**
  72408. * Sets the shadows Exposure value.
  72409. * 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.
  72410. */
  72411. shadowsExposure: number;
  72412. /**
  72413. * Returns the class name
  72414. * @returns The class name
  72415. */
  72416. getClassName(): string;
  72417. /**
  72418. * Binds the color curves to the shader.
  72419. * @param colorCurves The color curve to bind
  72420. * @param effect The effect to bind to
  72421. * @param positiveUniform The positive uniform shader parameter
  72422. * @param neutralUniform The neutral uniform shader parameter
  72423. * @param negativeUniform The negative uniform shader parameter
  72424. */
  72425. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72426. /**
  72427. * Prepare the list of uniforms associated with the ColorCurves effects.
  72428. * @param uniformsList The list of uniforms used in the effect
  72429. */
  72430. static PrepareUniforms(uniformsList: string[]): void;
  72431. /**
  72432. * Returns color grading data based on a hue, density, saturation and exposure value.
  72433. * @param filterHue The hue of the color filter.
  72434. * @param filterDensity The density of the color filter.
  72435. * @param saturation The saturation.
  72436. * @param exposure The exposure.
  72437. * @param result The result data container.
  72438. */
  72439. private getColorGradingDataToRef;
  72440. /**
  72441. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72442. * @param value The input slider value in range [-100,100].
  72443. * @returns Adjusted value.
  72444. */
  72445. private static applyColorGradingSliderNonlinear;
  72446. /**
  72447. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72448. * @param hue The hue (H) input.
  72449. * @param saturation The saturation (S) input.
  72450. * @param brightness The brightness (B) input.
  72451. * @result An RGBA color represented as Vector4.
  72452. */
  72453. private static fromHSBToRef;
  72454. /**
  72455. * Returns a value clamped between min and max
  72456. * @param value The value to clamp
  72457. * @param min The minimum of value
  72458. * @param max The maximum of value
  72459. * @returns The clamped value.
  72460. */
  72461. private static clamp;
  72462. /**
  72463. * Clones the current color curve instance.
  72464. * @return The cloned curves
  72465. */
  72466. clone(): ColorCurves;
  72467. /**
  72468. * Serializes the current color curve instance to a json representation.
  72469. * @return a JSON representation
  72470. */
  72471. serialize(): any;
  72472. /**
  72473. * Parses the color curve from a json representation.
  72474. * @param source the JSON source to parse
  72475. * @return The parsed curves
  72476. */
  72477. static Parse(source: any): ColorCurves;
  72478. }
  72479. }
  72480. declare module BABYLON {
  72481. /**
  72482. * Interface to follow in your material defines to integrate easily the
  72483. * Image proccessing functions.
  72484. * @hidden
  72485. */
  72486. export interface IImageProcessingConfigurationDefines {
  72487. IMAGEPROCESSING: boolean;
  72488. VIGNETTE: boolean;
  72489. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72490. VIGNETTEBLENDMODEOPAQUE: boolean;
  72491. TONEMAPPING: boolean;
  72492. TONEMAPPING_ACES: boolean;
  72493. CONTRAST: boolean;
  72494. EXPOSURE: boolean;
  72495. COLORCURVES: boolean;
  72496. COLORGRADING: boolean;
  72497. COLORGRADING3D: boolean;
  72498. SAMPLER3DGREENDEPTH: boolean;
  72499. SAMPLER3DBGRMAP: boolean;
  72500. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72501. }
  72502. /**
  72503. * @hidden
  72504. */
  72505. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72506. IMAGEPROCESSING: boolean;
  72507. VIGNETTE: boolean;
  72508. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72509. VIGNETTEBLENDMODEOPAQUE: boolean;
  72510. TONEMAPPING: boolean;
  72511. TONEMAPPING_ACES: boolean;
  72512. CONTRAST: boolean;
  72513. COLORCURVES: boolean;
  72514. COLORGRADING: boolean;
  72515. COLORGRADING3D: boolean;
  72516. SAMPLER3DGREENDEPTH: boolean;
  72517. SAMPLER3DBGRMAP: boolean;
  72518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72519. EXPOSURE: boolean;
  72520. constructor();
  72521. }
  72522. /**
  72523. * This groups together the common properties used for image processing either in direct forward pass
  72524. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72525. * or not.
  72526. */
  72527. export class ImageProcessingConfiguration {
  72528. /**
  72529. * Default tone mapping applied in BabylonJS.
  72530. */
  72531. static readonly TONEMAPPING_STANDARD: number;
  72532. /**
  72533. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72534. * to other engines rendering to increase portability.
  72535. */
  72536. static readonly TONEMAPPING_ACES: number;
  72537. /**
  72538. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72539. */
  72540. colorCurves: Nullable<ColorCurves>;
  72541. private _colorCurvesEnabled;
  72542. /**
  72543. * Gets wether the color curves effect is enabled.
  72544. */
  72545. /**
  72546. * Sets wether the color curves effect is enabled.
  72547. */
  72548. colorCurvesEnabled: boolean;
  72549. private _colorGradingTexture;
  72550. /**
  72551. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72552. */
  72553. /**
  72554. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72555. */
  72556. colorGradingTexture: Nullable<BaseTexture>;
  72557. private _colorGradingEnabled;
  72558. /**
  72559. * Gets wether the color grading effect is enabled.
  72560. */
  72561. /**
  72562. * Sets wether the color grading effect is enabled.
  72563. */
  72564. colorGradingEnabled: boolean;
  72565. private _colorGradingWithGreenDepth;
  72566. /**
  72567. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72568. */
  72569. /**
  72570. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72571. */
  72572. colorGradingWithGreenDepth: boolean;
  72573. private _colorGradingBGR;
  72574. /**
  72575. * Gets wether the color grading texture contains BGR values.
  72576. */
  72577. /**
  72578. * Sets wether the color grading texture contains BGR values.
  72579. */
  72580. colorGradingBGR: boolean;
  72581. /** @hidden */
  72582. _exposure: number;
  72583. /**
  72584. * Gets the Exposure used in the effect.
  72585. */
  72586. /**
  72587. * Sets the Exposure used in the effect.
  72588. */
  72589. exposure: number;
  72590. private _toneMappingEnabled;
  72591. /**
  72592. * Gets wether the tone mapping effect is enabled.
  72593. */
  72594. /**
  72595. * Sets wether the tone mapping effect is enabled.
  72596. */
  72597. toneMappingEnabled: boolean;
  72598. private _toneMappingType;
  72599. /**
  72600. * Gets the type of tone mapping effect.
  72601. */
  72602. /**
  72603. * Sets the type of tone mapping effect used in BabylonJS.
  72604. */
  72605. toneMappingType: number;
  72606. protected _contrast: number;
  72607. /**
  72608. * Gets the contrast used in the effect.
  72609. */
  72610. /**
  72611. * Sets the contrast used in the effect.
  72612. */
  72613. contrast: number;
  72614. /**
  72615. * Vignette stretch size.
  72616. */
  72617. vignetteStretch: number;
  72618. /**
  72619. * Vignette centre X Offset.
  72620. */
  72621. vignetteCentreX: number;
  72622. /**
  72623. * Vignette centre Y Offset.
  72624. */
  72625. vignetteCentreY: number;
  72626. /**
  72627. * Vignette weight or intensity of the vignette effect.
  72628. */
  72629. vignetteWeight: number;
  72630. /**
  72631. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72632. * if vignetteEnabled is set to true.
  72633. */
  72634. vignetteColor: Color4;
  72635. /**
  72636. * Camera field of view used by the Vignette effect.
  72637. */
  72638. vignetteCameraFov: number;
  72639. private _vignetteBlendMode;
  72640. /**
  72641. * Gets the vignette blend mode allowing different kind of effect.
  72642. */
  72643. /**
  72644. * Sets the vignette blend mode allowing different kind of effect.
  72645. */
  72646. vignetteBlendMode: number;
  72647. private _vignetteEnabled;
  72648. /**
  72649. * Gets wether the vignette effect is enabled.
  72650. */
  72651. /**
  72652. * Sets wether the vignette effect is enabled.
  72653. */
  72654. vignetteEnabled: boolean;
  72655. private _applyByPostProcess;
  72656. /**
  72657. * Gets wether the image processing is applied through a post process or not.
  72658. */
  72659. /**
  72660. * Sets wether the image processing is applied through a post process or not.
  72661. */
  72662. applyByPostProcess: boolean;
  72663. private _isEnabled;
  72664. /**
  72665. * Gets wether the image processing is enabled or not.
  72666. */
  72667. /**
  72668. * Sets wether the image processing is enabled or not.
  72669. */
  72670. isEnabled: boolean;
  72671. /**
  72672. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72673. */
  72674. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72675. /**
  72676. * Method called each time the image processing information changes requires to recompile the effect.
  72677. */
  72678. protected _updateParameters(): void;
  72679. /**
  72680. * Gets the current class name.
  72681. * @return "ImageProcessingConfiguration"
  72682. */
  72683. getClassName(): string;
  72684. /**
  72685. * Prepare the list of uniforms associated with the Image Processing effects.
  72686. * @param uniforms The list of uniforms used in the effect
  72687. * @param defines the list of defines currently in use
  72688. */
  72689. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72690. /**
  72691. * Prepare the list of samplers associated with the Image Processing effects.
  72692. * @param samplersList The list of uniforms used in the effect
  72693. * @param defines the list of defines currently in use
  72694. */
  72695. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72696. /**
  72697. * Prepare the list of defines associated to the shader.
  72698. * @param defines the list of defines to complete
  72699. * @param forPostProcess Define if we are currently in post process mode or not
  72700. */
  72701. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72702. /**
  72703. * Returns true if all the image processing information are ready.
  72704. * @returns True if ready, otherwise, false
  72705. */
  72706. isReady(): boolean;
  72707. /**
  72708. * Binds the image processing to the shader.
  72709. * @param effect The effect to bind to
  72710. * @param aspectRatio Define the current aspect ratio of the effect
  72711. */
  72712. bind(effect: Effect, aspectRatio?: number): void;
  72713. /**
  72714. * Clones the current image processing instance.
  72715. * @return The cloned image processing
  72716. */
  72717. clone(): ImageProcessingConfiguration;
  72718. /**
  72719. * Serializes the current image processing instance to a json representation.
  72720. * @return a JSON representation
  72721. */
  72722. serialize(): any;
  72723. /**
  72724. * Parses the image processing from a json representation.
  72725. * @param source the JSON source to parse
  72726. * @return The parsed image processing
  72727. */
  72728. static Parse(source: any): ImageProcessingConfiguration;
  72729. private static _VIGNETTEMODE_MULTIPLY;
  72730. private static _VIGNETTEMODE_OPAQUE;
  72731. /**
  72732. * Used to apply the vignette as a mix with the pixel color.
  72733. */
  72734. static readonly VIGNETTEMODE_MULTIPLY: number;
  72735. /**
  72736. * Used to apply the vignette as a replacement of the pixel color.
  72737. */
  72738. static readonly VIGNETTEMODE_OPAQUE: number;
  72739. }
  72740. }
  72741. declare module BABYLON {
  72742. /** @hidden */
  72743. export var postprocessVertexShader: {
  72744. name: string;
  72745. shader: string;
  72746. };
  72747. }
  72748. declare module BABYLON {
  72749. /** Defines supported spaces */
  72750. export enum Space {
  72751. /** Local (object) space */
  72752. LOCAL = 0,
  72753. /** World space */
  72754. WORLD = 1,
  72755. /** Bone space */
  72756. BONE = 2
  72757. }
  72758. /** Defines the 3 main axes */
  72759. export class Axis {
  72760. /** X axis */
  72761. static X: Vector3;
  72762. /** Y axis */
  72763. static Y: Vector3;
  72764. /** Z axis */
  72765. static Z: Vector3;
  72766. }
  72767. }
  72768. declare module BABYLON {
  72769. /**
  72770. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72771. * This is the base of the follow, arc rotate cameras and Free camera
  72772. * @see http://doc.babylonjs.com/features/cameras
  72773. */
  72774. export class TargetCamera extends Camera {
  72775. private static _RigCamTransformMatrix;
  72776. private static _TargetTransformMatrix;
  72777. private static _TargetFocalPoint;
  72778. /**
  72779. * Define the current direction the camera is moving to
  72780. */
  72781. cameraDirection: Vector3;
  72782. /**
  72783. * Define the current rotation the camera is rotating to
  72784. */
  72785. cameraRotation: Vector2;
  72786. /**
  72787. * When set, the up vector of the camera will be updated by the rotation of the camera
  72788. */
  72789. updateUpVectorFromRotation: boolean;
  72790. private _tmpQuaternion;
  72791. /**
  72792. * Define the current rotation of the camera
  72793. */
  72794. rotation: Vector3;
  72795. /**
  72796. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72797. */
  72798. rotationQuaternion: Quaternion;
  72799. /**
  72800. * Define the current speed of the camera
  72801. */
  72802. speed: number;
  72803. /**
  72804. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72805. * around all axis.
  72806. */
  72807. noRotationConstraint: boolean;
  72808. /**
  72809. * Define the current target of the camera as an object or a position.
  72810. */
  72811. lockedTarget: any;
  72812. /** @hidden */
  72813. _currentTarget: Vector3;
  72814. /** @hidden */
  72815. _initialFocalDistance: number;
  72816. /** @hidden */
  72817. _viewMatrix: Matrix;
  72818. /** @hidden */
  72819. _camMatrix: Matrix;
  72820. /** @hidden */
  72821. _cameraTransformMatrix: Matrix;
  72822. /** @hidden */
  72823. _cameraRotationMatrix: Matrix;
  72824. /** @hidden */
  72825. _referencePoint: Vector3;
  72826. /** @hidden */
  72827. _transformedReferencePoint: Vector3;
  72828. protected _globalCurrentTarget: Vector3;
  72829. protected _globalCurrentUpVector: Vector3;
  72830. /** @hidden */
  72831. _reset: () => void;
  72832. private _defaultUp;
  72833. /**
  72834. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72835. * This is the base of the follow, arc rotate cameras and Free camera
  72836. * @see http://doc.babylonjs.com/features/cameras
  72837. * @param name Defines the name of the camera in the scene
  72838. * @param position Defines the start position of the camera in the scene
  72839. * @param scene Defines the scene the camera belongs to
  72840. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72841. */
  72842. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72843. /**
  72844. * Gets the position in front of the camera at a given distance.
  72845. * @param distance The distance from the camera we want the position to be
  72846. * @returns the position
  72847. */
  72848. getFrontPosition(distance: number): Vector3;
  72849. /** @hidden */
  72850. _getLockedTargetPosition(): Nullable<Vector3>;
  72851. private _storedPosition;
  72852. private _storedRotation;
  72853. private _storedRotationQuaternion;
  72854. /**
  72855. * Store current camera state of the camera (fov, position, rotation, etc..)
  72856. * @returns the camera
  72857. */
  72858. storeState(): Camera;
  72859. /**
  72860. * Restored camera state. You must call storeState() first
  72861. * @returns whether it was successful or not
  72862. * @hidden
  72863. */
  72864. _restoreStateValues(): boolean;
  72865. /** @hidden */
  72866. _initCache(): void;
  72867. /** @hidden */
  72868. _updateCache(ignoreParentClass?: boolean): void;
  72869. /** @hidden */
  72870. _isSynchronizedViewMatrix(): boolean;
  72871. /** @hidden */
  72872. _computeLocalCameraSpeed(): number;
  72873. /**
  72874. * Defines the target the camera should look at.
  72875. * @param target Defines the new target as a Vector or a mesh
  72876. */
  72877. setTarget(target: Vector3): void;
  72878. /**
  72879. * Return the current target position of the camera. This value is expressed in local space.
  72880. * @returns the target position
  72881. */
  72882. getTarget(): Vector3;
  72883. /** @hidden */
  72884. _decideIfNeedsToMove(): boolean;
  72885. /** @hidden */
  72886. _updatePosition(): void;
  72887. /** @hidden */
  72888. _checkInputs(): void;
  72889. protected _updateCameraRotationMatrix(): void;
  72890. /**
  72891. * 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)
  72892. * @returns the current camera
  72893. */
  72894. private _rotateUpVectorWithCameraRotationMatrix;
  72895. private _cachedRotationZ;
  72896. private _cachedQuaternionRotationZ;
  72897. /** @hidden */
  72898. _getViewMatrix(): Matrix;
  72899. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72900. /**
  72901. * @hidden
  72902. */
  72903. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72904. /**
  72905. * @hidden
  72906. */
  72907. _updateRigCameras(): void;
  72908. private _getRigCamPositionAndTarget;
  72909. /**
  72910. * Gets the current object class name.
  72911. * @return the class name
  72912. */
  72913. getClassName(): string;
  72914. }
  72915. }
  72916. declare module BABYLON {
  72917. /**
  72918. * Gather the list of keyboard event types as constants.
  72919. */
  72920. export class KeyboardEventTypes {
  72921. /**
  72922. * The keydown event is fired when a key becomes active (pressed).
  72923. */
  72924. static readonly KEYDOWN: number;
  72925. /**
  72926. * The keyup event is fired when a key has been released.
  72927. */
  72928. static readonly KEYUP: number;
  72929. }
  72930. /**
  72931. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72932. */
  72933. export class KeyboardInfo {
  72934. /**
  72935. * Defines the type of event (KeyboardEventTypes)
  72936. */
  72937. type: number;
  72938. /**
  72939. * Defines the related dom event
  72940. */
  72941. event: KeyboardEvent;
  72942. /**
  72943. * Instantiates a new keyboard info.
  72944. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72945. * @param type Defines the type of event (KeyboardEventTypes)
  72946. * @param event Defines the related dom event
  72947. */
  72948. constructor(
  72949. /**
  72950. * Defines the type of event (KeyboardEventTypes)
  72951. */
  72952. type: number,
  72953. /**
  72954. * Defines the related dom event
  72955. */
  72956. event: KeyboardEvent);
  72957. }
  72958. /**
  72959. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72960. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72961. */
  72962. export class KeyboardInfoPre extends KeyboardInfo {
  72963. /**
  72964. * Defines the type of event (KeyboardEventTypes)
  72965. */
  72966. type: number;
  72967. /**
  72968. * Defines the related dom event
  72969. */
  72970. event: KeyboardEvent;
  72971. /**
  72972. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72973. */
  72974. skipOnPointerObservable: boolean;
  72975. /**
  72976. * Instantiates a new keyboard pre info.
  72977. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72978. * @param type Defines the type of event (KeyboardEventTypes)
  72979. * @param event Defines the related dom event
  72980. */
  72981. constructor(
  72982. /**
  72983. * Defines the type of event (KeyboardEventTypes)
  72984. */
  72985. type: number,
  72986. /**
  72987. * Defines the related dom event
  72988. */
  72989. event: KeyboardEvent);
  72990. }
  72991. }
  72992. declare module BABYLON {
  72993. /**
  72994. * Manage the keyboard inputs to control the movement of a free camera.
  72995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72996. */
  72997. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72998. /**
  72999. * Defines the camera the input is attached to.
  73000. */
  73001. camera: FreeCamera;
  73002. /**
  73003. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73004. */
  73005. keysUp: number[];
  73006. /**
  73007. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73008. */
  73009. keysDown: number[];
  73010. /**
  73011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73012. */
  73013. keysLeft: number[];
  73014. /**
  73015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73016. */
  73017. keysRight: number[];
  73018. private _keys;
  73019. private _onCanvasBlurObserver;
  73020. private _onKeyboardObserver;
  73021. private _engine;
  73022. private _scene;
  73023. /**
  73024. * Attach the input controls to a specific dom element to get the input from.
  73025. * @param element Defines the element the controls should be listened from
  73026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73027. */
  73028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73029. /**
  73030. * Detach the current controls from the specified dom element.
  73031. * @param element Defines the element to stop listening the inputs from
  73032. */
  73033. detachControl(element: Nullable<HTMLElement>): void;
  73034. /**
  73035. * Update the current camera state depending on the inputs that have been used this frame.
  73036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73037. */
  73038. checkInputs(): void;
  73039. /**
  73040. * Gets the class name of the current intput.
  73041. * @returns the class name
  73042. */
  73043. getClassName(): string;
  73044. /** @hidden */
  73045. _onLostFocus(): void;
  73046. /**
  73047. * Get the friendly name associated with the input class.
  73048. * @returns the input friendly name
  73049. */
  73050. getSimpleName(): string;
  73051. }
  73052. }
  73053. declare module BABYLON {
  73054. /**
  73055. * Interface describing all the common properties and methods a shadow light needs to implement.
  73056. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73057. * as well as binding the different shadow properties to the effects.
  73058. */
  73059. export interface IShadowLight extends Light {
  73060. /**
  73061. * The light id in the scene (used in scene.findLighById for instance)
  73062. */
  73063. id: string;
  73064. /**
  73065. * The position the shdow will be casted from.
  73066. */
  73067. position: Vector3;
  73068. /**
  73069. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73070. */
  73071. direction: Vector3;
  73072. /**
  73073. * The transformed position. Position of the light in world space taking parenting in account.
  73074. */
  73075. transformedPosition: Vector3;
  73076. /**
  73077. * The transformed direction. Direction of the light in world space taking parenting in account.
  73078. */
  73079. transformedDirection: Vector3;
  73080. /**
  73081. * The friendly name of the light in the scene.
  73082. */
  73083. name: string;
  73084. /**
  73085. * Defines the shadow projection clipping minimum z value.
  73086. */
  73087. shadowMinZ: number;
  73088. /**
  73089. * Defines the shadow projection clipping maximum z value.
  73090. */
  73091. shadowMaxZ: number;
  73092. /**
  73093. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73094. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73095. */
  73096. computeTransformedInformation(): boolean;
  73097. /**
  73098. * Gets the scene the light belongs to.
  73099. * @returns The scene
  73100. */
  73101. getScene(): Scene;
  73102. /**
  73103. * Callback defining a custom Projection Matrix Builder.
  73104. * This can be used to override the default projection matrix computation.
  73105. */
  73106. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73107. /**
  73108. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73109. * @param matrix The materix to updated with the projection information
  73110. * @param viewMatrix The transform matrix of the light
  73111. * @param renderList The list of mesh to render in the map
  73112. * @returns The current light
  73113. */
  73114. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73115. /**
  73116. * Gets the current depth scale used in ESM.
  73117. * @returns The scale
  73118. */
  73119. getDepthScale(): number;
  73120. /**
  73121. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73122. * @returns true if a cube texture needs to be use
  73123. */
  73124. needCube(): boolean;
  73125. /**
  73126. * Detects if the projection matrix requires to be recomputed this frame.
  73127. * @returns true if it requires to be recomputed otherwise, false.
  73128. */
  73129. needProjectionMatrixCompute(): boolean;
  73130. /**
  73131. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73132. */
  73133. forceProjectionMatrixCompute(): void;
  73134. /**
  73135. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73136. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73137. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73138. */
  73139. getShadowDirection(faceIndex?: number): Vector3;
  73140. /**
  73141. * Gets the minZ used for shadow according to both the scene and the light.
  73142. * @param activeCamera The camera we are returning the min for
  73143. * @returns the depth min z
  73144. */
  73145. getDepthMinZ(activeCamera: Camera): number;
  73146. /**
  73147. * Gets the maxZ used for shadow according to both the scene and the light.
  73148. * @param activeCamera The camera we are returning the max for
  73149. * @returns the depth max z
  73150. */
  73151. getDepthMaxZ(activeCamera: Camera): number;
  73152. }
  73153. /**
  73154. * Base implementation IShadowLight
  73155. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73156. */
  73157. export abstract class ShadowLight extends Light implements IShadowLight {
  73158. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73159. protected _position: Vector3;
  73160. protected _setPosition(value: Vector3): void;
  73161. /**
  73162. * Sets the position the shadow will be casted from. Also use as the light position for both
  73163. * point and spot lights.
  73164. */
  73165. /**
  73166. * Sets the position the shadow will be casted from. Also use as the light position for both
  73167. * point and spot lights.
  73168. */
  73169. position: Vector3;
  73170. protected _direction: Vector3;
  73171. protected _setDirection(value: Vector3): void;
  73172. /**
  73173. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73174. * Also use as the light direction on spot and directional lights.
  73175. */
  73176. /**
  73177. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73178. * Also use as the light direction on spot and directional lights.
  73179. */
  73180. direction: Vector3;
  73181. private _shadowMinZ;
  73182. /**
  73183. * Gets the shadow projection clipping minimum z value.
  73184. */
  73185. /**
  73186. * Sets the shadow projection clipping minimum z value.
  73187. */
  73188. shadowMinZ: number;
  73189. private _shadowMaxZ;
  73190. /**
  73191. * Sets the shadow projection clipping maximum z value.
  73192. */
  73193. /**
  73194. * Gets the shadow projection clipping maximum z value.
  73195. */
  73196. shadowMaxZ: number;
  73197. /**
  73198. * Callback defining a custom Projection Matrix Builder.
  73199. * This can be used to override the default projection matrix computation.
  73200. */
  73201. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73202. /**
  73203. * The transformed position. Position of the light in world space taking parenting in account.
  73204. */
  73205. transformedPosition: Vector3;
  73206. /**
  73207. * The transformed direction. Direction of the light in world space taking parenting in account.
  73208. */
  73209. transformedDirection: Vector3;
  73210. private _needProjectionMatrixCompute;
  73211. /**
  73212. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73213. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73214. */
  73215. computeTransformedInformation(): boolean;
  73216. /**
  73217. * Return the depth scale used for the shadow map.
  73218. * @returns the depth scale.
  73219. */
  73220. getDepthScale(): number;
  73221. /**
  73222. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73223. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73224. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73225. */
  73226. getShadowDirection(faceIndex?: number): Vector3;
  73227. /**
  73228. * Returns the ShadowLight absolute position in the World.
  73229. * @returns the position vector in world space
  73230. */
  73231. getAbsolutePosition(): Vector3;
  73232. /**
  73233. * Sets the ShadowLight direction toward the passed target.
  73234. * @param target The point to target in local space
  73235. * @returns the updated ShadowLight direction
  73236. */
  73237. setDirectionToTarget(target: Vector3): Vector3;
  73238. /**
  73239. * Returns the light rotation in euler definition.
  73240. * @returns the x y z rotation in local space.
  73241. */
  73242. getRotation(): Vector3;
  73243. /**
  73244. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73245. * @returns true if a cube texture needs to be use
  73246. */
  73247. needCube(): boolean;
  73248. /**
  73249. * Detects if the projection matrix requires to be recomputed this frame.
  73250. * @returns true if it requires to be recomputed otherwise, false.
  73251. */
  73252. needProjectionMatrixCompute(): boolean;
  73253. /**
  73254. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73255. */
  73256. forceProjectionMatrixCompute(): void;
  73257. /** @hidden */
  73258. _initCache(): void;
  73259. /** @hidden */
  73260. _isSynchronized(): boolean;
  73261. /**
  73262. * Computes the world matrix of the node
  73263. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73264. * @returns the world matrix
  73265. */
  73266. computeWorldMatrix(force?: boolean): Matrix;
  73267. /**
  73268. * Gets the minZ used for shadow according to both the scene and the light.
  73269. * @param activeCamera The camera we are returning the min for
  73270. * @returns the depth min z
  73271. */
  73272. getDepthMinZ(activeCamera: Camera): number;
  73273. /**
  73274. * Gets the maxZ used for shadow according to both the scene and the light.
  73275. * @param activeCamera The camera we are returning the max for
  73276. * @returns the depth max z
  73277. */
  73278. getDepthMaxZ(activeCamera: Camera): number;
  73279. /**
  73280. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73281. * @param matrix The materix to updated with the projection information
  73282. * @param viewMatrix The transform matrix of the light
  73283. * @param renderList The list of mesh to render in the map
  73284. * @returns The current light
  73285. */
  73286. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73287. }
  73288. }
  73289. declare module BABYLON {
  73290. /**
  73291. * "Static Class" containing the most commonly used helper while dealing with material for
  73292. * rendering purpose.
  73293. *
  73294. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73295. *
  73296. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73297. */
  73298. export class MaterialHelper {
  73299. /**
  73300. * Bind the current view position to an effect.
  73301. * @param effect The effect to be bound
  73302. * @param scene The scene the eyes position is used from
  73303. */
  73304. static BindEyePosition(effect: Effect, scene: Scene): void;
  73305. /**
  73306. * Helps preparing the defines values about the UVs in used in the effect.
  73307. * UVs are shared as much as we can accross channels in the shaders.
  73308. * @param texture The texture we are preparing the UVs for
  73309. * @param defines The defines to update
  73310. * @param key The channel key "diffuse", "specular"... used in the shader
  73311. */
  73312. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73313. /**
  73314. * Binds a texture matrix value to its corrsponding uniform
  73315. * @param texture The texture to bind the matrix for
  73316. * @param uniformBuffer The uniform buffer receivin the data
  73317. * @param key The channel key "diffuse", "specular"... used in the shader
  73318. */
  73319. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73320. /**
  73321. * Gets the current status of the fog (should it be enabled?)
  73322. * @param mesh defines the mesh to evaluate for fog support
  73323. * @param scene defines the hosting scene
  73324. * @returns true if fog must be enabled
  73325. */
  73326. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73327. /**
  73328. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73329. * @param mesh defines the current mesh
  73330. * @param scene defines the current scene
  73331. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73332. * @param pointsCloud defines if point cloud rendering has to be turned on
  73333. * @param fogEnabled defines if fog has to be turned on
  73334. * @param alphaTest defines if alpha testing has to be turned on
  73335. * @param defines defines the current list of defines
  73336. */
  73337. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73338. /**
  73339. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73340. * @param scene defines the current scene
  73341. * @param engine defines the current engine
  73342. * @param defines specifies the list of active defines
  73343. * @param useInstances defines if instances have to be turned on
  73344. * @param useClipPlane defines if clip plane have to be turned on
  73345. */
  73346. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73347. /**
  73348. * Prepares the defines for bones
  73349. * @param mesh The mesh containing the geometry data we will draw
  73350. * @param defines The defines to update
  73351. */
  73352. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73353. /**
  73354. * Prepares the defines for morph targets
  73355. * @param mesh The mesh containing the geometry data we will draw
  73356. * @param defines The defines to update
  73357. */
  73358. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73359. /**
  73360. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73361. * @param mesh The mesh containing the geometry data we will draw
  73362. * @param defines The defines to update
  73363. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73364. * @param useBones Precise whether bones should be used or not (override mesh info)
  73365. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73366. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73367. * @returns false if defines are considered not dirty and have not been checked
  73368. */
  73369. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73370. /**
  73371. * Prepares the defines related to multiview
  73372. * @param scene The scene we are intending to draw
  73373. * @param defines The defines to update
  73374. */
  73375. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73376. /**
  73377. * Prepares the defines related to the light information passed in parameter
  73378. * @param scene The scene we are intending to draw
  73379. * @param mesh The mesh the effect is compiling for
  73380. * @param light The light the effect is compiling for
  73381. * @param lightIndex The index of the light
  73382. * @param defines The defines to update
  73383. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73384. * @param state Defines the current state regarding what is needed (normals, etc...)
  73385. */
  73386. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73387. needNormals: boolean;
  73388. needRebuild: boolean;
  73389. shadowEnabled: boolean;
  73390. specularEnabled: boolean;
  73391. lightmapMode: boolean;
  73392. }): void;
  73393. /**
  73394. * Prepares the defines related to the light information passed in parameter
  73395. * @param scene The scene we are intending to draw
  73396. * @param mesh The mesh the effect is compiling for
  73397. * @param defines The defines to update
  73398. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73399. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73400. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73401. * @returns true if normals will be required for the rest of the effect
  73402. */
  73403. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73404. /**
  73405. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73406. * @param lightIndex defines the light index
  73407. * @param uniformsList The uniform list
  73408. * @param samplersList The sampler list
  73409. * @param projectedLightTexture defines if projected texture must be used
  73410. * @param uniformBuffersList defines an optional list of uniform buffers
  73411. */
  73412. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73413. /**
  73414. * Prepares the uniforms and samplers list to be used in the effect
  73415. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73416. * @param samplersList The sampler list
  73417. * @param defines The defines helping in the list generation
  73418. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73419. */
  73420. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73421. /**
  73422. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73423. * @param defines The defines to update while falling back
  73424. * @param fallbacks The authorized effect fallbacks
  73425. * @param maxSimultaneousLights The maximum number of lights allowed
  73426. * @param rank the current rank of the Effect
  73427. * @returns The newly affected rank
  73428. */
  73429. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73430. private static _TmpMorphInfluencers;
  73431. /**
  73432. * Prepares the list of attributes required for morph targets according to the effect defines.
  73433. * @param attribs The current list of supported attribs
  73434. * @param mesh The mesh to prepare the morph targets attributes for
  73435. * @param influencers The number of influencers
  73436. */
  73437. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73438. /**
  73439. * Prepares the list of attributes required for morph targets according to the effect defines.
  73440. * @param attribs The current list of supported attribs
  73441. * @param mesh The mesh to prepare the morph targets attributes for
  73442. * @param defines The current Defines of the effect
  73443. */
  73444. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73445. /**
  73446. * Prepares the list of attributes required for bones according to the effect defines.
  73447. * @param attribs The current list of supported attribs
  73448. * @param mesh The mesh to prepare the bones attributes for
  73449. * @param defines The current Defines of the effect
  73450. * @param fallbacks The current efffect fallback strategy
  73451. */
  73452. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73453. /**
  73454. * Check and prepare the list of attributes required for instances according to the effect defines.
  73455. * @param attribs The current list of supported attribs
  73456. * @param defines The current MaterialDefines of the effect
  73457. */
  73458. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73459. /**
  73460. * Add the list of attributes required for instances to the attribs array.
  73461. * @param attribs The current list of supported attribs
  73462. */
  73463. static PushAttributesForInstances(attribs: string[]): void;
  73464. /**
  73465. * Binds the light shadow information to the effect for the given mesh.
  73466. * @param light The light containing the generator
  73467. * @param scene The scene the lights belongs to
  73468. * @param mesh The mesh we are binding the information to render
  73469. * @param lightIndex The light index in the effect used to render the mesh
  73470. * @param effect The effect we are binding the data to
  73471. */
  73472. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73473. /**
  73474. * Binds the light information to the effect.
  73475. * @param light The light containing the generator
  73476. * @param effect The effect we are binding the data to
  73477. * @param lightIndex The light index in the effect used to render
  73478. */
  73479. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73480. /**
  73481. * Binds the lights information from the scene to the effect for the given mesh.
  73482. * @param light Light to bind
  73483. * @param lightIndex Light index
  73484. * @param scene The scene where the light belongs to
  73485. * @param mesh The mesh we are binding the information to render
  73486. * @param effect The effect we are binding the data to
  73487. * @param useSpecular Defines if specular is supported
  73488. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73489. */
  73490. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73491. /**
  73492. * Binds the lights information from the scene to the effect for the given mesh.
  73493. * @param scene The scene the lights belongs to
  73494. * @param mesh The mesh we are binding the information to render
  73495. * @param effect The effect we are binding the data to
  73496. * @param defines The generated defines for the effect
  73497. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73498. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73499. */
  73500. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73501. private static _tempFogColor;
  73502. /**
  73503. * Binds the fog information from the scene to the effect for the given mesh.
  73504. * @param scene The scene the lights belongs to
  73505. * @param mesh The mesh we are binding the information to render
  73506. * @param effect The effect we are binding the data to
  73507. * @param linearSpace Defines if the fog effect is applied in linear space
  73508. */
  73509. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73510. /**
  73511. * Binds the bones information from the mesh to the effect.
  73512. * @param mesh The mesh we are binding the information to render
  73513. * @param effect The effect we are binding the data to
  73514. */
  73515. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73516. /**
  73517. * Binds the morph targets information from the mesh to the effect.
  73518. * @param abstractMesh The mesh we are binding the information to render
  73519. * @param effect The effect we are binding the data to
  73520. */
  73521. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73522. /**
  73523. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73524. * @param defines The generated defines used in the effect
  73525. * @param effect The effect we are binding the data to
  73526. * @param scene The scene we are willing to render with logarithmic scale for
  73527. */
  73528. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73529. /**
  73530. * Binds the clip plane information from the scene to the effect.
  73531. * @param scene The scene the clip plane information are extracted from
  73532. * @param effect The effect we are binding the data to
  73533. */
  73534. static BindClipPlane(effect: Effect, scene: Scene): void;
  73535. }
  73536. }
  73537. declare module BABYLON {
  73538. /** @hidden */
  73539. export var packingFunctions: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. declare module BABYLON {
  73545. /** @hidden */
  73546. export var shadowMapPixelShader: {
  73547. name: string;
  73548. shader: string;
  73549. };
  73550. }
  73551. declare module BABYLON {
  73552. /** @hidden */
  73553. export var bonesDeclaration: {
  73554. name: string;
  73555. shader: string;
  73556. };
  73557. }
  73558. declare module BABYLON {
  73559. /** @hidden */
  73560. export var morphTargetsVertexGlobalDeclaration: {
  73561. name: string;
  73562. shader: string;
  73563. };
  73564. }
  73565. declare module BABYLON {
  73566. /** @hidden */
  73567. export var morphTargetsVertexDeclaration: {
  73568. name: string;
  73569. shader: string;
  73570. };
  73571. }
  73572. declare module BABYLON {
  73573. /** @hidden */
  73574. export var instancesDeclaration: {
  73575. name: string;
  73576. shader: string;
  73577. };
  73578. }
  73579. declare module BABYLON {
  73580. /** @hidden */
  73581. export var helperFunctions: {
  73582. name: string;
  73583. shader: string;
  73584. };
  73585. }
  73586. declare module BABYLON {
  73587. /** @hidden */
  73588. export var morphTargetsVertex: {
  73589. name: string;
  73590. shader: string;
  73591. };
  73592. }
  73593. declare module BABYLON {
  73594. /** @hidden */
  73595. export var instancesVertex: {
  73596. name: string;
  73597. shader: string;
  73598. };
  73599. }
  73600. declare module BABYLON {
  73601. /** @hidden */
  73602. export var bonesVertex: {
  73603. name: string;
  73604. shader: string;
  73605. };
  73606. }
  73607. declare module BABYLON {
  73608. /** @hidden */
  73609. export var shadowMapVertexShader: {
  73610. name: string;
  73611. shader: string;
  73612. };
  73613. }
  73614. declare module BABYLON {
  73615. /** @hidden */
  73616. export var depthBoxBlurPixelShader: {
  73617. name: string;
  73618. shader: string;
  73619. };
  73620. }
  73621. declare module BABYLON {
  73622. /**
  73623. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73624. */
  73625. export interface ICustomShaderOptions {
  73626. /**
  73627. * Gets or sets the custom shader name to use
  73628. */
  73629. shaderName: string;
  73630. /**
  73631. * The list of attribute names used in the shader
  73632. */
  73633. attributes?: string[];
  73634. /**
  73635. * The list of unifrom names used in the shader
  73636. */
  73637. uniforms?: string[];
  73638. /**
  73639. * The list of sampler names used in the shader
  73640. */
  73641. samplers?: string[];
  73642. /**
  73643. * The list of defines used in the shader
  73644. */
  73645. defines?: string[];
  73646. }
  73647. /**
  73648. * Interface to implement to create a shadow generator compatible with BJS.
  73649. */
  73650. export interface IShadowGenerator {
  73651. /**
  73652. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73653. * @returns The render target texture if present otherwise, null
  73654. */
  73655. getShadowMap(): Nullable<RenderTargetTexture>;
  73656. /**
  73657. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73658. * @returns The render target texture if the shadow map is present otherwise, null
  73659. */
  73660. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73661. /**
  73662. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73663. * @param subMesh The submesh we want to render in the shadow map
  73664. * @param useInstances Defines wether will draw in the map using instances
  73665. * @returns true if ready otherwise, false
  73666. */
  73667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73668. /**
  73669. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73670. * @param defines Defines of the material we want to update
  73671. * @param lightIndex Index of the light in the enabled light list of the material
  73672. */
  73673. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73674. /**
  73675. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73676. * defined in the generator but impacting the effect).
  73677. * It implies the unifroms available on the materials are the standard BJS ones.
  73678. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73679. * @param effect The effect we are binfing the information for
  73680. */
  73681. bindShadowLight(lightIndex: string, effect: Effect): void;
  73682. /**
  73683. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73684. * (eq to shadow prjection matrix * light transform matrix)
  73685. * @returns The transform matrix used to create the shadow map
  73686. */
  73687. getTransformMatrix(): Matrix;
  73688. /**
  73689. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73690. * Cube and 2D textures for instance.
  73691. */
  73692. recreateShadowMap(): void;
  73693. /**
  73694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73695. * @param onCompiled Callback triggered at the and of the effects compilation
  73696. * @param options Sets of optional options forcing the compilation with different modes
  73697. */
  73698. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73699. useInstances: boolean;
  73700. }>): void;
  73701. /**
  73702. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73703. * @param options Sets of optional options forcing the compilation with different modes
  73704. * @returns A promise that resolves when the compilation completes
  73705. */
  73706. forceCompilationAsync(options?: Partial<{
  73707. useInstances: boolean;
  73708. }>): Promise<void>;
  73709. /**
  73710. * Serializes the shadow generator setup to a json object.
  73711. * @returns The serialized JSON object
  73712. */
  73713. serialize(): any;
  73714. /**
  73715. * Disposes the Shadow map and related Textures and effects.
  73716. */
  73717. dispose(): void;
  73718. }
  73719. /**
  73720. * Default implementation IShadowGenerator.
  73721. * This is the main object responsible of generating shadows in the framework.
  73722. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73723. */
  73724. export class ShadowGenerator implements IShadowGenerator {
  73725. /**
  73726. * Shadow generator mode None: no filtering applied.
  73727. */
  73728. static readonly FILTER_NONE: number;
  73729. /**
  73730. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73731. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73732. */
  73733. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73734. /**
  73735. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73736. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73737. */
  73738. static readonly FILTER_POISSONSAMPLING: number;
  73739. /**
  73740. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73742. */
  73743. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73744. /**
  73745. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73746. * edge artifacts on steep falloff.
  73747. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73748. */
  73749. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73750. /**
  73751. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73752. * edge artifacts on steep falloff.
  73753. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73754. */
  73755. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73756. /**
  73757. * Shadow generator mode PCF: Percentage Closer Filtering
  73758. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73759. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73760. */
  73761. static readonly FILTER_PCF: number;
  73762. /**
  73763. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73764. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73765. * Contact Hardening
  73766. */
  73767. static readonly FILTER_PCSS: number;
  73768. /**
  73769. * Reserved for PCF and PCSS
  73770. * Highest Quality.
  73771. *
  73772. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73773. *
  73774. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73775. */
  73776. static readonly QUALITY_HIGH: number;
  73777. /**
  73778. * Reserved for PCF and PCSS
  73779. * Good tradeoff for quality/perf cross devices
  73780. *
  73781. * Execute PCF on a 3*3 kernel.
  73782. *
  73783. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73784. */
  73785. static readonly QUALITY_MEDIUM: number;
  73786. /**
  73787. * Reserved for PCF and PCSS
  73788. * The lowest quality but the fastest.
  73789. *
  73790. * Execute PCF on a 1*1 kernel.
  73791. *
  73792. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73793. */
  73794. static readonly QUALITY_LOW: number;
  73795. /** Gets or sets the custom shader name to use */
  73796. customShaderOptions: ICustomShaderOptions;
  73797. /**
  73798. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73799. */
  73800. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73801. /**
  73802. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73803. */
  73804. onAfterShadowMapRenderObservable: Observable<Effect>;
  73805. /**
  73806. * Observable triggered before a mesh is rendered in the shadow map.
  73807. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73808. */
  73809. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73810. /**
  73811. * Observable triggered after a mesh is rendered in the shadow map.
  73812. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73813. */
  73814. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73815. private _bias;
  73816. /**
  73817. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73818. */
  73819. /**
  73820. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73821. */
  73822. bias: number;
  73823. private _normalBias;
  73824. /**
  73825. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73826. */
  73827. /**
  73828. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73829. */
  73830. normalBias: number;
  73831. private _blurBoxOffset;
  73832. /**
  73833. * Gets the blur box offset: offset applied during the blur pass.
  73834. * Only useful if useKernelBlur = false
  73835. */
  73836. /**
  73837. * Sets the blur box offset: offset applied during the blur pass.
  73838. * Only useful if useKernelBlur = false
  73839. */
  73840. blurBoxOffset: number;
  73841. private _blurScale;
  73842. /**
  73843. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73844. * 2 means half of the size.
  73845. */
  73846. /**
  73847. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73848. * 2 means half of the size.
  73849. */
  73850. blurScale: number;
  73851. private _blurKernel;
  73852. /**
  73853. * Gets the blur kernel: kernel size of the blur pass.
  73854. * Only useful if useKernelBlur = true
  73855. */
  73856. /**
  73857. * Sets the blur kernel: kernel size of the blur pass.
  73858. * Only useful if useKernelBlur = true
  73859. */
  73860. blurKernel: number;
  73861. private _useKernelBlur;
  73862. /**
  73863. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73864. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73865. */
  73866. /**
  73867. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73868. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73869. */
  73870. useKernelBlur: boolean;
  73871. private _depthScale;
  73872. /**
  73873. * Gets the depth scale used in ESM mode.
  73874. */
  73875. /**
  73876. * Sets the depth scale used in ESM mode.
  73877. * This can override the scale stored on the light.
  73878. */
  73879. depthScale: number;
  73880. private _filter;
  73881. /**
  73882. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73883. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73884. */
  73885. /**
  73886. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73887. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73888. */
  73889. filter: number;
  73890. /**
  73891. * Gets if the current filter is set to Poisson Sampling.
  73892. */
  73893. /**
  73894. * Sets the current filter to Poisson Sampling.
  73895. */
  73896. usePoissonSampling: boolean;
  73897. /**
  73898. * Gets if the current filter is set to ESM.
  73899. */
  73900. /**
  73901. * Sets the current filter is to ESM.
  73902. */
  73903. useExponentialShadowMap: boolean;
  73904. /**
  73905. * Gets if the current filter is set to filtered ESM.
  73906. */
  73907. /**
  73908. * Gets if the current filter is set to filtered ESM.
  73909. */
  73910. useBlurExponentialShadowMap: boolean;
  73911. /**
  73912. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73913. * exponential to prevent steep falloff artifacts).
  73914. */
  73915. /**
  73916. * Sets the current filter to "close ESM" (using the inverse of the
  73917. * exponential to prevent steep falloff artifacts).
  73918. */
  73919. useCloseExponentialShadowMap: boolean;
  73920. /**
  73921. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73922. * exponential to prevent steep falloff artifacts).
  73923. */
  73924. /**
  73925. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73926. * exponential to prevent steep falloff artifacts).
  73927. */
  73928. useBlurCloseExponentialShadowMap: boolean;
  73929. /**
  73930. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73931. */
  73932. /**
  73933. * Sets the current filter to "PCF" (percentage closer filtering).
  73934. */
  73935. usePercentageCloserFiltering: boolean;
  73936. private _filteringQuality;
  73937. /**
  73938. * Gets the PCF or PCSS Quality.
  73939. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73940. */
  73941. /**
  73942. * Sets the PCF or PCSS Quality.
  73943. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73944. */
  73945. filteringQuality: number;
  73946. /**
  73947. * Gets if the current filter is set to "PCSS" (contact hardening).
  73948. */
  73949. /**
  73950. * Sets the current filter to "PCSS" (contact hardening).
  73951. */
  73952. useContactHardeningShadow: boolean;
  73953. private _contactHardeningLightSizeUVRatio;
  73954. /**
  73955. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73956. * Using a ratio helps keeping shape stability independently of the map size.
  73957. *
  73958. * It does not account for the light projection as it was having too much
  73959. * instability during the light setup or during light position changes.
  73960. *
  73961. * Only valid if useContactHardeningShadow is true.
  73962. */
  73963. /**
  73964. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73965. * Using a ratio helps keeping shape stability independently of the map size.
  73966. *
  73967. * It does not account for the light projection as it was having too much
  73968. * instability during the light setup or during light position changes.
  73969. *
  73970. * Only valid if useContactHardeningShadow is true.
  73971. */
  73972. contactHardeningLightSizeUVRatio: number;
  73973. private _darkness;
  73974. /** Gets or sets the actual darkness of a shadow */
  73975. darkness: number;
  73976. /**
  73977. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73978. * 0 means strongest and 1 would means no shadow.
  73979. * @returns the darkness.
  73980. */
  73981. getDarkness(): number;
  73982. /**
  73983. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73984. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73985. * @returns the shadow generator allowing fluent coding.
  73986. */
  73987. setDarkness(darkness: number): ShadowGenerator;
  73988. private _transparencyShadow;
  73989. /** Gets or sets the ability to have transparent shadow */
  73990. transparencyShadow: boolean;
  73991. /**
  73992. * Sets the ability to have transparent shadow (boolean).
  73993. * @param transparent True if transparent else False
  73994. * @returns the shadow generator allowing fluent coding
  73995. */
  73996. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73997. private _shadowMap;
  73998. private _shadowMap2;
  73999. /**
  74000. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74001. * @returns The render target texture if present otherwise, null
  74002. */
  74003. getShadowMap(): Nullable<RenderTargetTexture>;
  74004. /**
  74005. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74006. * @returns The render target texture if the shadow map is present otherwise, null
  74007. */
  74008. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74009. /**
  74010. * Gets the class name of that object
  74011. * @returns "ShadowGenerator"
  74012. */
  74013. getClassName(): string;
  74014. /**
  74015. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74016. * @param mesh Mesh to add
  74017. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74018. * @returns the Shadow Generator itself
  74019. */
  74020. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74021. /**
  74022. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74023. * @param mesh Mesh to remove
  74024. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74025. * @returns the Shadow Generator itself
  74026. */
  74027. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74028. /**
  74029. * Controls the extent to which the shadows fade out at the edge of the frustum
  74030. * Used only by directionals and spots
  74031. */
  74032. frustumEdgeFalloff: number;
  74033. private _light;
  74034. /**
  74035. * Returns the associated light object.
  74036. * @returns the light generating the shadow
  74037. */
  74038. getLight(): IShadowLight;
  74039. /**
  74040. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74041. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74042. * It might on the other hand introduce peter panning.
  74043. */
  74044. forceBackFacesOnly: boolean;
  74045. private _scene;
  74046. private _lightDirection;
  74047. private _effect;
  74048. private _viewMatrix;
  74049. private _projectionMatrix;
  74050. private _transformMatrix;
  74051. private _cachedPosition;
  74052. private _cachedDirection;
  74053. private _cachedDefines;
  74054. private _currentRenderID;
  74055. private _boxBlurPostprocess;
  74056. private _kernelBlurXPostprocess;
  74057. private _kernelBlurYPostprocess;
  74058. private _blurPostProcesses;
  74059. private _mapSize;
  74060. private _currentFaceIndex;
  74061. private _currentFaceIndexCache;
  74062. private _textureType;
  74063. private _defaultTextureMatrix;
  74064. /** @hidden */
  74065. static _SceneComponentInitialization: (scene: Scene) => void;
  74066. /**
  74067. * Creates a ShadowGenerator object.
  74068. * A ShadowGenerator is the required tool to use the shadows.
  74069. * Each light casting shadows needs to use its own ShadowGenerator.
  74070. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74071. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74072. * @param light The light object generating the shadows.
  74073. * @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.
  74074. */
  74075. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74076. private _initializeGenerator;
  74077. private _initializeShadowMap;
  74078. private _initializeBlurRTTAndPostProcesses;
  74079. private _renderForShadowMap;
  74080. private _renderSubMeshForShadowMap;
  74081. private _applyFilterValues;
  74082. /**
  74083. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74084. * @param onCompiled Callback triggered at the and of the effects compilation
  74085. * @param options Sets of optional options forcing the compilation with different modes
  74086. */
  74087. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74088. useInstances: boolean;
  74089. }>): void;
  74090. /**
  74091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74092. * @param options Sets of optional options forcing the compilation with different modes
  74093. * @returns A promise that resolves when the compilation completes
  74094. */
  74095. forceCompilationAsync(options?: Partial<{
  74096. useInstances: boolean;
  74097. }>): Promise<void>;
  74098. /**
  74099. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74100. * @param subMesh The submesh we want to render in the shadow map
  74101. * @param useInstances Defines wether will draw in the map using instances
  74102. * @returns true if ready otherwise, false
  74103. */
  74104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74105. /**
  74106. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74107. * @param defines Defines of the material we want to update
  74108. * @param lightIndex Index of the light in the enabled light list of the material
  74109. */
  74110. prepareDefines(defines: any, lightIndex: number): void;
  74111. /**
  74112. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74113. * defined in the generator but impacting the effect).
  74114. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74115. * @param effect The effect we are binfing the information for
  74116. */
  74117. bindShadowLight(lightIndex: string, effect: Effect): void;
  74118. /**
  74119. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74120. * (eq to shadow prjection matrix * light transform matrix)
  74121. * @returns The transform matrix used to create the shadow map
  74122. */
  74123. getTransformMatrix(): Matrix;
  74124. /**
  74125. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74126. * Cube and 2D textures for instance.
  74127. */
  74128. recreateShadowMap(): void;
  74129. private _disposeBlurPostProcesses;
  74130. private _disposeRTTandPostProcesses;
  74131. /**
  74132. * Disposes the ShadowGenerator.
  74133. * Returns nothing.
  74134. */
  74135. dispose(): void;
  74136. /**
  74137. * Serializes the shadow generator setup to a json object.
  74138. * @returns The serialized JSON object
  74139. */
  74140. serialize(): any;
  74141. /**
  74142. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74143. * @param parsedShadowGenerator The JSON object to parse
  74144. * @param scene The scene to create the shadow map for
  74145. * @returns The parsed shadow generator
  74146. */
  74147. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74148. }
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74153. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74154. * 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.
  74155. */
  74156. export abstract class Light extends Node {
  74157. /**
  74158. * Falloff Default: light is falling off following the material specification:
  74159. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74160. */
  74161. static readonly FALLOFF_DEFAULT: number;
  74162. /**
  74163. * Falloff Physical: light is falling off following the inverse squared distance law.
  74164. */
  74165. static readonly FALLOFF_PHYSICAL: number;
  74166. /**
  74167. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74168. * to enhance interoperability with other engines.
  74169. */
  74170. static readonly FALLOFF_GLTF: number;
  74171. /**
  74172. * Falloff Standard: light is falling off like in the standard material
  74173. * to enhance interoperability with other materials.
  74174. */
  74175. static readonly FALLOFF_STANDARD: number;
  74176. /**
  74177. * If every light affecting the material is in this lightmapMode,
  74178. * material.lightmapTexture adds or multiplies
  74179. * (depends on material.useLightmapAsShadowmap)
  74180. * after every other light calculations.
  74181. */
  74182. static readonly LIGHTMAP_DEFAULT: number;
  74183. /**
  74184. * material.lightmapTexture as only diffuse lighting from this light
  74185. * adds only specular lighting from this light
  74186. * adds dynamic shadows
  74187. */
  74188. static readonly LIGHTMAP_SPECULAR: number;
  74189. /**
  74190. * material.lightmapTexture as only lighting
  74191. * no light calculation from this light
  74192. * only adds dynamic shadows from this light
  74193. */
  74194. static readonly LIGHTMAP_SHADOWSONLY: number;
  74195. /**
  74196. * Each light type uses the default quantity according to its type:
  74197. * point/spot lights use luminous intensity
  74198. * directional lights use illuminance
  74199. */
  74200. static readonly INTENSITYMODE_AUTOMATIC: number;
  74201. /**
  74202. * lumen (lm)
  74203. */
  74204. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74205. /**
  74206. * candela (lm/sr)
  74207. */
  74208. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74209. /**
  74210. * lux (lm/m^2)
  74211. */
  74212. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74213. /**
  74214. * nit (cd/m^2)
  74215. */
  74216. static readonly INTENSITYMODE_LUMINANCE: number;
  74217. /**
  74218. * Light type const id of the point light.
  74219. */
  74220. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74221. /**
  74222. * Light type const id of the directional light.
  74223. */
  74224. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74225. /**
  74226. * Light type const id of the spot light.
  74227. */
  74228. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74229. /**
  74230. * Light type const id of the hemispheric light.
  74231. */
  74232. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74233. /**
  74234. * Diffuse gives the basic color to an object.
  74235. */
  74236. diffuse: Color3;
  74237. /**
  74238. * Specular produces a highlight color on an object.
  74239. * Note: This is note affecting PBR materials.
  74240. */
  74241. specular: Color3;
  74242. /**
  74243. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74244. * falling off base on range or angle.
  74245. * This can be set to any values in Light.FALLOFF_x.
  74246. *
  74247. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74248. * other types of materials.
  74249. */
  74250. falloffType: number;
  74251. /**
  74252. * Strength of the light.
  74253. * Note: By default it is define in the framework own unit.
  74254. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74255. */
  74256. intensity: number;
  74257. private _range;
  74258. protected _inverseSquaredRange: number;
  74259. /**
  74260. * Defines how far from the source the light is impacting in scene units.
  74261. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74262. */
  74263. /**
  74264. * Defines how far from the source the light is impacting in scene units.
  74265. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74266. */
  74267. range: number;
  74268. /**
  74269. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74270. * of light.
  74271. */
  74272. private _photometricScale;
  74273. private _intensityMode;
  74274. /**
  74275. * Gets the photometric scale used to interpret the intensity.
  74276. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74277. */
  74278. /**
  74279. * Sets the photometric scale used to interpret the intensity.
  74280. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74281. */
  74282. intensityMode: number;
  74283. private _radius;
  74284. /**
  74285. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74286. */
  74287. /**
  74288. * sets the light radius used by PBR Materials to simulate soft area lights.
  74289. */
  74290. radius: number;
  74291. private _renderPriority;
  74292. /**
  74293. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74294. * exceeding the number allowed of the materials.
  74295. */
  74296. renderPriority: number;
  74297. private _shadowEnabled;
  74298. /**
  74299. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74300. * the current shadow generator.
  74301. */
  74302. /**
  74303. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74304. * the current shadow generator.
  74305. */
  74306. shadowEnabled: boolean;
  74307. private _includedOnlyMeshes;
  74308. /**
  74309. * Gets the only meshes impacted by this light.
  74310. */
  74311. /**
  74312. * Sets the only meshes impacted by this light.
  74313. */
  74314. includedOnlyMeshes: AbstractMesh[];
  74315. private _excludedMeshes;
  74316. /**
  74317. * Gets the meshes not impacted by this light.
  74318. */
  74319. /**
  74320. * Sets the meshes not impacted by this light.
  74321. */
  74322. excludedMeshes: AbstractMesh[];
  74323. private _excludeWithLayerMask;
  74324. /**
  74325. * Gets the layer id use to find what meshes are not impacted by the light.
  74326. * Inactive if 0
  74327. */
  74328. /**
  74329. * Sets the layer id use to find what meshes are not impacted by the light.
  74330. * Inactive if 0
  74331. */
  74332. excludeWithLayerMask: number;
  74333. private _includeOnlyWithLayerMask;
  74334. /**
  74335. * Gets the layer id use to find what meshes are impacted by the light.
  74336. * Inactive if 0
  74337. */
  74338. /**
  74339. * Sets the layer id use to find what meshes are impacted by the light.
  74340. * Inactive if 0
  74341. */
  74342. includeOnlyWithLayerMask: number;
  74343. private _lightmapMode;
  74344. /**
  74345. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74346. */
  74347. /**
  74348. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74349. */
  74350. lightmapMode: number;
  74351. /**
  74352. * Shadow generator associted to the light.
  74353. * @hidden Internal use only.
  74354. */
  74355. _shadowGenerator: Nullable<IShadowGenerator>;
  74356. /**
  74357. * @hidden Internal use only.
  74358. */
  74359. _excludedMeshesIds: string[];
  74360. /**
  74361. * @hidden Internal use only.
  74362. */
  74363. _includedOnlyMeshesIds: string[];
  74364. /**
  74365. * The current light unifom buffer.
  74366. * @hidden Internal use only.
  74367. */
  74368. _uniformBuffer: UniformBuffer;
  74369. /**
  74370. * Creates a Light object in the scene.
  74371. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74372. * @param name The firendly name of the light
  74373. * @param scene The scene the light belongs too
  74374. */
  74375. constructor(name: string, scene: Scene);
  74376. protected abstract _buildUniformLayout(): void;
  74377. /**
  74378. * Sets the passed Effect "effect" with the Light information.
  74379. * @param effect The effect to update
  74380. * @param lightIndex The index of the light in the effect to update
  74381. * @returns The light
  74382. */
  74383. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74384. /**
  74385. * Returns the string "Light".
  74386. * @returns the class name
  74387. */
  74388. getClassName(): string;
  74389. /** @hidden */
  74390. readonly _isLight: boolean;
  74391. /**
  74392. * Converts the light information to a readable string for debug purpose.
  74393. * @param fullDetails Supports for multiple levels of logging within scene loading
  74394. * @returns the human readable light info
  74395. */
  74396. toString(fullDetails?: boolean): string;
  74397. /** @hidden */
  74398. protected _syncParentEnabledState(): void;
  74399. /**
  74400. * Set the enabled state of this node.
  74401. * @param value - the new enabled state
  74402. */
  74403. setEnabled(value: boolean): void;
  74404. /**
  74405. * Returns the Light associated shadow generator if any.
  74406. * @return the associated shadow generator.
  74407. */
  74408. getShadowGenerator(): Nullable<IShadowGenerator>;
  74409. /**
  74410. * Returns a Vector3, the absolute light position in the World.
  74411. * @returns the world space position of the light
  74412. */
  74413. getAbsolutePosition(): Vector3;
  74414. /**
  74415. * Specifies if the light will affect the passed mesh.
  74416. * @param mesh The mesh to test against the light
  74417. * @return true the mesh is affected otherwise, false.
  74418. */
  74419. canAffectMesh(mesh: AbstractMesh): boolean;
  74420. /**
  74421. * Sort function to order lights for rendering.
  74422. * @param a First Light object to compare to second.
  74423. * @param b Second Light object to compare first.
  74424. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74425. */
  74426. static CompareLightsPriority(a: Light, b: Light): number;
  74427. /**
  74428. * Releases resources associated with this node.
  74429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74431. */
  74432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74433. /**
  74434. * Returns the light type ID (integer).
  74435. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74436. */
  74437. getTypeID(): number;
  74438. /**
  74439. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74440. * @returns the scaled intensity in intensity mode unit
  74441. */
  74442. getScaledIntensity(): number;
  74443. /**
  74444. * Returns a new Light object, named "name", from the current one.
  74445. * @param name The name of the cloned light
  74446. * @returns the new created light
  74447. */
  74448. clone(name: string): Nullable<Light>;
  74449. /**
  74450. * Serializes the current light into a Serialization object.
  74451. * @returns the serialized object.
  74452. */
  74453. serialize(): any;
  74454. /**
  74455. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74456. * This new light is named "name" and added to the passed scene.
  74457. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74458. * @param name The friendly name of the light
  74459. * @param scene The scene the new light will belong to
  74460. * @returns the constructor function
  74461. */
  74462. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74463. /**
  74464. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74465. * @param parsedLight The JSON representation of the light
  74466. * @param scene The scene to create the parsed light in
  74467. * @returns the created light after parsing
  74468. */
  74469. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74470. private _hookArrayForExcluded;
  74471. private _hookArrayForIncludedOnly;
  74472. private _resyncMeshes;
  74473. /**
  74474. * Forces the meshes to update their light related information in their rendering used effects
  74475. * @hidden Internal Use Only
  74476. */
  74477. _markMeshesAsLightDirty(): void;
  74478. /**
  74479. * Recomputes the cached photometric scale if needed.
  74480. */
  74481. private _computePhotometricScale;
  74482. /**
  74483. * Returns the Photometric Scale according to the light type and intensity mode.
  74484. */
  74485. private _getPhotometricScale;
  74486. /**
  74487. * Reorder the light in the scene according to their defined priority.
  74488. * @hidden Internal Use Only
  74489. */
  74490. _reorderLightsInScene(): void;
  74491. /**
  74492. * Prepares the list of defines specific to the light type.
  74493. * @param defines the list of defines
  74494. * @param lightIndex defines the index of the light for the effect
  74495. */
  74496. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74497. }
  74498. }
  74499. declare module BABYLON {
  74500. /**
  74501. * Interface used to define Action
  74502. */
  74503. export interface IAction {
  74504. /**
  74505. * Trigger for the action
  74506. */
  74507. trigger: number;
  74508. /** Options of the trigger */
  74509. triggerOptions: any;
  74510. /**
  74511. * Gets the trigger parameters
  74512. * @returns the trigger parameters
  74513. */
  74514. getTriggerParameter(): any;
  74515. /**
  74516. * Internal only - executes current action event
  74517. * @hidden
  74518. */
  74519. _executeCurrent(evt?: ActionEvent): void;
  74520. /**
  74521. * Serialize placeholder for child classes
  74522. * @param parent of child
  74523. * @returns the serialized object
  74524. */
  74525. serialize(parent: any): any;
  74526. /**
  74527. * Internal only
  74528. * @hidden
  74529. */
  74530. _prepare(): void;
  74531. /**
  74532. * Internal only - manager for action
  74533. * @hidden
  74534. */
  74535. _actionManager: AbstractActionManager;
  74536. /**
  74537. * Adds action to chain of actions, may be a DoNothingAction
  74538. * @param action defines the next action to execute
  74539. * @returns The action passed in
  74540. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74541. */
  74542. then(action: IAction): IAction;
  74543. }
  74544. /**
  74545. * The action to be carried out following a trigger
  74546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74547. */
  74548. export class Action implements IAction {
  74549. /** the trigger, with or without parameters, for the action */
  74550. triggerOptions: any;
  74551. /**
  74552. * Trigger for the action
  74553. */
  74554. trigger: number;
  74555. /**
  74556. * Internal only - manager for action
  74557. * @hidden
  74558. */
  74559. _actionManager: ActionManager;
  74560. private _nextActiveAction;
  74561. private _child;
  74562. private _condition?;
  74563. private _triggerParameter;
  74564. /**
  74565. * An event triggered prior to action being executed.
  74566. */
  74567. onBeforeExecuteObservable: Observable<Action>;
  74568. /**
  74569. * Creates a new Action
  74570. * @param triggerOptions the trigger, with or without parameters, for the action
  74571. * @param condition an optional determinant of action
  74572. */
  74573. constructor(
  74574. /** the trigger, with or without parameters, for the action */
  74575. triggerOptions: any, condition?: Condition);
  74576. /**
  74577. * Internal only
  74578. * @hidden
  74579. */
  74580. _prepare(): void;
  74581. /**
  74582. * Gets the trigger parameters
  74583. * @returns the trigger parameters
  74584. */
  74585. getTriggerParameter(): any;
  74586. /**
  74587. * Internal only - executes current action event
  74588. * @hidden
  74589. */
  74590. _executeCurrent(evt?: ActionEvent): void;
  74591. /**
  74592. * Execute placeholder for child classes
  74593. * @param evt optional action event
  74594. */
  74595. execute(evt?: ActionEvent): void;
  74596. /**
  74597. * Skips to next active action
  74598. */
  74599. skipToNextActiveAction(): void;
  74600. /**
  74601. * Adds action to chain of actions, may be a DoNothingAction
  74602. * @param action defines the next action to execute
  74603. * @returns The action passed in
  74604. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74605. */
  74606. then(action: Action): Action;
  74607. /**
  74608. * Internal only
  74609. * @hidden
  74610. */
  74611. _getProperty(propertyPath: string): string;
  74612. /**
  74613. * Internal only
  74614. * @hidden
  74615. */
  74616. _getEffectiveTarget(target: any, propertyPath: string): any;
  74617. /**
  74618. * Serialize placeholder for child classes
  74619. * @param parent of child
  74620. * @returns the serialized object
  74621. */
  74622. serialize(parent: any): any;
  74623. /**
  74624. * Internal only called by serialize
  74625. * @hidden
  74626. */
  74627. protected _serialize(serializedAction: any, parent?: any): any;
  74628. /**
  74629. * Internal only
  74630. * @hidden
  74631. */
  74632. static _SerializeValueAsString: (value: any) => string;
  74633. /**
  74634. * Internal only
  74635. * @hidden
  74636. */
  74637. static _GetTargetProperty: (target: Node | Scene) => {
  74638. name: string;
  74639. targetType: string;
  74640. value: string;
  74641. };
  74642. }
  74643. }
  74644. declare module BABYLON {
  74645. /**
  74646. * A Condition applied to an Action
  74647. */
  74648. export class Condition {
  74649. /**
  74650. * Internal only - manager for action
  74651. * @hidden
  74652. */
  74653. _actionManager: ActionManager;
  74654. /**
  74655. * Internal only
  74656. * @hidden
  74657. */
  74658. _evaluationId: number;
  74659. /**
  74660. * Internal only
  74661. * @hidden
  74662. */
  74663. _currentResult: boolean;
  74664. /**
  74665. * Creates a new Condition
  74666. * @param actionManager the manager of the action the condition is applied to
  74667. */
  74668. constructor(actionManager: ActionManager);
  74669. /**
  74670. * Check if the current condition is valid
  74671. * @returns a boolean
  74672. */
  74673. isValid(): boolean;
  74674. /**
  74675. * Internal only
  74676. * @hidden
  74677. */
  74678. _getProperty(propertyPath: string): string;
  74679. /**
  74680. * Internal only
  74681. * @hidden
  74682. */
  74683. _getEffectiveTarget(target: any, propertyPath: string): any;
  74684. /**
  74685. * Serialize placeholder for child classes
  74686. * @returns the serialized object
  74687. */
  74688. serialize(): any;
  74689. /**
  74690. * Internal only
  74691. * @hidden
  74692. */
  74693. protected _serialize(serializedCondition: any): any;
  74694. }
  74695. /**
  74696. * Defines specific conditional operators as extensions of Condition
  74697. */
  74698. export class ValueCondition extends Condition {
  74699. /** path to specify the property of the target the conditional operator uses */
  74700. propertyPath: string;
  74701. /** the value compared by the conditional operator against the current value of the property */
  74702. value: any;
  74703. /** the conditional operator, default ValueCondition.IsEqual */
  74704. operator: number;
  74705. /**
  74706. * Internal only
  74707. * @hidden
  74708. */
  74709. private static _IsEqual;
  74710. /**
  74711. * Internal only
  74712. * @hidden
  74713. */
  74714. private static _IsDifferent;
  74715. /**
  74716. * Internal only
  74717. * @hidden
  74718. */
  74719. private static _IsGreater;
  74720. /**
  74721. * Internal only
  74722. * @hidden
  74723. */
  74724. private static _IsLesser;
  74725. /**
  74726. * returns the number for IsEqual
  74727. */
  74728. static readonly IsEqual: number;
  74729. /**
  74730. * Returns the number for IsDifferent
  74731. */
  74732. static readonly IsDifferent: number;
  74733. /**
  74734. * Returns the number for IsGreater
  74735. */
  74736. static readonly IsGreater: number;
  74737. /**
  74738. * Returns the number for IsLesser
  74739. */
  74740. static readonly IsLesser: number;
  74741. /**
  74742. * Internal only The action manager for the condition
  74743. * @hidden
  74744. */
  74745. _actionManager: ActionManager;
  74746. /**
  74747. * Internal only
  74748. * @hidden
  74749. */
  74750. private _target;
  74751. /**
  74752. * Internal only
  74753. * @hidden
  74754. */
  74755. private _effectiveTarget;
  74756. /**
  74757. * Internal only
  74758. * @hidden
  74759. */
  74760. private _property;
  74761. /**
  74762. * Creates a new ValueCondition
  74763. * @param actionManager manager for the action the condition applies to
  74764. * @param target for the action
  74765. * @param propertyPath path to specify the property of the target the conditional operator uses
  74766. * @param value the value compared by the conditional operator against the current value of the property
  74767. * @param operator the conditional operator, default ValueCondition.IsEqual
  74768. */
  74769. constructor(actionManager: ActionManager, target: any,
  74770. /** path to specify the property of the target the conditional operator uses */
  74771. propertyPath: string,
  74772. /** the value compared by the conditional operator against the current value of the property */
  74773. value: any,
  74774. /** the conditional operator, default ValueCondition.IsEqual */
  74775. operator?: number);
  74776. /**
  74777. * Compares the given value with the property value for the specified conditional operator
  74778. * @returns the result of the comparison
  74779. */
  74780. isValid(): boolean;
  74781. /**
  74782. * Serialize the ValueCondition into a JSON compatible object
  74783. * @returns serialization object
  74784. */
  74785. serialize(): any;
  74786. /**
  74787. * Gets the name of the conditional operator for the ValueCondition
  74788. * @param operator the conditional operator
  74789. * @returns the name
  74790. */
  74791. static GetOperatorName(operator: number): string;
  74792. }
  74793. /**
  74794. * Defines a predicate condition as an extension of Condition
  74795. */
  74796. export class PredicateCondition extends Condition {
  74797. /** defines the predicate function used to validate the condition */
  74798. predicate: () => boolean;
  74799. /**
  74800. * Internal only - manager for action
  74801. * @hidden
  74802. */
  74803. _actionManager: ActionManager;
  74804. /**
  74805. * Creates a new PredicateCondition
  74806. * @param actionManager manager for the action the condition applies to
  74807. * @param predicate defines the predicate function used to validate the condition
  74808. */
  74809. constructor(actionManager: ActionManager,
  74810. /** defines the predicate function used to validate the condition */
  74811. predicate: () => boolean);
  74812. /**
  74813. * @returns the validity of the predicate condition
  74814. */
  74815. isValid(): boolean;
  74816. }
  74817. /**
  74818. * Defines a state condition as an extension of Condition
  74819. */
  74820. export class StateCondition extends Condition {
  74821. /** Value to compare with target state */
  74822. value: string;
  74823. /**
  74824. * Internal only - manager for action
  74825. * @hidden
  74826. */
  74827. _actionManager: ActionManager;
  74828. /**
  74829. * Internal only
  74830. * @hidden
  74831. */
  74832. private _target;
  74833. /**
  74834. * Creates a new StateCondition
  74835. * @param actionManager manager for the action the condition applies to
  74836. * @param target of the condition
  74837. * @param value to compare with target state
  74838. */
  74839. constructor(actionManager: ActionManager, target: any,
  74840. /** Value to compare with target state */
  74841. value: string);
  74842. /**
  74843. * Gets a boolean indicating if the current condition is met
  74844. * @returns the validity of the state
  74845. */
  74846. isValid(): boolean;
  74847. /**
  74848. * Serialize the StateCondition into a JSON compatible object
  74849. * @returns serialization object
  74850. */
  74851. serialize(): any;
  74852. }
  74853. }
  74854. declare module BABYLON {
  74855. /**
  74856. * This defines an action responsible to toggle a boolean once triggered.
  74857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74858. */
  74859. export class SwitchBooleanAction extends Action {
  74860. /**
  74861. * The path to the boolean property in the target object
  74862. */
  74863. propertyPath: string;
  74864. private _target;
  74865. private _effectiveTarget;
  74866. private _property;
  74867. /**
  74868. * Instantiate the action
  74869. * @param triggerOptions defines the trigger options
  74870. * @param target defines the object containing the boolean
  74871. * @param propertyPath defines the path to the boolean property in the target object
  74872. * @param condition defines the trigger related conditions
  74873. */
  74874. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74875. /** @hidden */
  74876. _prepare(): void;
  74877. /**
  74878. * Execute the action toggle the boolean value.
  74879. */
  74880. execute(): void;
  74881. /**
  74882. * Serializes the actions and its related information.
  74883. * @param parent defines the object to serialize in
  74884. * @returns the serialized object
  74885. */
  74886. serialize(parent: any): any;
  74887. }
  74888. /**
  74889. * This defines an action responsible to set a the state field of the target
  74890. * to a desired value once triggered.
  74891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74892. */
  74893. export class SetStateAction extends Action {
  74894. /**
  74895. * The value to store in the state field.
  74896. */
  74897. value: string;
  74898. private _target;
  74899. /**
  74900. * Instantiate the action
  74901. * @param triggerOptions defines the trigger options
  74902. * @param target defines the object containing the state property
  74903. * @param value defines the value to store in the state field
  74904. * @param condition defines the trigger related conditions
  74905. */
  74906. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74907. /**
  74908. * Execute the action and store the value on the target state property.
  74909. */
  74910. execute(): void;
  74911. /**
  74912. * Serializes the actions and its related information.
  74913. * @param parent defines the object to serialize in
  74914. * @returns the serialized object
  74915. */
  74916. serialize(parent: any): any;
  74917. }
  74918. /**
  74919. * This defines an action responsible to set a property of the target
  74920. * to a desired value once triggered.
  74921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74922. */
  74923. export class SetValueAction extends Action {
  74924. /**
  74925. * The path of the property to set in the target.
  74926. */
  74927. propertyPath: string;
  74928. /**
  74929. * The value to set in the property
  74930. */
  74931. value: any;
  74932. private _target;
  74933. private _effectiveTarget;
  74934. private _property;
  74935. /**
  74936. * Instantiate the action
  74937. * @param triggerOptions defines the trigger options
  74938. * @param target defines the object containing the property
  74939. * @param propertyPath defines the path of the property to set in the target
  74940. * @param value defines the value to set in the property
  74941. * @param condition defines the trigger related conditions
  74942. */
  74943. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74944. /** @hidden */
  74945. _prepare(): void;
  74946. /**
  74947. * Execute the action and set the targetted property to the desired value.
  74948. */
  74949. execute(): void;
  74950. /**
  74951. * Serializes the actions and its related information.
  74952. * @param parent defines the object to serialize in
  74953. * @returns the serialized object
  74954. */
  74955. serialize(parent: any): any;
  74956. }
  74957. /**
  74958. * This defines an action responsible to increment the target value
  74959. * to a desired value once triggered.
  74960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74961. */
  74962. export class IncrementValueAction extends Action {
  74963. /**
  74964. * The path of the property to increment in the target.
  74965. */
  74966. propertyPath: string;
  74967. /**
  74968. * The value we should increment the property by.
  74969. */
  74970. value: any;
  74971. private _target;
  74972. private _effectiveTarget;
  74973. private _property;
  74974. /**
  74975. * Instantiate the action
  74976. * @param triggerOptions defines the trigger options
  74977. * @param target defines the object containing the property
  74978. * @param propertyPath defines the path of the property to increment in the target
  74979. * @param value defines the value value we should increment the property by
  74980. * @param condition defines the trigger related conditions
  74981. */
  74982. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74983. /** @hidden */
  74984. _prepare(): void;
  74985. /**
  74986. * Execute the action and increment the target of the value amount.
  74987. */
  74988. execute(): void;
  74989. /**
  74990. * Serializes the actions and its related information.
  74991. * @param parent defines the object to serialize in
  74992. * @returns the serialized object
  74993. */
  74994. serialize(parent: any): any;
  74995. }
  74996. /**
  74997. * This defines an action responsible to start an animation once triggered.
  74998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74999. */
  75000. export class PlayAnimationAction extends Action {
  75001. /**
  75002. * Where the animation should start (animation frame)
  75003. */
  75004. from: number;
  75005. /**
  75006. * Where the animation should stop (animation frame)
  75007. */
  75008. to: number;
  75009. /**
  75010. * Define if the animation should loop or stop after the first play.
  75011. */
  75012. loop?: boolean;
  75013. private _target;
  75014. /**
  75015. * Instantiate the action
  75016. * @param triggerOptions defines the trigger options
  75017. * @param target defines the target animation or animation name
  75018. * @param from defines from where the animation should start (animation frame)
  75019. * @param end defines where the animation should stop (animation frame)
  75020. * @param loop defines if the animation should loop or stop after the first play
  75021. * @param condition defines the trigger related conditions
  75022. */
  75023. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75024. /** @hidden */
  75025. _prepare(): void;
  75026. /**
  75027. * Execute the action and play the animation.
  75028. */
  75029. execute(): void;
  75030. /**
  75031. * Serializes the actions and its related information.
  75032. * @param parent defines the object to serialize in
  75033. * @returns the serialized object
  75034. */
  75035. serialize(parent: any): any;
  75036. }
  75037. /**
  75038. * This defines an action responsible to stop an animation once triggered.
  75039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75040. */
  75041. export class StopAnimationAction extends Action {
  75042. private _target;
  75043. /**
  75044. * Instantiate the action
  75045. * @param triggerOptions defines the trigger options
  75046. * @param target defines the target animation or animation name
  75047. * @param condition defines the trigger related conditions
  75048. */
  75049. constructor(triggerOptions: any, target: any, condition?: Condition);
  75050. /** @hidden */
  75051. _prepare(): void;
  75052. /**
  75053. * Execute the action and stop the animation.
  75054. */
  75055. execute(): void;
  75056. /**
  75057. * Serializes the actions and its related information.
  75058. * @param parent defines the object to serialize in
  75059. * @returns the serialized object
  75060. */
  75061. serialize(parent: any): any;
  75062. }
  75063. /**
  75064. * This defines an action responsible that does nothing once triggered.
  75065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75066. */
  75067. export class DoNothingAction extends Action {
  75068. /**
  75069. * Instantiate the action
  75070. * @param triggerOptions defines the trigger options
  75071. * @param condition defines the trigger related conditions
  75072. */
  75073. constructor(triggerOptions?: any, condition?: Condition);
  75074. /**
  75075. * Execute the action and do nothing.
  75076. */
  75077. execute(): void;
  75078. /**
  75079. * Serializes the actions and its related information.
  75080. * @param parent defines the object to serialize in
  75081. * @returns the serialized object
  75082. */
  75083. serialize(parent: any): any;
  75084. }
  75085. /**
  75086. * This defines an action responsible to trigger several actions once triggered.
  75087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75088. */
  75089. export class CombineAction extends Action {
  75090. /**
  75091. * The list of aggregated animations to run.
  75092. */
  75093. children: Action[];
  75094. /**
  75095. * Instantiate the action
  75096. * @param triggerOptions defines the trigger options
  75097. * @param children defines the list of aggregated animations to run
  75098. * @param condition defines the trigger related conditions
  75099. */
  75100. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75101. /** @hidden */
  75102. _prepare(): void;
  75103. /**
  75104. * Execute the action and executes all the aggregated actions.
  75105. */
  75106. execute(evt: ActionEvent): void;
  75107. /**
  75108. * Serializes the actions and its related information.
  75109. * @param parent defines the object to serialize in
  75110. * @returns the serialized object
  75111. */
  75112. serialize(parent: any): any;
  75113. }
  75114. /**
  75115. * This defines an action responsible to run code (external event) once triggered.
  75116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75117. */
  75118. export class ExecuteCodeAction extends Action {
  75119. /**
  75120. * The callback function to run.
  75121. */
  75122. func: (evt: ActionEvent) => void;
  75123. /**
  75124. * Instantiate the action
  75125. * @param triggerOptions defines the trigger options
  75126. * @param func defines the callback function to run
  75127. * @param condition defines the trigger related conditions
  75128. */
  75129. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75130. /**
  75131. * Execute the action and run the attached code.
  75132. */
  75133. execute(evt: ActionEvent): void;
  75134. }
  75135. /**
  75136. * This defines an action responsible to set the parent property of the target once triggered.
  75137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75138. */
  75139. export class SetParentAction extends Action {
  75140. private _parent;
  75141. private _target;
  75142. /**
  75143. * Instantiate the action
  75144. * @param triggerOptions defines the trigger options
  75145. * @param target defines the target containing the parent property
  75146. * @param parent defines from where the animation should start (animation frame)
  75147. * @param condition defines the trigger related conditions
  75148. */
  75149. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75150. /** @hidden */
  75151. _prepare(): void;
  75152. /**
  75153. * Execute the action and set the parent property.
  75154. */
  75155. execute(): void;
  75156. /**
  75157. * Serializes the actions and its related information.
  75158. * @param parent defines the object to serialize in
  75159. * @returns the serialized object
  75160. */
  75161. serialize(parent: any): any;
  75162. }
  75163. }
  75164. declare module BABYLON {
  75165. /**
  75166. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75167. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75169. */
  75170. export class ActionManager extends AbstractActionManager {
  75171. /**
  75172. * Nothing
  75173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75174. */
  75175. static readonly NothingTrigger: number;
  75176. /**
  75177. * On pick
  75178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75179. */
  75180. static readonly OnPickTrigger: number;
  75181. /**
  75182. * On left pick
  75183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75184. */
  75185. static readonly OnLeftPickTrigger: number;
  75186. /**
  75187. * On right pick
  75188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75189. */
  75190. static readonly OnRightPickTrigger: number;
  75191. /**
  75192. * On center pick
  75193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75194. */
  75195. static readonly OnCenterPickTrigger: number;
  75196. /**
  75197. * On pick down
  75198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75199. */
  75200. static readonly OnPickDownTrigger: number;
  75201. /**
  75202. * On double pick
  75203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75204. */
  75205. static readonly OnDoublePickTrigger: number;
  75206. /**
  75207. * On pick up
  75208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75209. */
  75210. static readonly OnPickUpTrigger: number;
  75211. /**
  75212. * On pick out.
  75213. * This trigger will only be raised if you also declared a OnPickDown
  75214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75215. */
  75216. static readonly OnPickOutTrigger: number;
  75217. /**
  75218. * On long press
  75219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75220. */
  75221. static readonly OnLongPressTrigger: number;
  75222. /**
  75223. * On pointer over
  75224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75225. */
  75226. static readonly OnPointerOverTrigger: number;
  75227. /**
  75228. * On pointer out
  75229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75230. */
  75231. static readonly OnPointerOutTrigger: number;
  75232. /**
  75233. * On every frame
  75234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75235. */
  75236. static readonly OnEveryFrameTrigger: number;
  75237. /**
  75238. * On intersection enter
  75239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75240. */
  75241. static readonly OnIntersectionEnterTrigger: number;
  75242. /**
  75243. * On intersection exit
  75244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75245. */
  75246. static readonly OnIntersectionExitTrigger: number;
  75247. /**
  75248. * On key down
  75249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75250. */
  75251. static readonly OnKeyDownTrigger: number;
  75252. /**
  75253. * On key up
  75254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75255. */
  75256. static readonly OnKeyUpTrigger: number;
  75257. private _scene;
  75258. /**
  75259. * Creates a new action manager
  75260. * @param scene defines the hosting scene
  75261. */
  75262. constructor(scene: Scene);
  75263. /**
  75264. * Releases all associated resources
  75265. */
  75266. dispose(): void;
  75267. /**
  75268. * Gets hosting scene
  75269. * @returns the hosting scene
  75270. */
  75271. getScene(): Scene;
  75272. /**
  75273. * Does this action manager handles actions of any of the given triggers
  75274. * @param triggers defines the triggers to be tested
  75275. * @return a boolean indicating whether one (or more) of the triggers is handled
  75276. */
  75277. hasSpecificTriggers(triggers: number[]): boolean;
  75278. /**
  75279. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75280. * speed.
  75281. * @param triggerA defines the trigger to be tested
  75282. * @param triggerB defines the trigger to be tested
  75283. * @return a boolean indicating whether one (or more) of the triggers is handled
  75284. */
  75285. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75286. /**
  75287. * Does this action manager handles actions of a given trigger
  75288. * @param trigger defines the trigger to be tested
  75289. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75290. * @return whether the trigger is handled
  75291. */
  75292. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75293. /**
  75294. * Does this action manager has pointer triggers
  75295. */
  75296. readonly hasPointerTriggers: boolean;
  75297. /**
  75298. * Does this action manager has pick triggers
  75299. */
  75300. readonly hasPickTriggers: boolean;
  75301. /**
  75302. * Registers an action to this action manager
  75303. * @param action defines the action to be registered
  75304. * @return the action amended (prepared) after registration
  75305. */
  75306. registerAction(action: IAction): Nullable<IAction>;
  75307. /**
  75308. * Unregisters an action to this action manager
  75309. * @param action defines the action to be unregistered
  75310. * @return a boolean indicating whether the action has been unregistered
  75311. */
  75312. unregisterAction(action: IAction): Boolean;
  75313. /**
  75314. * Process a specific trigger
  75315. * @param trigger defines the trigger to process
  75316. * @param evt defines the event details to be processed
  75317. */
  75318. processTrigger(trigger: number, evt?: IActionEvent): void;
  75319. /** @hidden */
  75320. _getEffectiveTarget(target: any, propertyPath: string): any;
  75321. /** @hidden */
  75322. _getProperty(propertyPath: string): string;
  75323. /**
  75324. * Serialize this manager to a JSON object
  75325. * @param name defines the property name to store this manager
  75326. * @returns a JSON representation of this manager
  75327. */
  75328. serialize(name: string): any;
  75329. /**
  75330. * Creates a new ActionManager from a JSON data
  75331. * @param parsedActions defines the JSON data to read from
  75332. * @param object defines the hosting mesh
  75333. * @param scene defines the hosting scene
  75334. */
  75335. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75336. /**
  75337. * Get a trigger name by index
  75338. * @param trigger defines the trigger index
  75339. * @returns a trigger name
  75340. */
  75341. static GetTriggerName(trigger: number): string;
  75342. }
  75343. }
  75344. declare module BABYLON {
  75345. /**
  75346. * Class representing a ray with position and direction
  75347. */
  75348. export class Ray {
  75349. /** origin point */
  75350. origin: Vector3;
  75351. /** direction */
  75352. direction: Vector3;
  75353. /** length of the ray */
  75354. length: number;
  75355. private static readonly TmpVector3;
  75356. private _tmpRay;
  75357. /**
  75358. * Creates a new ray
  75359. * @param origin origin point
  75360. * @param direction direction
  75361. * @param length length of the ray
  75362. */
  75363. constructor(
  75364. /** origin point */
  75365. origin: Vector3,
  75366. /** direction */
  75367. direction: Vector3,
  75368. /** length of the ray */
  75369. length?: number);
  75370. /**
  75371. * Checks if the ray intersects a box
  75372. * @param minimum bound of the box
  75373. * @param maximum bound of the box
  75374. * @param intersectionTreshold extra extend to be added to the box in all direction
  75375. * @returns if the box was hit
  75376. */
  75377. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75378. /**
  75379. * Checks if the ray intersects a box
  75380. * @param box the bounding box to check
  75381. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75382. * @returns if the box was hit
  75383. */
  75384. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75385. /**
  75386. * If the ray hits a sphere
  75387. * @param sphere the bounding sphere to check
  75388. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75389. * @returns true if it hits the sphere
  75390. */
  75391. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75392. /**
  75393. * If the ray hits a triange
  75394. * @param vertex0 triangle vertex
  75395. * @param vertex1 triangle vertex
  75396. * @param vertex2 triangle vertex
  75397. * @returns intersection information if hit
  75398. */
  75399. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75400. /**
  75401. * Checks if ray intersects a plane
  75402. * @param plane the plane to check
  75403. * @returns the distance away it was hit
  75404. */
  75405. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75406. /**
  75407. * Calculate the intercept of a ray on a given axis
  75408. * @param axis to check 'x' | 'y' | 'z'
  75409. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75410. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75411. */
  75412. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75413. /**
  75414. * Checks if ray intersects a mesh
  75415. * @param mesh the mesh to check
  75416. * @param fastCheck if only the bounding box should checked
  75417. * @returns picking info of the intersecton
  75418. */
  75419. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75420. /**
  75421. * Checks if ray intersects a mesh
  75422. * @param meshes the meshes to check
  75423. * @param fastCheck if only the bounding box should checked
  75424. * @param results array to store result in
  75425. * @returns Array of picking infos
  75426. */
  75427. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75428. private _comparePickingInfo;
  75429. private static smallnum;
  75430. private static rayl;
  75431. /**
  75432. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75433. * @param sega the first point of the segment to test the intersection against
  75434. * @param segb the second point of the segment to test the intersection against
  75435. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75436. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75437. */
  75438. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75439. /**
  75440. * Update the ray from viewport position
  75441. * @param x position
  75442. * @param y y position
  75443. * @param viewportWidth viewport width
  75444. * @param viewportHeight viewport height
  75445. * @param world world matrix
  75446. * @param view view matrix
  75447. * @param projection projection matrix
  75448. * @returns this ray updated
  75449. */
  75450. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75451. /**
  75452. * Creates a ray with origin and direction of 0,0,0
  75453. * @returns the new ray
  75454. */
  75455. static Zero(): Ray;
  75456. /**
  75457. * Creates a new ray from screen space and viewport
  75458. * @param x position
  75459. * @param y y position
  75460. * @param viewportWidth viewport width
  75461. * @param viewportHeight viewport height
  75462. * @param world world matrix
  75463. * @param view view matrix
  75464. * @param projection projection matrix
  75465. * @returns new ray
  75466. */
  75467. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75468. /**
  75469. * 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
  75470. * transformed to the given world matrix.
  75471. * @param origin The origin point
  75472. * @param end The end point
  75473. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75474. * @returns the new ray
  75475. */
  75476. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75477. /**
  75478. * Transforms a ray by a matrix
  75479. * @param ray ray to transform
  75480. * @param matrix matrix to apply
  75481. * @returns the resulting new ray
  75482. */
  75483. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75484. /**
  75485. * Transforms a ray by a matrix
  75486. * @param ray ray to transform
  75487. * @param matrix matrix to apply
  75488. * @param result ray to store result in
  75489. */
  75490. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75491. /**
  75492. * Unproject a ray from screen space to object space
  75493. * @param sourceX defines the screen space x coordinate to use
  75494. * @param sourceY defines the screen space y coordinate to use
  75495. * @param viewportWidth defines the current width of the viewport
  75496. * @param viewportHeight defines the current height of the viewport
  75497. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75498. * @param view defines the view matrix to use
  75499. * @param projection defines the projection matrix to use
  75500. */
  75501. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75502. }
  75503. /**
  75504. * Type used to define predicate used to select faces when a mesh intersection is detected
  75505. */
  75506. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75507. interface Scene {
  75508. /** @hidden */
  75509. _tempPickingRay: Nullable<Ray>;
  75510. /** @hidden */
  75511. _cachedRayForTransform: Ray;
  75512. /** @hidden */
  75513. _pickWithRayInverseMatrix: Matrix;
  75514. /** @hidden */
  75515. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75516. /** @hidden */
  75517. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75518. }
  75519. }
  75520. declare module BABYLON {
  75521. /**
  75522. * Groups all the scene component constants in one place to ease maintenance.
  75523. * @hidden
  75524. */
  75525. export class SceneComponentConstants {
  75526. static readonly NAME_EFFECTLAYER: string;
  75527. static readonly NAME_LAYER: string;
  75528. static readonly NAME_LENSFLARESYSTEM: string;
  75529. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75530. static readonly NAME_PARTICLESYSTEM: string;
  75531. static readonly NAME_GAMEPAD: string;
  75532. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75533. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75534. static readonly NAME_DEPTHRENDERER: string;
  75535. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75536. static readonly NAME_SPRITE: string;
  75537. static readonly NAME_OUTLINERENDERER: string;
  75538. static readonly NAME_PROCEDURALTEXTURE: string;
  75539. static readonly NAME_SHADOWGENERATOR: string;
  75540. static readonly NAME_OCTREE: string;
  75541. static readonly NAME_PHYSICSENGINE: string;
  75542. static readonly NAME_AUDIO: string;
  75543. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75544. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75545. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75546. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75547. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75548. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75549. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75550. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75551. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75552. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75553. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75554. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75555. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75556. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75557. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75558. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75559. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75560. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75561. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75562. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75563. static readonly STEP_AFTERRENDER_AUDIO: number;
  75564. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75565. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75566. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75567. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75568. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75569. static readonly STEP_POINTERMOVE_SPRITE: number;
  75570. static readonly STEP_POINTERDOWN_SPRITE: number;
  75571. static readonly STEP_POINTERUP_SPRITE: number;
  75572. }
  75573. /**
  75574. * This represents a scene component.
  75575. *
  75576. * This is used to decouple the dependency the scene is having on the different workloads like
  75577. * layers, post processes...
  75578. */
  75579. export interface ISceneComponent {
  75580. /**
  75581. * The name of the component. Each component must have a unique name.
  75582. */
  75583. name: string;
  75584. /**
  75585. * The scene the component belongs to.
  75586. */
  75587. scene: Scene;
  75588. /**
  75589. * Register the component to one instance of a scene.
  75590. */
  75591. register(): void;
  75592. /**
  75593. * Rebuilds the elements related to this component in case of
  75594. * context lost for instance.
  75595. */
  75596. rebuild(): void;
  75597. /**
  75598. * Disposes the component and the associated ressources.
  75599. */
  75600. dispose(): void;
  75601. }
  75602. /**
  75603. * This represents a SERIALIZABLE scene component.
  75604. *
  75605. * This extends Scene Component to add Serialization methods on top.
  75606. */
  75607. export interface ISceneSerializableComponent extends ISceneComponent {
  75608. /**
  75609. * Adds all the elements from the container to the scene
  75610. * @param container the container holding the elements
  75611. */
  75612. addFromContainer(container: AbstractScene): void;
  75613. /**
  75614. * Removes all the elements in the container from the scene
  75615. * @param container contains the elements to remove
  75616. * @param dispose if the removed element should be disposed (default: false)
  75617. */
  75618. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75619. /**
  75620. * Serializes the component data to the specified json object
  75621. * @param serializationObject The object to serialize to
  75622. */
  75623. serialize(serializationObject: any): void;
  75624. }
  75625. /**
  75626. * Strong typing of a Mesh related stage step action
  75627. */
  75628. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75629. /**
  75630. * Strong typing of a Evaluate Sub Mesh related stage step action
  75631. */
  75632. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75633. /**
  75634. * Strong typing of a Active Mesh related stage step action
  75635. */
  75636. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75637. /**
  75638. * Strong typing of a Camera related stage step action
  75639. */
  75640. export type CameraStageAction = (camera: Camera) => void;
  75641. /**
  75642. * Strong typing of a Camera Frame buffer related stage step action
  75643. */
  75644. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75645. /**
  75646. * Strong typing of a Render Target related stage step action
  75647. */
  75648. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75649. /**
  75650. * Strong typing of a RenderingGroup related stage step action
  75651. */
  75652. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75653. /**
  75654. * Strong typing of a Mesh Render related stage step action
  75655. */
  75656. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75657. /**
  75658. * Strong typing of a simple stage step action
  75659. */
  75660. export type SimpleStageAction = () => void;
  75661. /**
  75662. * Strong typing of a render target action.
  75663. */
  75664. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75665. /**
  75666. * Strong typing of a pointer move action.
  75667. */
  75668. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75669. /**
  75670. * Strong typing of a pointer up/down action.
  75671. */
  75672. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75673. /**
  75674. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75675. * @hidden
  75676. */
  75677. export class Stage<T extends Function> extends Array<{
  75678. index: number;
  75679. component: ISceneComponent;
  75680. action: T;
  75681. }> {
  75682. /**
  75683. * Hide ctor from the rest of the world.
  75684. * @param items The items to add.
  75685. */
  75686. private constructor();
  75687. /**
  75688. * Creates a new Stage.
  75689. * @returns A new instance of a Stage
  75690. */
  75691. static Create<T extends Function>(): Stage<T>;
  75692. /**
  75693. * Registers a step in an ordered way in the targeted stage.
  75694. * @param index Defines the position to register the step in
  75695. * @param component Defines the component attached to the step
  75696. * @param action Defines the action to launch during the step
  75697. */
  75698. registerStep(index: number, component: ISceneComponent, action: T): void;
  75699. /**
  75700. * Clears all the steps from the stage.
  75701. */
  75702. clear(): void;
  75703. }
  75704. }
  75705. declare module BABYLON {
  75706. interface Scene {
  75707. /** @hidden */
  75708. _pointerOverSprite: Nullable<Sprite>;
  75709. /** @hidden */
  75710. _pickedDownSprite: Nullable<Sprite>;
  75711. /** @hidden */
  75712. _tempSpritePickingRay: Nullable<Ray>;
  75713. /**
  75714. * All of the sprite managers added to this scene
  75715. * @see http://doc.babylonjs.com/babylon101/sprites
  75716. */
  75717. spriteManagers: Array<ISpriteManager>;
  75718. /**
  75719. * An event triggered when sprites rendering is about to start
  75720. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75721. */
  75722. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75723. /**
  75724. * An event triggered when sprites rendering is done
  75725. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75726. */
  75727. onAfterSpritesRenderingObservable: Observable<Scene>;
  75728. /** @hidden */
  75729. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75730. /** Launch a ray to try to pick a sprite in the scene
  75731. * @param x position on screen
  75732. * @param y position on screen
  75733. * @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
  75734. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75735. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75736. * @returns a PickingInfo
  75737. */
  75738. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75739. /** Use the given ray to pick a sprite in the scene
  75740. * @param ray The ray (in world space) to use to pick meshes
  75741. * @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
  75742. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75743. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75744. * @returns a PickingInfo
  75745. */
  75746. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75747. /**
  75748. * Force the sprite under the pointer
  75749. * @param sprite defines the sprite to use
  75750. */
  75751. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75752. /**
  75753. * Gets the sprite under the pointer
  75754. * @returns a Sprite or null if no sprite is under the pointer
  75755. */
  75756. getPointerOverSprite(): Nullable<Sprite>;
  75757. }
  75758. /**
  75759. * Defines the sprite scene component responsible to manage sprites
  75760. * in a given scene.
  75761. */
  75762. export class SpriteSceneComponent implements ISceneComponent {
  75763. /**
  75764. * The component name helpfull to identify the component in the list of scene components.
  75765. */
  75766. readonly name: string;
  75767. /**
  75768. * The scene the component belongs to.
  75769. */
  75770. scene: Scene;
  75771. /** @hidden */
  75772. private _spritePredicate;
  75773. /**
  75774. * Creates a new instance of the component for the given scene
  75775. * @param scene Defines the scene to register the component in
  75776. */
  75777. constructor(scene: Scene);
  75778. /**
  75779. * Registers the component in a given scene
  75780. */
  75781. register(): void;
  75782. /**
  75783. * Rebuilds the elements related to this component in case of
  75784. * context lost for instance.
  75785. */
  75786. rebuild(): void;
  75787. /**
  75788. * Disposes the component and the associated ressources.
  75789. */
  75790. dispose(): void;
  75791. private _pickSpriteButKeepRay;
  75792. private _pointerMove;
  75793. private _pointerDown;
  75794. private _pointerUp;
  75795. }
  75796. }
  75797. declare module BABYLON {
  75798. /** @hidden */
  75799. export var fogFragmentDeclaration: {
  75800. name: string;
  75801. shader: string;
  75802. };
  75803. }
  75804. declare module BABYLON {
  75805. /** @hidden */
  75806. export var fogFragment: {
  75807. name: string;
  75808. shader: string;
  75809. };
  75810. }
  75811. declare module BABYLON {
  75812. /** @hidden */
  75813. export var spritesPixelShader: {
  75814. name: string;
  75815. shader: string;
  75816. };
  75817. }
  75818. declare module BABYLON {
  75819. /** @hidden */
  75820. export var fogVertexDeclaration: {
  75821. name: string;
  75822. shader: string;
  75823. };
  75824. }
  75825. declare module BABYLON {
  75826. /** @hidden */
  75827. export var spritesVertexShader: {
  75828. name: string;
  75829. shader: string;
  75830. };
  75831. }
  75832. declare module BABYLON {
  75833. /**
  75834. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75835. */
  75836. export interface ISpriteManager extends IDisposable {
  75837. /**
  75838. * Restricts the camera to viewing objects with the same layerMask.
  75839. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75840. */
  75841. layerMask: number;
  75842. /**
  75843. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75844. */
  75845. isPickable: boolean;
  75846. /**
  75847. * Specifies the rendering group id for this mesh (0 by default)
  75848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75849. */
  75850. renderingGroupId: number;
  75851. /**
  75852. * Defines the list of sprites managed by the manager.
  75853. */
  75854. sprites: Array<Sprite>;
  75855. /**
  75856. * Tests the intersection of a sprite with a specific ray.
  75857. * @param ray The ray we are sending to test the collision
  75858. * @param camera The camera space we are sending rays in
  75859. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75860. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75861. * @returns picking info or null.
  75862. */
  75863. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75864. /**
  75865. * Renders the list of sprites on screen.
  75866. */
  75867. render(): void;
  75868. }
  75869. /**
  75870. * Class used to manage multiple sprites on the same spritesheet
  75871. * @see http://doc.babylonjs.com/babylon101/sprites
  75872. */
  75873. export class SpriteManager implements ISpriteManager {
  75874. /** defines the manager's name */
  75875. name: string;
  75876. /** Gets the list of sprites */
  75877. sprites: Sprite[];
  75878. /** Gets or sets the rendering group id (0 by default) */
  75879. renderingGroupId: number;
  75880. /** Gets or sets camera layer mask */
  75881. layerMask: number;
  75882. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75883. fogEnabled: boolean;
  75884. /** Gets or sets a boolean indicating if the sprites are pickable */
  75885. isPickable: boolean;
  75886. /** Defines the default width of a cell in the spritesheet */
  75887. cellWidth: number;
  75888. /** Defines the default height of a cell in the spritesheet */
  75889. cellHeight: number;
  75890. /** Associative array from JSON sprite data file */
  75891. private _cellData;
  75892. /** Array of sprite names from JSON sprite data file */
  75893. private _spriteMap;
  75894. /** True when packed cell data from JSON file is ready*/
  75895. private _packedAndReady;
  75896. /**
  75897. * An event triggered when the manager is disposed.
  75898. */
  75899. onDisposeObservable: Observable<SpriteManager>;
  75900. private _onDisposeObserver;
  75901. /**
  75902. * Callback called when the manager is disposed
  75903. */
  75904. onDispose: () => void;
  75905. private _capacity;
  75906. private _fromPacked;
  75907. private _spriteTexture;
  75908. private _epsilon;
  75909. private _scene;
  75910. private _vertexData;
  75911. private _buffer;
  75912. private _vertexBuffers;
  75913. private _indexBuffer;
  75914. private _effectBase;
  75915. private _effectFog;
  75916. /**
  75917. * Gets or sets the spritesheet texture
  75918. */
  75919. texture: Texture;
  75920. /**
  75921. * Creates a new sprite manager
  75922. * @param name defines the manager's name
  75923. * @param imgUrl defines the sprite sheet url
  75924. * @param capacity defines the maximum allowed number of sprites
  75925. * @param cellSize defines the size of a sprite cell
  75926. * @param scene defines the hosting scene
  75927. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75928. * @param samplingMode defines the smapling mode to use with spritesheet
  75929. * @param fromPacked set to false; do not alter
  75930. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  75931. */
  75932. constructor(
  75933. /** defines the manager's name */
  75934. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  75935. private _makePacked;
  75936. private _appendSpriteVertex;
  75937. /**
  75938. * Intersects the sprites with a ray
  75939. * @param ray defines the ray to intersect with
  75940. * @param camera defines the current active camera
  75941. * @param predicate defines a predicate used to select candidate sprites
  75942. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75943. * @returns null if no hit or a PickingInfo
  75944. */
  75945. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75946. /**
  75947. * Render all child sprites
  75948. */
  75949. render(): void;
  75950. /**
  75951. * Release associated resources
  75952. */
  75953. dispose(): void;
  75954. }
  75955. }
  75956. declare module BABYLON {
  75957. /**
  75958. * Class used to represent a sprite
  75959. * @see http://doc.babylonjs.com/babylon101/sprites
  75960. */
  75961. export class Sprite {
  75962. /** defines the name */
  75963. name: string;
  75964. /** Gets or sets the current world position */
  75965. position: Vector3;
  75966. /** Gets or sets the main color */
  75967. color: Color4;
  75968. /** Gets or sets the width */
  75969. width: number;
  75970. /** Gets or sets the height */
  75971. height: number;
  75972. /** Gets or sets rotation angle */
  75973. angle: number;
  75974. /** Gets or sets the cell index in the sprite sheet */
  75975. cellIndex: number;
  75976. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  75977. cellRef: string;
  75978. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75979. invertU: number;
  75980. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75981. invertV: number;
  75982. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75983. disposeWhenFinishedAnimating: boolean;
  75984. /** Gets the list of attached animations */
  75985. animations: Animation[];
  75986. /** Gets or sets a boolean indicating if the sprite can be picked */
  75987. isPickable: boolean;
  75988. /**
  75989. * Gets or sets the associated action manager
  75990. */
  75991. actionManager: Nullable<ActionManager>;
  75992. private _animationStarted;
  75993. private _loopAnimation;
  75994. private _fromIndex;
  75995. private _toIndex;
  75996. private _delay;
  75997. private _direction;
  75998. private _manager;
  75999. private _time;
  76000. private _onAnimationEnd;
  76001. /**
  76002. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76003. */
  76004. isVisible: boolean;
  76005. /**
  76006. * Gets or sets the sprite size
  76007. */
  76008. size: number;
  76009. /**
  76010. * Creates a new Sprite
  76011. * @param name defines the name
  76012. * @param manager defines the manager
  76013. */
  76014. constructor(
  76015. /** defines the name */
  76016. name: string, manager: ISpriteManager);
  76017. /**
  76018. * Starts an animation
  76019. * @param from defines the initial key
  76020. * @param to defines the end key
  76021. * @param loop defines if the animation must loop
  76022. * @param delay defines the start delay (in ms)
  76023. * @param onAnimationEnd defines a callback to call when animation ends
  76024. */
  76025. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76026. /** Stops current animation (if any) */
  76027. stopAnimation(): void;
  76028. /** @hidden */
  76029. _animate(deltaTime: number): void;
  76030. /** Release associated resources */
  76031. dispose(): void;
  76032. }
  76033. }
  76034. declare module BABYLON {
  76035. /**
  76036. * Information about the result of picking within a scene
  76037. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76038. */
  76039. export class PickingInfo {
  76040. /** @hidden */
  76041. _pickingUnavailable: boolean;
  76042. /**
  76043. * If the pick collided with an object
  76044. */
  76045. hit: boolean;
  76046. /**
  76047. * Distance away where the pick collided
  76048. */
  76049. distance: number;
  76050. /**
  76051. * The location of pick collision
  76052. */
  76053. pickedPoint: Nullable<Vector3>;
  76054. /**
  76055. * The mesh corresponding the the pick collision
  76056. */
  76057. pickedMesh: Nullable<AbstractMesh>;
  76058. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76059. bu: number;
  76060. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76061. bv: number;
  76062. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76063. faceId: number;
  76064. /** Id of the the submesh that was picked */
  76065. subMeshId: number;
  76066. /** If a sprite was picked, this will be the sprite the pick collided with */
  76067. pickedSprite: Nullable<Sprite>;
  76068. /**
  76069. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76070. */
  76071. originMesh: Nullable<AbstractMesh>;
  76072. /**
  76073. * The ray that was used to perform the picking.
  76074. */
  76075. ray: Nullable<Ray>;
  76076. /**
  76077. * Gets the normal correspodning to the face the pick collided with
  76078. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76079. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76080. * @returns The normal correspodning to the face the pick collided with
  76081. */
  76082. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76083. /**
  76084. * Gets the texture coordinates of where the pick occured
  76085. * @returns the vector containing the coordnates of the texture
  76086. */
  76087. getTextureCoordinates(): Nullable<Vector2>;
  76088. }
  76089. }
  76090. declare module BABYLON {
  76091. /**
  76092. * Gather the list of pointer event types as constants.
  76093. */
  76094. export class PointerEventTypes {
  76095. /**
  76096. * 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.
  76097. */
  76098. static readonly POINTERDOWN: number;
  76099. /**
  76100. * The pointerup event is fired when a pointer is no longer active.
  76101. */
  76102. static readonly POINTERUP: number;
  76103. /**
  76104. * The pointermove event is fired when a pointer changes coordinates.
  76105. */
  76106. static readonly POINTERMOVE: number;
  76107. /**
  76108. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76109. */
  76110. static readonly POINTERWHEEL: number;
  76111. /**
  76112. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76113. */
  76114. static readonly POINTERPICK: number;
  76115. /**
  76116. * The pointertap event is fired when a the object has been touched and released without drag.
  76117. */
  76118. static readonly POINTERTAP: number;
  76119. /**
  76120. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76121. */
  76122. static readonly POINTERDOUBLETAP: number;
  76123. }
  76124. /**
  76125. * Base class of pointer info types.
  76126. */
  76127. export class PointerInfoBase {
  76128. /**
  76129. * Defines the type of event (PointerEventTypes)
  76130. */
  76131. type: number;
  76132. /**
  76133. * Defines the related dom event
  76134. */
  76135. event: PointerEvent | MouseWheelEvent;
  76136. /**
  76137. * Instantiates the base class of pointers info.
  76138. * @param type Defines the type of event (PointerEventTypes)
  76139. * @param event Defines the related dom event
  76140. */
  76141. constructor(
  76142. /**
  76143. * Defines the type of event (PointerEventTypes)
  76144. */
  76145. type: number,
  76146. /**
  76147. * Defines the related dom event
  76148. */
  76149. event: PointerEvent | MouseWheelEvent);
  76150. }
  76151. /**
  76152. * This class is used to store pointer related info for the onPrePointerObservable event.
  76153. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76154. */
  76155. export class PointerInfoPre extends PointerInfoBase {
  76156. /**
  76157. * Ray from a pointer if availible (eg. 6dof controller)
  76158. */
  76159. ray: Nullable<Ray>;
  76160. /**
  76161. * Defines the local position of the pointer on the canvas.
  76162. */
  76163. localPosition: Vector2;
  76164. /**
  76165. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76166. */
  76167. skipOnPointerObservable: boolean;
  76168. /**
  76169. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76170. * @param type Defines the type of event (PointerEventTypes)
  76171. * @param event Defines the related dom event
  76172. * @param localX Defines the local x coordinates of the pointer when the event occured
  76173. * @param localY Defines the local y coordinates of the pointer when the event occured
  76174. */
  76175. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76176. }
  76177. /**
  76178. * This type contains all the data related to a pointer event in Babylon.js.
  76179. * 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.
  76180. */
  76181. export class PointerInfo extends PointerInfoBase {
  76182. /**
  76183. * Defines the picking info associated to the info (if any)\
  76184. */
  76185. pickInfo: Nullable<PickingInfo>;
  76186. /**
  76187. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76188. * @param type Defines the type of event (PointerEventTypes)
  76189. * @param event Defines the related dom event
  76190. * @param pickInfo Defines the picking info associated to the info (if any)\
  76191. */
  76192. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76193. /**
  76194. * Defines the picking info associated to the info (if any)\
  76195. */
  76196. pickInfo: Nullable<PickingInfo>);
  76197. }
  76198. /**
  76199. * Data relating to a touch event on the screen.
  76200. */
  76201. export interface PointerTouch {
  76202. /**
  76203. * X coordinate of touch.
  76204. */
  76205. x: number;
  76206. /**
  76207. * Y coordinate of touch.
  76208. */
  76209. y: number;
  76210. /**
  76211. * Id of touch. Unique for each finger.
  76212. */
  76213. pointerId: number;
  76214. /**
  76215. * Event type passed from DOM.
  76216. */
  76217. type: any;
  76218. }
  76219. }
  76220. declare module BABYLON {
  76221. /**
  76222. * Manage the mouse inputs to control the movement of a free camera.
  76223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76224. */
  76225. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76226. /**
  76227. * Define if touch is enabled in the mouse input
  76228. */
  76229. touchEnabled: boolean;
  76230. /**
  76231. * Defines the camera the input is attached to.
  76232. */
  76233. camera: FreeCamera;
  76234. /**
  76235. * Defines the buttons associated with the input to handle camera move.
  76236. */
  76237. buttons: number[];
  76238. /**
  76239. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76240. */
  76241. angularSensibility: number;
  76242. private _pointerInput;
  76243. private _onMouseMove;
  76244. private _observer;
  76245. private previousPosition;
  76246. /**
  76247. * Observable for when a pointer move event occurs containing the move offset
  76248. */
  76249. onPointerMovedObservable: Observable<{
  76250. offsetX: number;
  76251. offsetY: number;
  76252. }>;
  76253. /**
  76254. * @hidden
  76255. * If the camera should be rotated automatically based on pointer movement
  76256. */
  76257. _allowCameraRotation: boolean;
  76258. /**
  76259. * Manage the mouse inputs to control the movement of a free camera.
  76260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76261. * @param touchEnabled Defines if touch is enabled or not
  76262. */
  76263. constructor(
  76264. /**
  76265. * Define if touch is enabled in the mouse input
  76266. */
  76267. touchEnabled?: boolean);
  76268. /**
  76269. * Attach the input controls to a specific dom element to get the input from.
  76270. * @param element Defines the element the controls should be listened from
  76271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76272. */
  76273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76274. /**
  76275. * Called on JS contextmenu event.
  76276. * Override this method to provide functionality.
  76277. */
  76278. protected onContextMenu(evt: PointerEvent): void;
  76279. /**
  76280. * Detach the current controls from the specified dom element.
  76281. * @param element Defines the element to stop listening the inputs from
  76282. */
  76283. detachControl(element: Nullable<HTMLElement>): void;
  76284. /**
  76285. * Gets the class name of the current intput.
  76286. * @returns the class name
  76287. */
  76288. getClassName(): string;
  76289. /**
  76290. * Get the friendly name associated with the input class.
  76291. * @returns the input friendly name
  76292. */
  76293. getSimpleName(): string;
  76294. }
  76295. }
  76296. declare module BABYLON {
  76297. /**
  76298. * Manage the touch inputs to control the movement of a free camera.
  76299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76300. */
  76301. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76302. /**
  76303. * Defines the camera the input is attached to.
  76304. */
  76305. camera: FreeCamera;
  76306. /**
  76307. * Defines the touch sensibility for rotation.
  76308. * The higher the faster.
  76309. */
  76310. touchAngularSensibility: number;
  76311. /**
  76312. * Defines the touch sensibility for move.
  76313. * The higher the faster.
  76314. */
  76315. touchMoveSensibility: number;
  76316. private _offsetX;
  76317. private _offsetY;
  76318. private _pointerPressed;
  76319. private _pointerInput;
  76320. private _observer;
  76321. private _onLostFocus;
  76322. /**
  76323. * Attach the input controls to a specific dom element to get the input from.
  76324. * @param element Defines the element the controls should be listened from
  76325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76326. */
  76327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76328. /**
  76329. * Detach the current controls from the specified dom element.
  76330. * @param element Defines the element to stop listening the inputs from
  76331. */
  76332. detachControl(element: Nullable<HTMLElement>): void;
  76333. /**
  76334. * Update the current camera state depending on the inputs that have been used this frame.
  76335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76336. */
  76337. checkInputs(): void;
  76338. /**
  76339. * Gets the class name of the current intput.
  76340. * @returns the class name
  76341. */
  76342. getClassName(): string;
  76343. /**
  76344. * Get the friendly name associated with the input class.
  76345. * @returns the input friendly name
  76346. */
  76347. getSimpleName(): string;
  76348. }
  76349. }
  76350. declare module BABYLON {
  76351. /**
  76352. * Default Inputs manager for the FreeCamera.
  76353. * It groups all the default supported inputs for ease of use.
  76354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76355. */
  76356. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76357. /**
  76358. * @hidden
  76359. */
  76360. _mouseInput: Nullable<FreeCameraMouseInput>;
  76361. /**
  76362. * Instantiates a new FreeCameraInputsManager.
  76363. * @param camera Defines the camera the inputs belong to
  76364. */
  76365. constructor(camera: FreeCamera);
  76366. /**
  76367. * Add keyboard input support to the input manager.
  76368. * @returns the current input manager
  76369. */
  76370. addKeyboard(): FreeCameraInputsManager;
  76371. /**
  76372. * Add mouse input support to the input manager.
  76373. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76374. * @returns the current input manager
  76375. */
  76376. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76377. /**
  76378. * Removes the mouse input support from the manager
  76379. * @returns the current input manager
  76380. */
  76381. removeMouse(): FreeCameraInputsManager;
  76382. /**
  76383. * Add touch input support to the input manager.
  76384. * @returns the current input manager
  76385. */
  76386. addTouch(): FreeCameraInputsManager;
  76387. /**
  76388. * Remove all attached input methods from a camera
  76389. */
  76390. clear(): void;
  76391. }
  76392. }
  76393. declare module BABYLON {
  76394. /**
  76395. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76396. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76398. */
  76399. export class FreeCamera extends TargetCamera {
  76400. /**
  76401. * Define the collision ellipsoid of the camera.
  76402. * This is helpful to simulate a camera body like the player body around the camera
  76403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76404. */
  76405. ellipsoid: Vector3;
  76406. /**
  76407. * Define an offset for the position of the ellipsoid around the camera.
  76408. * This can be helpful to determine the center of the body near the gravity center of the body
  76409. * instead of its head.
  76410. */
  76411. ellipsoidOffset: Vector3;
  76412. /**
  76413. * Enable or disable collisions of the camera with the rest of the scene objects.
  76414. */
  76415. checkCollisions: boolean;
  76416. /**
  76417. * Enable or disable gravity on the camera.
  76418. */
  76419. applyGravity: boolean;
  76420. /**
  76421. * Define the input manager associated to the camera.
  76422. */
  76423. inputs: FreeCameraInputsManager;
  76424. /**
  76425. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76426. * Higher values reduce sensitivity.
  76427. */
  76428. /**
  76429. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76430. * Higher values reduce sensitivity.
  76431. */
  76432. angularSensibility: number;
  76433. /**
  76434. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76435. */
  76436. keysUp: number[];
  76437. /**
  76438. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76439. */
  76440. keysDown: number[];
  76441. /**
  76442. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76443. */
  76444. keysLeft: number[];
  76445. /**
  76446. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76447. */
  76448. keysRight: number[];
  76449. /**
  76450. * Event raised when the camera collide with a mesh in the scene.
  76451. */
  76452. onCollide: (collidedMesh: AbstractMesh) => void;
  76453. private _collider;
  76454. private _needMoveForGravity;
  76455. private _oldPosition;
  76456. private _diffPosition;
  76457. private _newPosition;
  76458. /** @hidden */
  76459. _localDirection: Vector3;
  76460. /** @hidden */
  76461. _transformedDirection: Vector3;
  76462. /**
  76463. * Instantiates a Free Camera.
  76464. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76465. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76467. * @param name Define the name of the camera in the scene
  76468. * @param position Define the start position of the camera in the scene
  76469. * @param scene Define the scene the camera belongs to
  76470. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76471. */
  76472. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76473. /**
  76474. * Attached controls to the current camera.
  76475. * @param element Defines the element the controls should be listened from
  76476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76477. */
  76478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76479. /**
  76480. * Detach the current controls from the camera.
  76481. * The camera will stop reacting to inputs.
  76482. * @param element Defines the element to stop listening the inputs from
  76483. */
  76484. detachControl(element: HTMLElement): void;
  76485. private _collisionMask;
  76486. /**
  76487. * Define a collision mask to limit the list of object the camera can collide with
  76488. */
  76489. collisionMask: number;
  76490. /** @hidden */
  76491. _collideWithWorld(displacement: Vector3): void;
  76492. private _onCollisionPositionChange;
  76493. /** @hidden */
  76494. _checkInputs(): void;
  76495. /** @hidden */
  76496. _decideIfNeedsToMove(): boolean;
  76497. /** @hidden */
  76498. _updatePosition(): void;
  76499. /**
  76500. * Destroy the camera and release the current resources hold by it.
  76501. */
  76502. dispose(): void;
  76503. /**
  76504. * Gets the current object class name.
  76505. * @return the class name
  76506. */
  76507. getClassName(): string;
  76508. }
  76509. }
  76510. declare module BABYLON {
  76511. /**
  76512. * Represents a gamepad control stick position
  76513. */
  76514. export class StickValues {
  76515. /**
  76516. * The x component of the control stick
  76517. */
  76518. x: number;
  76519. /**
  76520. * The y component of the control stick
  76521. */
  76522. y: number;
  76523. /**
  76524. * Initializes the gamepad x and y control stick values
  76525. * @param x The x component of the gamepad control stick value
  76526. * @param y The y component of the gamepad control stick value
  76527. */
  76528. constructor(
  76529. /**
  76530. * The x component of the control stick
  76531. */
  76532. x: number,
  76533. /**
  76534. * The y component of the control stick
  76535. */
  76536. y: number);
  76537. }
  76538. /**
  76539. * An interface which manages callbacks for gamepad button changes
  76540. */
  76541. export interface GamepadButtonChanges {
  76542. /**
  76543. * Called when a gamepad has been changed
  76544. */
  76545. changed: boolean;
  76546. /**
  76547. * Called when a gamepad press event has been triggered
  76548. */
  76549. pressChanged: boolean;
  76550. /**
  76551. * Called when a touch event has been triggered
  76552. */
  76553. touchChanged: boolean;
  76554. /**
  76555. * Called when a value has changed
  76556. */
  76557. valueChanged: boolean;
  76558. }
  76559. /**
  76560. * Represents a gamepad
  76561. */
  76562. export class Gamepad {
  76563. /**
  76564. * The id of the gamepad
  76565. */
  76566. id: string;
  76567. /**
  76568. * The index of the gamepad
  76569. */
  76570. index: number;
  76571. /**
  76572. * The browser gamepad
  76573. */
  76574. browserGamepad: any;
  76575. /**
  76576. * Specifies what type of gamepad this represents
  76577. */
  76578. type: number;
  76579. private _leftStick;
  76580. private _rightStick;
  76581. /** @hidden */
  76582. _isConnected: boolean;
  76583. private _leftStickAxisX;
  76584. private _leftStickAxisY;
  76585. private _rightStickAxisX;
  76586. private _rightStickAxisY;
  76587. /**
  76588. * Triggered when the left control stick has been changed
  76589. */
  76590. private _onleftstickchanged;
  76591. /**
  76592. * Triggered when the right control stick has been changed
  76593. */
  76594. private _onrightstickchanged;
  76595. /**
  76596. * Represents a gamepad controller
  76597. */
  76598. static GAMEPAD: number;
  76599. /**
  76600. * Represents a generic controller
  76601. */
  76602. static GENERIC: number;
  76603. /**
  76604. * Represents an XBox controller
  76605. */
  76606. static XBOX: number;
  76607. /**
  76608. * Represents a pose-enabled controller
  76609. */
  76610. static POSE_ENABLED: number;
  76611. /**
  76612. * Represents an Dual Shock controller
  76613. */
  76614. static DUALSHOCK: number;
  76615. /**
  76616. * Specifies whether the left control stick should be Y-inverted
  76617. */
  76618. protected _invertLeftStickY: boolean;
  76619. /**
  76620. * Specifies if the gamepad has been connected
  76621. */
  76622. readonly isConnected: boolean;
  76623. /**
  76624. * Initializes the gamepad
  76625. * @param id The id of the gamepad
  76626. * @param index The index of the gamepad
  76627. * @param browserGamepad The browser gamepad
  76628. * @param leftStickX The x component of the left joystick
  76629. * @param leftStickY The y component of the left joystick
  76630. * @param rightStickX The x component of the right joystick
  76631. * @param rightStickY The y component of the right joystick
  76632. */
  76633. constructor(
  76634. /**
  76635. * The id of the gamepad
  76636. */
  76637. id: string,
  76638. /**
  76639. * The index of the gamepad
  76640. */
  76641. index: number,
  76642. /**
  76643. * The browser gamepad
  76644. */
  76645. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76646. /**
  76647. * Callback triggered when the left joystick has changed
  76648. * @param callback
  76649. */
  76650. onleftstickchanged(callback: (values: StickValues) => void): void;
  76651. /**
  76652. * Callback triggered when the right joystick has changed
  76653. * @param callback
  76654. */
  76655. onrightstickchanged(callback: (values: StickValues) => void): void;
  76656. /**
  76657. * Gets the left joystick
  76658. */
  76659. /**
  76660. * Sets the left joystick values
  76661. */
  76662. leftStick: StickValues;
  76663. /**
  76664. * Gets the right joystick
  76665. */
  76666. /**
  76667. * Sets the right joystick value
  76668. */
  76669. rightStick: StickValues;
  76670. /**
  76671. * Updates the gamepad joystick positions
  76672. */
  76673. update(): void;
  76674. /**
  76675. * Disposes the gamepad
  76676. */
  76677. dispose(): void;
  76678. }
  76679. /**
  76680. * Represents a generic gamepad
  76681. */
  76682. export class GenericPad extends Gamepad {
  76683. private _buttons;
  76684. private _onbuttondown;
  76685. private _onbuttonup;
  76686. /**
  76687. * Observable triggered when a button has been pressed
  76688. */
  76689. onButtonDownObservable: Observable<number>;
  76690. /**
  76691. * Observable triggered when a button has been released
  76692. */
  76693. onButtonUpObservable: Observable<number>;
  76694. /**
  76695. * Callback triggered when a button has been pressed
  76696. * @param callback Called when a button has been pressed
  76697. */
  76698. onbuttondown(callback: (buttonPressed: number) => void): void;
  76699. /**
  76700. * Callback triggered when a button has been released
  76701. * @param callback Called when a button has been released
  76702. */
  76703. onbuttonup(callback: (buttonReleased: number) => void): void;
  76704. /**
  76705. * Initializes the generic gamepad
  76706. * @param id The id of the generic gamepad
  76707. * @param index The index of the generic gamepad
  76708. * @param browserGamepad The browser gamepad
  76709. */
  76710. constructor(id: string, index: number, browserGamepad: any);
  76711. private _setButtonValue;
  76712. /**
  76713. * Updates the generic gamepad
  76714. */
  76715. update(): void;
  76716. /**
  76717. * Disposes the generic gamepad
  76718. */
  76719. dispose(): void;
  76720. }
  76721. }
  76722. declare module BABYLON {
  76723. interface Engine {
  76724. /**
  76725. * Creates a raw texture
  76726. * @param data defines the data to store in the texture
  76727. * @param width defines the width of the texture
  76728. * @param height defines the height of the texture
  76729. * @param format defines the format of the data
  76730. * @param generateMipMaps defines if the engine should generate the mip levels
  76731. * @param invertY defines if data must be stored with Y axis inverted
  76732. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76733. * @param compression defines the compression used (null by default)
  76734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76735. * @returns the raw texture inside an InternalTexture
  76736. */
  76737. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76738. /**
  76739. * Update a raw texture
  76740. * @param texture defines the texture to update
  76741. * @param data defines the data to store in the texture
  76742. * @param format defines the format of the data
  76743. * @param invertY defines if data must be stored with Y axis inverted
  76744. */
  76745. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76746. /**
  76747. * Update a raw texture
  76748. * @param texture defines the texture to update
  76749. * @param data defines the data to store in the texture
  76750. * @param format defines the format of the data
  76751. * @param invertY defines if data must be stored with Y axis inverted
  76752. * @param compression defines the compression used (null by default)
  76753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76754. */
  76755. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76756. /**
  76757. * Creates a new raw cube texture
  76758. * @param data defines the array of data to use to create each face
  76759. * @param size defines the size of the textures
  76760. * @param format defines the format of the data
  76761. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76762. * @param generateMipMaps defines if the engine should generate the mip levels
  76763. * @param invertY defines if data must be stored with Y axis inverted
  76764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76765. * @param compression defines the compression used (null by default)
  76766. * @returns the cube texture as an InternalTexture
  76767. */
  76768. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76769. /**
  76770. * Update a raw cube texture
  76771. * @param texture defines the texture to udpdate
  76772. * @param data defines the data to store
  76773. * @param format defines the data format
  76774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76775. * @param invertY defines if data must be stored with Y axis inverted
  76776. */
  76777. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76778. /**
  76779. * Update a raw cube texture
  76780. * @param texture defines the texture to udpdate
  76781. * @param data defines the data to store
  76782. * @param format defines the data format
  76783. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76784. * @param invertY defines if data must be stored with Y axis inverted
  76785. * @param compression defines the compression used (null by default)
  76786. */
  76787. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76788. /**
  76789. * Update a raw cube texture
  76790. * @param texture defines the texture to udpdate
  76791. * @param data defines the data to store
  76792. * @param format defines the data format
  76793. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76794. * @param invertY defines if data must be stored with Y axis inverted
  76795. * @param compression defines the compression used (null by default)
  76796. * @param level defines which level of the texture to update
  76797. */
  76798. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76799. /**
  76800. * Creates a new raw cube texture from a specified url
  76801. * @param url defines the url where the data is located
  76802. * @param scene defines the current scene
  76803. * @param size defines the size of the textures
  76804. * @param format defines the format of the data
  76805. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76806. * @param noMipmap defines if the engine should avoid generating the mip levels
  76807. * @param callback defines a callback used to extract texture data from loaded data
  76808. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76809. * @param onLoad defines a callback called when texture is loaded
  76810. * @param onError defines a callback called if there is an error
  76811. * @returns the cube texture as an InternalTexture
  76812. */
  76813. 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;
  76814. /**
  76815. * Creates a new raw cube texture from a specified url
  76816. * @param url defines the url where the data is located
  76817. * @param scene defines the current scene
  76818. * @param size defines the size of the textures
  76819. * @param format defines the format of the data
  76820. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76821. * @param noMipmap defines if the engine should avoid generating the mip levels
  76822. * @param callback defines a callback used to extract texture data from loaded data
  76823. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76824. * @param onLoad defines a callback called when texture is loaded
  76825. * @param onError defines a callback called if there is an error
  76826. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76827. * @param invertY defines if data must be stored with Y axis inverted
  76828. * @returns the cube texture as an InternalTexture
  76829. */
  76830. 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;
  76831. /**
  76832. * Creates a new raw 3D texture
  76833. * @param data defines the data used to create the texture
  76834. * @param width defines the width of the texture
  76835. * @param height defines the height of the texture
  76836. * @param depth defines the depth of the texture
  76837. * @param format defines the format of the texture
  76838. * @param generateMipMaps defines if the engine must generate mip levels
  76839. * @param invertY defines if data must be stored with Y axis inverted
  76840. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76841. * @param compression defines the compressed used (can be null)
  76842. * @param textureType defines the compressed used (can be null)
  76843. * @returns a new raw 3D texture (stored in an InternalTexture)
  76844. */
  76845. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76846. /**
  76847. * Update a raw 3D texture
  76848. * @param texture defines the texture to update
  76849. * @param data defines the data to store
  76850. * @param format defines the data format
  76851. * @param invertY defines if data must be stored with Y axis inverted
  76852. */
  76853. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76854. /**
  76855. * Update a raw 3D texture
  76856. * @param texture defines the texture to update
  76857. * @param data defines the data to store
  76858. * @param format defines the data format
  76859. * @param invertY defines if data must be stored with Y axis inverted
  76860. * @param compression defines the used compression (can be null)
  76861. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76862. */
  76863. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76864. }
  76865. }
  76866. declare module BABYLON {
  76867. /**
  76868. * Raw texture can help creating a texture directly from an array of data.
  76869. * This can be super useful if you either get the data from an uncompressed source or
  76870. * if you wish to create your texture pixel by pixel.
  76871. */
  76872. export class RawTexture extends Texture {
  76873. /**
  76874. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76875. */
  76876. format: number;
  76877. private _engine;
  76878. /**
  76879. * Instantiates a new RawTexture.
  76880. * Raw texture can help creating a texture directly from an array of data.
  76881. * This can be super useful if you either get the data from an uncompressed source or
  76882. * if you wish to create your texture pixel by pixel.
  76883. * @param data define the array of data to use to create the texture
  76884. * @param width define the width of the texture
  76885. * @param height define the height of the texture
  76886. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76887. * @param scene define the scene the texture belongs to
  76888. * @param generateMipMaps define whether mip maps should be generated or not
  76889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76892. */
  76893. constructor(data: ArrayBufferView, width: number, height: number,
  76894. /**
  76895. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76896. */
  76897. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76898. /**
  76899. * Updates the texture underlying data.
  76900. * @param data Define the new data of the texture
  76901. */
  76902. update(data: ArrayBufferView): void;
  76903. /**
  76904. * Creates a luminance texture from some data.
  76905. * @param data Define the texture data
  76906. * @param width Define the width of the texture
  76907. * @param height Define the height of the texture
  76908. * @param scene Define the scene the texture belongs to
  76909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76912. * @returns the luminance texture
  76913. */
  76914. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76915. /**
  76916. * Creates a luminance alpha texture from some data.
  76917. * @param data Define the texture data
  76918. * @param width Define the width of the texture
  76919. * @param height Define the height of the texture
  76920. * @param scene Define the scene the texture belongs to
  76921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76924. * @returns the luminance alpha texture
  76925. */
  76926. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76927. /**
  76928. * Creates an alpha texture from some data.
  76929. * @param data Define the texture data
  76930. * @param width Define the width of the texture
  76931. * @param height Define the height of the texture
  76932. * @param scene Define the scene the texture belongs to
  76933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76936. * @returns the alpha texture
  76937. */
  76938. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76939. /**
  76940. * Creates a RGB texture from some data.
  76941. * @param data Define the texture data
  76942. * @param width Define the width of the texture
  76943. * @param height Define the height of the texture
  76944. * @param scene Define the scene the texture belongs to
  76945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76949. * @returns the RGB alpha texture
  76950. */
  76951. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76952. /**
  76953. * Creates a RGBA texture from some data.
  76954. * @param data Define the texture data
  76955. * @param width Define the width of the texture
  76956. * @param height Define the height of the texture
  76957. * @param scene Define the scene the texture belongs to
  76958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76962. * @returns the RGBA texture
  76963. */
  76964. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76965. /**
  76966. * Creates a R texture from some data.
  76967. * @param data Define the texture data
  76968. * @param width Define the width of the texture
  76969. * @param height Define the height of the texture
  76970. * @param scene Define the scene the texture belongs to
  76971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76975. * @returns the R texture
  76976. */
  76977. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76978. }
  76979. }
  76980. declare module BABYLON {
  76981. /**
  76982. * Interface for the size containing width and height
  76983. */
  76984. export interface ISize {
  76985. /**
  76986. * Width
  76987. */
  76988. width: number;
  76989. /**
  76990. * Heighht
  76991. */
  76992. height: number;
  76993. }
  76994. /**
  76995. * Size containing widht and height
  76996. */
  76997. export class Size implements ISize {
  76998. /**
  76999. * Width
  77000. */
  77001. width: number;
  77002. /**
  77003. * Height
  77004. */
  77005. height: number;
  77006. /**
  77007. * Creates a Size object from the given width and height (floats).
  77008. * @param width width of the new size
  77009. * @param height height of the new size
  77010. */
  77011. constructor(width: number, height: number);
  77012. /**
  77013. * Returns a string with the Size width and height
  77014. * @returns a string with the Size width and height
  77015. */
  77016. toString(): string;
  77017. /**
  77018. * "Size"
  77019. * @returns the string "Size"
  77020. */
  77021. getClassName(): string;
  77022. /**
  77023. * Returns the Size hash code.
  77024. * @returns a hash code for a unique width and height
  77025. */
  77026. getHashCode(): number;
  77027. /**
  77028. * Updates the current size from the given one.
  77029. * @param src the given size
  77030. */
  77031. copyFrom(src: Size): void;
  77032. /**
  77033. * Updates in place the current Size from the given floats.
  77034. * @param width width of the new size
  77035. * @param height height of the new size
  77036. * @returns the updated Size.
  77037. */
  77038. copyFromFloats(width: number, height: number): Size;
  77039. /**
  77040. * Updates in place the current Size from the given floats.
  77041. * @param width width to set
  77042. * @param height height to set
  77043. * @returns the updated Size.
  77044. */
  77045. set(width: number, height: number): Size;
  77046. /**
  77047. * Multiplies the width and height by numbers
  77048. * @param w factor to multiple the width by
  77049. * @param h factor to multiple the height by
  77050. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77051. */
  77052. multiplyByFloats(w: number, h: number): Size;
  77053. /**
  77054. * Clones the size
  77055. * @returns a new Size copied from the given one.
  77056. */
  77057. clone(): Size;
  77058. /**
  77059. * True if the current Size and the given one width and height are strictly equal.
  77060. * @param other the other size to compare against
  77061. * @returns True if the current Size and the given one width and height are strictly equal.
  77062. */
  77063. equals(other: Size): boolean;
  77064. /**
  77065. * The surface of the Size : width * height (float).
  77066. */
  77067. readonly surface: number;
  77068. /**
  77069. * Create a new size of zero
  77070. * @returns a new Size set to (0.0, 0.0)
  77071. */
  77072. static Zero(): Size;
  77073. /**
  77074. * Sums the width and height of two sizes
  77075. * @param otherSize size to add to this size
  77076. * @returns a new Size set as the addition result of the current Size and the given one.
  77077. */
  77078. add(otherSize: Size): Size;
  77079. /**
  77080. * Subtracts the width and height of two
  77081. * @param otherSize size to subtract to this size
  77082. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77083. */
  77084. subtract(otherSize: Size): Size;
  77085. /**
  77086. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77087. * @param start starting size to lerp between
  77088. * @param end end size to lerp between
  77089. * @param amount amount to lerp between the start and end values
  77090. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77091. */
  77092. static Lerp(start: Size, end: Size, amount: number): Size;
  77093. }
  77094. }
  77095. declare module BABYLON {
  77096. /**
  77097. * Defines a runtime animation
  77098. */
  77099. export class RuntimeAnimation {
  77100. private _events;
  77101. /**
  77102. * The current frame of the runtime animation
  77103. */
  77104. private _currentFrame;
  77105. /**
  77106. * The animation used by the runtime animation
  77107. */
  77108. private _animation;
  77109. /**
  77110. * The target of the runtime animation
  77111. */
  77112. private _target;
  77113. /**
  77114. * The initiating animatable
  77115. */
  77116. private _host;
  77117. /**
  77118. * The original value of the runtime animation
  77119. */
  77120. private _originalValue;
  77121. /**
  77122. * The original blend value of the runtime animation
  77123. */
  77124. private _originalBlendValue;
  77125. /**
  77126. * The offsets cache of the runtime animation
  77127. */
  77128. private _offsetsCache;
  77129. /**
  77130. * The high limits cache of the runtime animation
  77131. */
  77132. private _highLimitsCache;
  77133. /**
  77134. * Specifies if the runtime animation has been stopped
  77135. */
  77136. private _stopped;
  77137. /**
  77138. * The blending factor of the runtime animation
  77139. */
  77140. private _blendingFactor;
  77141. /**
  77142. * The BabylonJS scene
  77143. */
  77144. private _scene;
  77145. /**
  77146. * The current value of the runtime animation
  77147. */
  77148. private _currentValue;
  77149. /** @hidden */
  77150. _animationState: _IAnimationState;
  77151. /**
  77152. * The active target of the runtime animation
  77153. */
  77154. private _activeTargets;
  77155. private _currentActiveTarget;
  77156. private _directTarget;
  77157. /**
  77158. * The target path of the runtime animation
  77159. */
  77160. private _targetPath;
  77161. /**
  77162. * The weight of the runtime animation
  77163. */
  77164. private _weight;
  77165. /**
  77166. * The ratio offset of the runtime animation
  77167. */
  77168. private _ratioOffset;
  77169. /**
  77170. * The previous delay of the runtime animation
  77171. */
  77172. private _previousDelay;
  77173. /**
  77174. * The previous ratio of the runtime animation
  77175. */
  77176. private _previousRatio;
  77177. private _enableBlending;
  77178. private _keys;
  77179. private _minFrame;
  77180. private _maxFrame;
  77181. private _minValue;
  77182. private _maxValue;
  77183. private _targetIsArray;
  77184. /**
  77185. * Gets the current frame of the runtime animation
  77186. */
  77187. readonly currentFrame: number;
  77188. /**
  77189. * Gets the weight of the runtime animation
  77190. */
  77191. readonly weight: number;
  77192. /**
  77193. * Gets the current value of the runtime animation
  77194. */
  77195. readonly currentValue: any;
  77196. /**
  77197. * Gets the target path of the runtime animation
  77198. */
  77199. readonly targetPath: string;
  77200. /**
  77201. * Gets the actual target of the runtime animation
  77202. */
  77203. readonly target: any;
  77204. /** @hidden */
  77205. _onLoop: () => void;
  77206. /**
  77207. * Create a new RuntimeAnimation object
  77208. * @param target defines the target of the animation
  77209. * @param animation defines the source animation object
  77210. * @param scene defines the hosting scene
  77211. * @param host defines the initiating Animatable
  77212. */
  77213. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77214. private _preparePath;
  77215. /**
  77216. * Gets the animation from the runtime animation
  77217. */
  77218. readonly animation: Animation;
  77219. /**
  77220. * Resets the runtime animation to the beginning
  77221. * @param restoreOriginal defines whether to restore the target property to the original value
  77222. */
  77223. reset(restoreOriginal?: boolean): void;
  77224. /**
  77225. * Specifies if the runtime animation is stopped
  77226. * @returns Boolean specifying if the runtime animation is stopped
  77227. */
  77228. isStopped(): boolean;
  77229. /**
  77230. * Disposes of the runtime animation
  77231. */
  77232. dispose(): void;
  77233. /**
  77234. * Apply the interpolated value to the target
  77235. * @param currentValue defines the value computed by the animation
  77236. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77237. */
  77238. setValue(currentValue: any, weight: number): void;
  77239. private _getOriginalValues;
  77240. private _setValue;
  77241. /**
  77242. * Gets the loop pmode of the runtime animation
  77243. * @returns Loop Mode
  77244. */
  77245. private _getCorrectLoopMode;
  77246. /**
  77247. * Move the current animation to a given frame
  77248. * @param frame defines the frame to move to
  77249. */
  77250. goToFrame(frame: number): void;
  77251. /**
  77252. * @hidden Internal use only
  77253. */
  77254. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77255. /**
  77256. * Execute the current animation
  77257. * @param delay defines the delay to add to the current frame
  77258. * @param from defines the lower bound of the animation range
  77259. * @param to defines the upper bound of the animation range
  77260. * @param loop defines if the current animation must loop
  77261. * @param speedRatio defines the current speed ratio
  77262. * @param weight defines the weight of the animation (default is -1 so no weight)
  77263. * @param onLoop optional callback called when animation loops
  77264. * @returns a boolean indicating if the animation is running
  77265. */
  77266. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77267. }
  77268. }
  77269. declare module BABYLON {
  77270. /**
  77271. * Class used to store an actual running animation
  77272. */
  77273. export class Animatable {
  77274. /** defines the target object */
  77275. target: any;
  77276. /** defines the starting frame number (default is 0) */
  77277. fromFrame: number;
  77278. /** defines the ending frame number (default is 100) */
  77279. toFrame: number;
  77280. /** defines if the animation must loop (default is false) */
  77281. loopAnimation: boolean;
  77282. /** defines a callback to call when animation ends if it is not looping */
  77283. onAnimationEnd?: (() => void) | null | undefined;
  77284. /** defines a callback to call when animation loops */
  77285. onAnimationLoop?: (() => void) | null | undefined;
  77286. private _localDelayOffset;
  77287. private _pausedDelay;
  77288. private _runtimeAnimations;
  77289. private _paused;
  77290. private _scene;
  77291. private _speedRatio;
  77292. private _weight;
  77293. private _syncRoot;
  77294. /**
  77295. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77296. * This will only apply for non looping animation (default is true)
  77297. */
  77298. disposeOnEnd: boolean;
  77299. /**
  77300. * Gets a boolean indicating if the animation has started
  77301. */
  77302. animationStarted: boolean;
  77303. /**
  77304. * Observer raised when the animation ends
  77305. */
  77306. onAnimationEndObservable: Observable<Animatable>;
  77307. /**
  77308. * Observer raised when the animation loops
  77309. */
  77310. onAnimationLoopObservable: Observable<Animatable>;
  77311. /**
  77312. * Gets the root Animatable used to synchronize and normalize animations
  77313. */
  77314. readonly syncRoot: Nullable<Animatable>;
  77315. /**
  77316. * Gets the current frame of the first RuntimeAnimation
  77317. * Used to synchronize Animatables
  77318. */
  77319. readonly masterFrame: number;
  77320. /**
  77321. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77322. */
  77323. weight: number;
  77324. /**
  77325. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77326. */
  77327. speedRatio: number;
  77328. /**
  77329. * Creates a new Animatable
  77330. * @param scene defines the hosting scene
  77331. * @param target defines the target object
  77332. * @param fromFrame defines the starting frame number (default is 0)
  77333. * @param toFrame defines the ending frame number (default is 100)
  77334. * @param loopAnimation defines if the animation must loop (default is false)
  77335. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77336. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77337. * @param animations defines a group of animation to add to the new Animatable
  77338. * @param onAnimationLoop defines a callback to call when animation loops
  77339. */
  77340. constructor(scene: Scene,
  77341. /** defines the target object */
  77342. target: any,
  77343. /** defines the starting frame number (default is 0) */
  77344. fromFrame?: number,
  77345. /** defines the ending frame number (default is 100) */
  77346. toFrame?: number,
  77347. /** defines if the animation must loop (default is false) */
  77348. loopAnimation?: boolean, speedRatio?: number,
  77349. /** defines a callback to call when animation ends if it is not looping */
  77350. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77351. /** defines a callback to call when animation loops */
  77352. onAnimationLoop?: (() => void) | null | undefined);
  77353. /**
  77354. * Synchronize and normalize current Animatable with a source Animatable
  77355. * This is useful when using animation weights and when animations are not of the same length
  77356. * @param root defines the root Animatable to synchronize with
  77357. * @returns the current Animatable
  77358. */
  77359. syncWith(root: Animatable): Animatable;
  77360. /**
  77361. * Gets the list of runtime animations
  77362. * @returns an array of RuntimeAnimation
  77363. */
  77364. getAnimations(): RuntimeAnimation[];
  77365. /**
  77366. * Adds more animations to the current animatable
  77367. * @param target defines the target of the animations
  77368. * @param animations defines the new animations to add
  77369. */
  77370. appendAnimations(target: any, animations: Animation[]): void;
  77371. /**
  77372. * Gets the source animation for a specific property
  77373. * @param property defines the propertyu to look for
  77374. * @returns null or the source animation for the given property
  77375. */
  77376. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77377. /**
  77378. * Gets the runtime animation for a specific property
  77379. * @param property defines the propertyu to look for
  77380. * @returns null or the runtime animation for the given property
  77381. */
  77382. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77383. /**
  77384. * Resets the animatable to its original state
  77385. */
  77386. reset(): void;
  77387. /**
  77388. * Allows the animatable to blend with current running animations
  77389. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77390. * @param blendingSpeed defines the blending speed to use
  77391. */
  77392. enableBlending(blendingSpeed: number): void;
  77393. /**
  77394. * Disable animation blending
  77395. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77396. */
  77397. disableBlending(): void;
  77398. /**
  77399. * Jump directly to a given frame
  77400. * @param frame defines the frame to jump to
  77401. */
  77402. goToFrame(frame: number): void;
  77403. /**
  77404. * Pause the animation
  77405. */
  77406. pause(): void;
  77407. /**
  77408. * Restart the animation
  77409. */
  77410. restart(): void;
  77411. private _raiseOnAnimationEnd;
  77412. /**
  77413. * Stop and delete the current animation
  77414. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77415. * @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)
  77416. */
  77417. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77418. /**
  77419. * Wait asynchronously for the animation to end
  77420. * @returns a promise which will be fullfilled when the animation ends
  77421. */
  77422. waitAsync(): Promise<Animatable>;
  77423. /** @hidden */
  77424. _animate(delay: number): boolean;
  77425. }
  77426. interface Scene {
  77427. /** @hidden */
  77428. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77429. /** @hidden */
  77430. _processLateAnimationBindingsForMatrices(holder: {
  77431. totalWeight: number;
  77432. animations: RuntimeAnimation[];
  77433. originalValue: Matrix;
  77434. }): any;
  77435. /** @hidden */
  77436. _processLateAnimationBindingsForQuaternions(holder: {
  77437. totalWeight: number;
  77438. animations: RuntimeAnimation[];
  77439. originalValue: Quaternion;
  77440. }, refQuaternion: Quaternion): Quaternion;
  77441. /** @hidden */
  77442. _processLateAnimationBindings(): void;
  77443. /**
  77444. * Will start the animation sequence of a given target
  77445. * @param target defines the target
  77446. * @param from defines from which frame should animation start
  77447. * @param to defines until which frame should animation run.
  77448. * @param weight defines the weight to apply to the animation (1.0 by default)
  77449. * @param loop defines if the animation loops
  77450. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77451. * @param onAnimationEnd defines the function to be executed when the animation ends
  77452. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77453. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77454. * @param onAnimationLoop defines the callback to call when an animation loops
  77455. * @returns the animatable object created for this animation
  77456. */
  77457. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77458. /**
  77459. * Will start the animation sequence of a given target
  77460. * @param target defines the target
  77461. * @param from defines from which frame should animation start
  77462. * @param to defines until which frame should animation run.
  77463. * @param loop defines if the animation loops
  77464. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77465. * @param onAnimationEnd defines the function to be executed when the animation ends
  77466. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77467. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77468. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77469. * @param onAnimationLoop defines the callback to call when an animation loops
  77470. * @returns the animatable object created for this animation
  77471. */
  77472. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77473. /**
  77474. * Will start the animation sequence of a given target and its hierarchy
  77475. * @param target defines the target
  77476. * @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.
  77477. * @param from defines from which frame should animation start
  77478. * @param to defines until which frame should animation run.
  77479. * @param loop defines if the animation loops
  77480. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77481. * @param onAnimationEnd defines the function to be executed when the animation ends
  77482. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77483. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77484. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77485. * @param onAnimationLoop defines the callback to call when an animation loops
  77486. * @returns the list of created animatables
  77487. */
  77488. 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[];
  77489. /**
  77490. * Begin a new animation on a given node
  77491. * @param target defines the target where the animation will take place
  77492. * @param animations defines the list of animations to start
  77493. * @param from defines the initial value
  77494. * @param to defines the final value
  77495. * @param loop defines if you want animation to loop (off by default)
  77496. * @param speedRatio defines the speed ratio to apply to all animations
  77497. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77498. * @param onAnimationLoop defines the callback to call when an animation loops
  77499. * @returns the list of created animatables
  77500. */
  77501. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77502. /**
  77503. * Begin a new animation on a given node and its hierarchy
  77504. * @param target defines the root node where the animation will take place
  77505. * @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.
  77506. * @param animations defines the list of animations to start
  77507. * @param from defines the initial value
  77508. * @param to defines the final value
  77509. * @param loop defines if you want animation to loop (off by default)
  77510. * @param speedRatio defines the speed ratio to apply to all animations
  77511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77512. * @param onAnimationLoop defines the callback to call when an animation loops
  77513. * @returns the list of animatables created for all nodes
  77514. */
  77515. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77516. /**
  77517. * Gets the animatable associated with a specific target
  77518. * @param target defines the target of the animatable
  77519. * @returns the required animatable if found
  77520. */
  77521. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77522. /**
  77523. * Gets all animatables associated with a given target
  77524. * @param target defines the target to look animatables for
  77525. * @returns an array of Animatables
  77526. */
  77527. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77528. /**
  77529. * Stops and removes all animations that have been applied to the scene
  77530. */
  77531. stopAllAnimations(): void;
  77532. }
  77533. interface Bone {
  77534. /**
  77535. * Copy an animation range from another bone
  77536. * @param source defines the source bone
  77537. * @param rangeName defines the range name to copy
  77538. * @param frameOffset defines the frame offset
  77539. * @param rescaleAsRequired defines if rescaling must be applied if required
  77540. * @param skelDimensionsRatio defines the scaling ratio
  77541. * @returns true if operation was successful
  77542. */
  77543. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77544. }
  77545. }
  77546. declare module BABYLON {
  77547. /**
  77548. * Class used to override all child animations of a given target
  77549. */
  77550. export class AnimationPropertiesOverride {
  77551. /**
  77552. * Gets or sets a value indicating if animation blending must be used
  77553. */
  77554. enableBlending: boolean;
  77555. /**
  77556. * Gets or sets the blending speed to use when enableBlending is true
  77557. */
  77558. blendingSpeed: number;
  77559. /**
  77560. * Gets or sets the default loop mode to use
  77561. */
  77562. loopMode: number;
  77563. }
  77564. }
  77565. declare module BABYLON {
  77566. /**
  77567. * Class used to handle skinning animations
  77568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77569. */
  77570. export class Skeleton implements IAnimatable {
  77571. /** defines the skeleton name */
  77572. name: string;
  77573. /** defines the skeleton Id */
  77574. id: string;
  77575. /**
  77576. * Defines the list of child bones
  77577. */
  77578. bones: Bone[];
  77579. /**
  77580. * Defines an estimate of the dimension of the skeleton at rest
  77581. */
  77582. dimensionsAtRest: Vector3;
  77583. /**
  77584. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77585. */
  77586. needInitialSkinMatrix: boolean;
  77587. /**
  77588. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77589. */
  77590. overrideMesh: Nullable<AbstractMesh>;
  77591. /**
  77592. * Gets the list of animations attached to this skeleton
  77593. */
  77594. animations: Array<Animation>;
  77595. private _scene;
  77596. private _isDirty;
  77597. private _transformMatrices;
  77598. private _transformMatrixTexture;
  77599. private _meshesWithPoseMatrix;
  77600. private _animatables;
  77601. private _identity;
  77602. private _synchronizedWithMesh;
  77603. private _ranges;
  77604. private _lastAbsoluteTransformsUpdateId;
  77605. private _canUseTextureForBones;
  77606. private _uniqueId;
  77607. /** @hidden */
  77608. _numBonesWithLinkedTransformNode: number;
  77609. /** @hidden */
  77610. _hasWaitingData: Nullable<boolean>;
  77611. /**
  77612. * Specifies if the skeleton should be serialized
  77613. */
  77614. doNotSerialize: boolean;
  77615. private _useTextureToStoreBoneMatrices;
  77616. /**
  77617. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77618. * Please note that this option is not available if the hardware does not support it
  77619. */
  77620. useTextureToStoreBoneMatrices: boolean;
  77621. private _animationPropertiesOverride;
  77622. /**
  77623. * Gets or sets the animation properties override
  77624. */
  77625. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77626. /**
  77627. * List of inspectable custom properties (used by the Inspector)
  77628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77629. */
  77630. inspectableCustomProperties: IInspectable[];
  77631. /**
  77632. * An observable triggered before computing the skeleton's matrices
  77633. */
  77634. onBeforeComputeObservable: Observable<Skeleton>;
  77635. /**
  77636. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77637. */
  77638. readonly isUsingTextureForMatrices: boolean;
  77639. /**
  77640. * Gets the unique ID of this skeleton
  77641. */
  77642. readonly uniqueId: number;
  77643. /**
  77644. * Creates a new skeleton
  77645. * @param name defines the skeleton name
  77646. * @param id defines the skeleton Id
  77647. * @param scene defines the hosting scene
  77648. */
  77649. constructor(
  77650. /** defines the skeleton name */
  77651. name: string,
  77652. /** defines the skeleton Id */
  77653. id: string, scene: Scene);
  77654. /**
  77655. * Gets the current object class name.
  77656. * @return the class name
  77657. */
  77658. getClassName(): string;
  77659. /**
  77660. * Returns an array containing the root bones
  77661. * @returns an array containing the root bones
  77662. */
  77663. getChildren(): Array<Bone>;
  77664. /**
  77665. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77666. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77667. * @returns a Float32Array containing matrices data
  77668. */
  77669. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77670. /**
  77671. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77673. * @returns a raw texture containing the data
  77674. */
  77675. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77676. /**
  77677. * Gets the current hosting scene
  77678. * @returns a scene object
  77679. */
  77680. getScene(): Scene;
  77681. /**
  77682. * Gets a string representing the current skeleton data
  77683. * @param fullDetails defines a boolean indicating if we want a verbose version
  77684. * @returns a string representing the current skeleton data
  77685. */
  77686. toString(fullDetails?: boolean): string;
  77687. /**
  77688. * Get bone's index searching by name
  77689. * @param name defines bone's name to search for
  77690. * @return the indice of the bone. Returns -1 if not found
  77691. */
  77692. getBoneIndexByName(name: string): number;
  77693. /**
  77694. * Creater a new animation range
  77695. * @param name defines the name of the range
  77696. * @param from defines the start key
  77697. * @param to defines the end key
  77698. */
  77699. createAnimationRange(name: string, from: number, to: number): void;
  77700. /**
  77701. * Delete a specific animation range
  77702. * @param name defines the name of the range
  77703. * @param deleteFrames defines if frames must be removed as well
  77704. */
  77705. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77706. /**
  77707. * Gets a specific animation range
  77708. * @param name defines the name of the range to look for
  77709. * @returns the requested animation range or null if not found
  77710. */
  77711. getAnimationRange(name: string): Nullable<AnimationRange>;
  77712. /**
  77713. * Gets the list of all animation ranges defined on this skeleton
  77714. * @returns an array
  77715. */
  77716. getAnimationRanges(): Nullable<AnimationRange>[];
  77717. /**
  77718. * Copy animation range from a source skeleton.
  77719. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77720. * @param source defines the source skeleton
  77721. * @param name defines the name of the range to copy
  77722. * @param rescaleAsRequired defines if rescaling must be applied if required
  77723. * @returns true if operation was successful
  77724. */
  77725. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77726. /**
  77727. * Forces the skeleton to go to rest pose
  77728. */
  77729. returnToRest(): void;
  77730. private _getHighestAnimationFrame;
  77731. /**
  77732. * Begin a specific animation range
  77733. * @param name defines the name of the range to start
  77734. * @param loop defines if looping must be turned on (false by default)
  77735. * @param speedRatio defines the speed ratio to apply (1 by default)
  77736. * @param onAnimationEnd defines a callback which will be called when animation will end
  77737. * @returns a new animatable
  77738. */
  77739. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77740. /** @hidden */
  77741. _markAsDirty(): void;
  77742. /** @hidden */
  77743. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77744. /** @hidden */
  77745. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77746. private _computeTransformMatrices;
  77747. /**
  77748. * Build all resources required to render a skeleton
  77749. */
  77750. prepare(): void;
  77751. /**
  77752. * Gets the list of animatables currently running for this skeleton
  77753. * @returns an array of animatables
  77754. */
  77755. getAnimatables(): IAnimatable[];
  77756. /**
  77757. * Clone the current skeleton
  77758. * @param name defines the name of the new skeleton
  77759. * @param id defines the id of the new skeleton
  77760. * @returns the new skeleton
  77761. */
  77762. clone(name: string, id: string): Skeleton;
  77763. /**
  77764. * Enable animation blending for this skeleton
  77765. * @param blendingSpeed defines the blending speed to apply
  77766. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77767. */
  77768. enableBlending(blendingSpeed?: number): void;
  77769. /**
  77770. * Releases all resources associated with the current skeleton
  77771. */
  77772. dispose(): void;
  77773. /**
  77774. * Serialize the skeleton in a JSON object
  77775. * @returns a JSON object
  77776. */
  77777. serialize(): any;
  77778. /**
  77779. * Creates a new skeleton from serialized data
  77780. * @param parsedSkeleton defines the serialized data
  77781. * @param scene defines the hosting scene
  77782. * @returns a new skeleton
  77783. */
  77784. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77785. /**
  77786. * Compute all node absolute transforms
  77787. * @param forceUpdate defines if computation must be done even if cache is up to date
  77788. */
  77789. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77790. /**
  77791. * Gets the root pose matrix
  77792. * @returns a matrix
  77793. */
  77794. getPoseMatrix(): Nullable<Matrix>;
  77795. /**
  77796. * Sorts bones per internal index
  77797. */
  77798. sortBones(): void;
  77799. private _sortBones;
  77800. }
  77801. }
  77802. declare module BABYLON {
  77803. /**
  77804. * Class used to store bone information
  77805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77806. */
  77807. export class Bone extends Node {
  77808. /**
  77809. * defines the bone name
  77810. */
  77811. name: string;
  77812. private static _tmpVecs;
  77813. private static _tmpQuat;
  77814. private static _tmpMats;
  77815. /**
  77816. * Gets the list of child bones
  77817. */
  77818. children: Bone[];
  77819. /** Gets the animations associated with this bone */
  77820. animations: Animation[];
  77821. /**
  77822. * Gets or sets bone length
  77823. */
  77824. length: number;
  77825. /**
  77826. * @hidden Internal only
  77827. * Set this value to map this bone to a different index in the transform matrices
  77828. * Set this value to -1 to exclude the bone from the transform matrices
  77829. */
  77830. _index: Nullable<number>;
  77831. private _skeleton;
  77832. private _localMatrix;
  77833. private _restPose;
  77834. private _baseMatrix;
  77835. private _absoluteTransform;
  77836. private _invertedAbsoluteTransform;
  77837. private _parent;
  77838. private _scalingDeterminant;
  77839. private _worldTransform;
  77840. private _localScaling;
  77841. private _localRotation;
  77842. private _localPosition;
  77843. private _needToDecompose;
  77844. private _needToCompose;
  77845. /** @hidden */
  77846. _linkedTransformNode: Nullable<TransformNode>;
  77847. /** @hidden */
  77848. _waitingTransformNodeId: Nullable<string>;
  77849. /** @hidden */
  77850. /** @hidden */
  77851. _matrix: Matrix;
  77852. /**
  77853. * Create a new bone
  77854. * @param name defines the bone name
  77855. * @param skeleton defines the parent skeleton
  77856. * @param parentBone defines the parent (can be null if the bone is the root)
  77857. * @param localMatrix defines the local matrix
  77858. * @param restPose defines the rest pose matrix
  77859. * @param baseMatrix defines the base matrix
  77860. * @param index defines index of the bone in the hiearchy
  77861. */
  77862. constructor(
  77863. /**
  77864. * defines the bone name
  77865. */
  77866. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77867. /**
  77868. * Gets the current object class name.
  77869. * @return the class name
  77870. */
  77871. getClassName(): string;
  77872. /**
  77873. * Gets the parent skeleton
  77874. * @returns a skeleton
  77875. */
  77876. getSkeleton(): Skeleton;
  77877. /**
  77878. * Gets parent bone
  77879. * @returns a bone or null if the bone is the root of the bone hierarchy
  77880. */
  77881. getParent(): Nullable<Bone>;
  77882. /**
  77883. * Returns an array containing the root bones
  77884. * @returns an array containing the root bones
  77885. */
  77886. getChildren(): Array<Bone>;
  77887. /**
  77888. * Sets the parent bone
  77889. * @param parent defines the parent (can be null if the bone is the root)
  77890. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77891. */
  77892. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77893. /**
  77894. * Gets the local matrix
  77895. * @returns a matrix
  77896. */
  77897. getLocalMatrix(): Matrix;
  77898. /**
  77899. * Gets the base matrix (initial matrix which remains unchanged)
  77900. * @returns a matrix
  77901. */
  77902. getBaseMatrix(): Matrix;
  77903. /**
  77904. * Gets the rest pose matrix
  77905. * @returns a matrix
  77906. */
  77907. getRestPose(): Matrix;
  77908. /**
  77909. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77910. */
  77911. getWorldMatrix(): Matrix;
  77912. /**
  77913. * Sets the local matrix to rest pose matrix
  77914. */
  77915. returnToRest(): void;
  77916. /**
  77917. * Gets the inverse of the absolute transform matrix.
  77918. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77919. * @returns a matrix
  77920. */
  77921. getInvertedAbsoluteTransform(): Matrix;
  77922. /**
  77923. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77924. * @returns a matrix
  77925. */
  77926. getAbsoluteTransform(): Matrix;
  77927. /**
  77928. * Links with the given transform node.
  77929. * The local matrix of this bone is copied from the transform node every frame.
  77930. * @param transformNode defines the transform node to link to
  77931. */
  77932. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77933. /**
  77934. * Gets the node used to drive the bone's transformation
  77935. * @returns a transform node or null
  77936. */
  77937. getTransformNode(): Nullable<TransformNode>;
  77938. /** Gets or sets current position (in local space) */
  77939. position: Vector3;
  77940. /** Gets or sets current rotation (in local space) */
  77941. rotation: Vector3;
  77942. /** Gets or sets current rotation quaternion (in local space) */
  77943. rotationQuaternion: Quaternion;
  77944. /** Gets or sets current scaling (in local space) */
  77945. scaling: Vector3;
  77946. /**
  77947. * Gets the animation properties override
  77948. */
  77949. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77950. private _decompose;
  77951. private _compose;
  77952. /**
  77953. * Update the base and local matrices
  77954. * @param matrix defines the new base or local matrix
  77955. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77956. * @param updateLocalMatrix defines if the local matrix should be updated
  77957. */
  77958. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77959. /** @hidden */
  77960. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77961. /**
  77962. * Flag the bone as dirty (Forcing it to update everything)
  77963. */
  77964. markAsDirty(): void;
  77965. /** @hidden */
  77966. _markAsDirtyAndCompose(): void;
  77967. private _markAsDirtyAndDecompose;
  77968. /**
  77969. * Translate the bone in local or world space
  77970. * @param vec The amount to translate the bone
  77971. * @param space The space that the translation is in
  77972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77973. */
  77974. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77975. /**
  77976. * Set the postion of the bone in local or world space
  77977. * @param position The position to set the bone
  77978. * @param space The space that the position is in
  77979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77980. */
  77981. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77982. /**
  77983. * Set the absolute position of the bone (world space)
  77984. * @param position The position to set the bone
  77985. * @param mesh The mesh that this bone is attached to
  77986. */
  77987. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77988. /**
  77989. * Scale the bone on the x, y and z axes (in local space)
  77990. * @param x The amount to scale the bone on the x axis
  77991. * @param y The amount to scale the bone on the y axis
  77992. * @param z The amount to scale the bone on the z axis
  77993. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77994. */
  77995. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77996. /**
  77997. * Set the bone scaling in local space
  77998. * @param scale defines the scaling vector
  77999. */
  78000. setScale(scale: Vector3): void;
  78001. /**
  78002. * Gets the current scaling in local space
  78003. * @returns the current scaling vector
  78004. */
  78005. getScale(): Vector3;
  78006. /**
  78007. * Gets the current scaling in local space and stores it in a target vector
  78008. * @param result defines the target vector
  78009. */
  78010. getScaleToRef(result: Vector3): void;
  78011. /**
  78012. * Set the yaw, pitch, and roll of the bone in local or world space
  78013. * @param yaw The rotation of the bone on the y axis
  78014. * @param pitch The rotation of the bone on the x axis
  78015. * @param roll The rotation of the bone on the z axis
  78016. * @param space The space that the axes of rotation are in
  78017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78018. */
  78019. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78020. /**
  78021. * Add a rotation to the bone on an axis in local or world space
  78022. * @param axis The axis to rotate the bone on
  78023. * @param amount The amount to rotate the bone
  78024. * @param space The space that the axis is in
  78025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78026. */
  78027. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78028. /**
  78029. * Set the rotation of the bone to a particular axis angle in local or world space
  78030. * @param axis The axis to rotate the bone on
  78031. * @param angle The angle that the bone should be rotated to
  78032. * @param space The space that the axis is in
  78033. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78034. */
  78035. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78036. /**
  78037. * Set the euler rotation of the bone in local of world space
  78038. * @param rotation The euler rotation that the bone should be set to
  78039. * @param space The space that the rotation is in
  78040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78041. */
  78042. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78043. /**
  78044. * Set the quaternion rotation of the bone in local of world space
  78045. * @param quat The quaternion rotation that the bone should be set to
  78046. * @param space The space that the rotation is in
  78047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78048. */
  78049. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78050. /**
  78051. * Set the rotation matrix of the bone in local of world space
  78052. * @param rotMat The rotation matrix that the bone should be set to
  78053. * @param space The space that the rotation is in
  78054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78055. */
  78056. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78057. private _rotateWithMatrix;
  78058. private _getNegativeRotationToRef;
  78059. /**
  78060. * Get the position of the bone in local or world space
  78061. * @param space The space that the returned position is in
  78062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78063. * @returns The position of the bone
  78064. */
  78065. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78066. /**
  78067. * Copy the position of the bone to a vector3 in local or world space
  78068. * @param space The space that the returned position is in
  78069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78070. * @param result The vector3 to copy the position to
  78071. */
  78072. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78073. /**
  78074. * Get the absolute position of the bone (world space)
  78075. * @param mesh The mesh that this bone is attached to
  78076. * @returns The absolute position of the bone
  78077. */
  78078. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78079. /**
  78080. * Copy the absolute position of the bone (world space) to the result param
  78081. * @param mesh The mesh that this bone is attached to
  78082. * @param result The vector3 to copy the absolute position to
  78083. */
  78084. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78085. /**
  78086. * Compute the absolute transforms of this bone and its children
  78087. */
  78088. computeAbsoluteTransforms(): void;
  78089. /**
  78090. * Get the world direction from an axis that is in the local space of the bone
  78091. * @param localAxis The local direction that is used to compute the world direction
  78092. * @param mesh The mesh that this bone is attached to
  78093. * @returns The world direction
  78094. */
  78095. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78096. /**
  78097. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78098. * @param localAxis The local direction that is used to compute the world direction
  78099. * @param mesh The mesh that this bone is attached to
  78100. * @param result The vector3 that the world direction will be copied to
  78101. */
  78102. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78103. /**
  78104. * Get the euler rotation of the bone in local or world space
  78105. * @param space The space that the rotation should be in
  78106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78107. * @returns The euler rotation
  78108. */
  78109. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78110. /**
  78111. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78112. * @param space The space that the rotation should be in
  78113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78114. * @param result The vector3 that the rotation should be copied to
  78115. */
  78116. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78117. /**
  78118. * Get the quaternion rotation of the bone in either local or world space
  78119. * @param space The space that the rotation should be in
  78120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78121. * @returns The quaternion rotation
  78122. */
  78123. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78124. /**
  78125. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78126. * @param space The space that the rotation should be in
  78127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78128. * @param result The quaternion that the rotation should be copied to
  78129. */
  78130. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78131. /**
  78132. * Get the rotation matrix of the bone in local or world space
  78133. * @param space The space that the rotation should be in
  78134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78135. * @returns The rotation matrix
  78136. */
  78137. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78138. /**
  78139. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78140. * @param space The space that the rotation should be in
  78141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78142. * @param result The quaternion that the rotation should be copied to
  78143. */
  78144. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78145. /**
  78146. * Get the world position of a point that is in the local space of the bone
  78147. * @param position The local position
  78148. * @param mesh The mesh that this bone is attached to
  78149. * @returns The world position
  78150. */
  78151. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78152. /**
  78153. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78154. * @param position The local position
  78155. * @param mesh The mesh that this bone is attached to
  78156. * @param result The vector3 that the world position should be copied to
  78157. */
  78158. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78159. /**
  78160. * Get the local position of a point that is in world space
  78161. * @param position The world position
  78162. * @param mesh The mesh that this bone is attached to
  78163. * @returns The local position
  78164. */
  78165. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78166. /**
  78167. * Get the local position of a point that is in world space and copy it to the result param
  78168. * @param position The world position
  78169. * @param mesh The mesh that this bone is attached to
  78170. * @param result The vector3 that the local position should be copied to
  78171. */
  78172. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78173. }
  78174. }
  78175. declare module BABYLON {
  78176. /**
  78177. * 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.
  78178. * @see https://doc.babylonjs.com/how_to/transformnode
  78179. */
  78180. export class TransformNode extends Node {
  78181. /**
  78182. * Object will not rotate to face the camera
  78183. */
  78184. static BILLBOARDMODE_NONE: number;
  78185. /**
  78186. * Object will rotate to face the camera but only on the x axis
  78187. */
  78188. static BILLBOARDMODE_X: number;
  78189. /**
  78190. * Object will rotate to face the camera but only on the y axis
  78191. */
  78192. static BILLBOARDMODE_Y: number;
  78193. /**
  78194. * Object will rotate to face the camera but only on the z axis
  78195. */
  78196. static BILLBOARDMODE_Z: number;
  78197. /**
  78198. * Object will rotate to face the camera
  78199. */
  78200. static BILLBOARDMODE_ALL: number;
  78201. /**
  78202. * Object will rotate to face the camera's position instead of orientation
  78203. */
  78204. static BILLBOARDMODE_USE_POSITION: number;
  78205. private _forward;
  78206. private _forwardInverted;
  78207. private _up;
  78208. private _right;
  78209. private _rightInverted;
  78210. private _position;
  78211. private _rotation;
  78212. private _rotationQuaternion;
  78213. protected _scaling: Vector3;
  78214. protected _isDirty: boolean;
  78215. private _transformToBoneReferal;
  78216. private _isAbsoluteSynced;
  78217. private _billboardMode;
  78218. /**
  78219. * Gets or sets the billboard mode. Default is 0.
  78220. *
  78221. * | Value | Type | Description |
  78222. * | --- | --- | --- |
  78223. * | 0 | BILLBOARDMODE_NONE | |
  78224. * | 1 | BILLBOARDMODE_X | |
  78225. * | 2 | BILLBOARDMODE_Y | |
  78226. * | 4 | BILLBOARDMODE_Z | |
  78227. * | 7 | BILLBOARDMODE_ALL | |
  78228. *
  78229. */
  78230. billboardMode: number;
  78231. private _preserveParentRotationForBillboard;
  78232. /**
  78233. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78234. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78235. */
  78236. preserveParentRotationForBillboard: boolean;
  78237. /**
  78238. * 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
  78239. */
  78240. scalingDeterminant: number;
  78241. private _infiniteDistance;
  78242. /**
  78243. * Gets or sets the distance of the object to max, often used by skybox
  78244. */
  78245. infiniteDistance: boolean;
  78246. /**
  78247. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78248. * By default the system will update normals to compensate
  78249. */
  78250. ignoreNonUniformScaling: boolean;
  78251. /**
  78252. * 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
  78253. */
  78254. reIntegrateRotationIntoRotationQuaternion: boolean;
  78255. /** @hidden */
  78256. _poseMatrix: Nullable<Matrix>;
  78257. /** @hidden */
  78258. _localMatrix: Matrix;
  78259. private _usePivotMatrix;
  78260. private _absolutePosition;
  78261. private _absoluteScaling;
  78262. private _absoluteRotationQuaternion;
  78263. private _pivotMatrix;
  78264. private _pivotMatrixInverse;
  78265. protected _postMultiplyPivotMatrix: boolean;
  78266. protected _isWorldMatrixFrozen: boolean;
  78267. /** @hidden */
  78268. _indexInSceneTransformNodesArray: number;
  78269. /**
  78270. * An event triggered after the world matrix is updated
  78271. */
  78272. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78273. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78274. /**
  78275. * Gets a string identifying the name of the class
  78276. * @returns "TransformNode" string
  78277. */
  78278. getClassName(): string;
  78279. /**
  78280. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78281. */
  78282. position: Vector3;
  78283. /**
  78284. * 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)).
  78285. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78286. */
  78287. rotation: Vector3;
  78288. /**
  78289. * 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)).
  78290. */
  78291. scaling: Vector3;
  78292. /**
  78293. * 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).
  78294. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78295. */
  78296. rotationQuaternion: Nullable<Quaternion>;
  78297. /**
  78298. * The forward direction of that transform in world space.
  78299. */
  78300. readonly forward: Vector3;
  78301. /**
  78302. * The up direction of that transform in world space.
  78303. */
  78304. readonly up: Vector3;
  78305. /**
  78306. * The right direction of that transform in world space.
  78307. */
  78308. readonly right: Vector3;
  78309. /**
  78310. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78311. * @param matrix the matrix to copy the pose from
  78312. * @returns this TransformNode.
  78313. */
  78314. updatePoseMatrix(matrix: Matrix): TransformNode;
  78315. /**
  78316. * Returns the mesh Pose matrix.
  78317. * @returns the pose matrix
  78318. */
  78319. getPoseMatrix(): Matrix;
  78320. /** @hidden */
  78321. _isSynchronized(): boolean;
  78322. /** @hidden */
  78323. _initCache(): void;
  78324. /**
  78325. * Flag the transform node as dirty (Forcing it to update everything)
  78326. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78327. * @returns this transform node
  78328. */
  78329. markAsDirty(property: string): TransformNode;
  78330. /**
  78331. * Returns the current mesh absolute position.
  78332. * Returns a Vector3.
  78333. */
  78334. readonly absolutePosition: Vector3;
  78335. /**
  78336. * Returns the current mesh absolute scaling.
  78337. * Returns a Vector3.
  78338. */
  78339. readonly absoluteScaling: Vector3;
  78340. /**
  78341. * Returns the current mesh absolute rotation.
  78342. * Returns a Quaternion.
  78343. */
  78344. readonly absoluteRotationQuaternion: Quaternion;
  78345. /**
  78346. * Sets a new matrix to apply before all other transformation
  78347. * @param matrix defines the transform matrix
  78348. * @returns the current TransformNode
  78349. */
  78350. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78351. /**
  78352. * Sets a new pivot matrix to the current node
  78353. * @param matrix defines the new pivot matrix to use
  78354. * @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
  78355. * @returns the current TransformNode
  78356. */
  78357. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78358. /**
  78359. * Returns the mesh pivot matrix.
  78360. * Default : Identity.
  78361. * @returns the matrix
  78362. */
  78363. getPivotMatrix(): Matrix;
  78364. /**
  78365. * Prevents the World matrix to be computed any longer.
  78366. * @returns the TransformNode.
  78367. */
  78368. freezeWorldMatrix(): TransformNode;
  78369. /**
  78370. * Allows back the World matrix computation.
  78371. * @returns the TransformNode.
  78372. */
  78373. unfreezeWorldMatrix(): this;
  78374. /**
  78375. * True if the World matrix has been frozen.
  78376. */
  78377. readonly isWorldMatrixFrozen: boolean;
  78378. /**
  78379. * Retuns the mesh absolute position in the World.
  78380. * @returns a Vector3.
  78381. */
  78382. getAbsolutePosition(): Vector3;
  78383. /**
  78384. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78385. * @param absolutePosition the absolute position to set
  78386. * @returns the TransformNode.
  78387. */
  78388. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78389. /**
  78390. * Sets the mesh position in its local space.
  78391. * @param vector3 the position to set in localspace
  78392. * @returns the TransformNode.
  78393. */
  78394. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78395. /**
  78396. * Returns the mesh position in the local space from the current World matrix values.
  78397. * @returns a new Vector3.
  78398. */
  78399. getPositionExpressedInLocalSpace(): Vector3;
  78400. /**
  78401. * Translates the mesh along the passed Vector3 in its local space.
  78402. * @param vector3 the distance to translate in localspace
  78403. * @returns the TransformNode.
  78404. */
  78405. locallyTranslate(vector3: Vector3): TransformNode;
  78406. private static _lookAtVectorCache;
  78407. /**
  78408. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78409. * @param targetPoint the position (must be in same space as current mesh) to look at
  78410. * @param yawCor optional yaw (y-axis) correction in radians
  78411. * @param pitchCor optional pitch (x-axis) correction in radians
  78412. * @param rollCor optional roll (z-axis) correction in radians
  78413. * @param space the choosen space of the target
  78414. * @returns the TransformNode.
  78415. */
  78416. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78417. /**
  78418. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78419. * This Vector3 is expressed in the World space.
  78420. * @param localAxis axis to rotate
  78421. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78422. */
  78423. getDirection(localAxis: Vector3): Vector3;
  78424. /**
  78425. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78426. * localAxis is expressed in the mesh local space.
  78427. * result is computed in the Wordl space from the mesh World matrix.
  78428. * @param localAxis axis to rotate
  78429. * @param result the resulting transformnode
  78430. * @returns this TransformNode.
  78431. */
  78432. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78433. /**
  78434. * Sets this transform node rotation to the given local axis.
  78435. * @param localAxis the axis in local space
  78436. * @param yawCor optional yaw (y-axis) correction in radians
  78437. * @param pitchCor optional pitch (x-axis) correction in radians
  78438. * @param rollCor optional roll (z-axis) correction in radians
  78439. * @returns this TransformNode
  78440. */
  78441. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78442. /**
  78443. * Sets a new pivot point to the current node
  78444. * @param point defines the new pivot point to use
  78445. * @param space defines if the point is in world or local space (local by default)
  78446. * @returns the current TransformNode
  78447. */
  78448. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78449. /**
  78450. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78451. * @returns the pivot point
  78452. */
  78453. getPivotPoint(): Vector3;
  78454. /**
  78455. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78456. * @param result the vector3 to store the result
  78457. * @returns this TransformNode.
  78458. */
  78459. getPivotPointToRef(result: Vector3): TransformNode;
  78460. /**
  78461. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78462. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78463. */
  78464. getAbsolutePivotPoint(): Vector3;
  78465. /**
  78466. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78467. * @param result vector3 to store the result
  78468. * @returns this TransformNode.
  78469. */
  78470. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78471. /**
  78472. * Defines the passed node as the parent of the current node.
  78473. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78474. * @see https://doc.babylonjs.com/how_to/parenting
  78475. * @param node the node ot set as the parent
  78476. * @returns this TransformNode.
  78477. */
  78478. setParent(node: Nullable<Node>): TransformNode;
  78479. private _nonUniformScaling;
  78480. /**
  78481. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78482. */
  78483. readonly nonUniformScaling: boolean;
  78484. /** @hidden */
  78485. _updateNonUniformScalingState(value: boolean): boolean;
  78486. /**
  78487. * Attach the current TransformNode to another TransformNode associated with a bone
  78488. * @param bone Bone affecting the TransformNode
  78489. * @param affectedTransformNode TransformNode associated with the bone
  78490. * @returns this object
  78491. */
  78492. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78493. /**
  78494. * Detach the transform node if its associated with a bone
  78495. * @returns this object
  78496. */
  78497. detachFromBone(): TransformNode;
  78498. private static _rotationAxisCache;
  78499. /**
  78500. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78501. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78502. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78503. * The passed axis is also normalized.
  78504. * @param axis the axis to rotate around
  78505. * @param amount the amount to rotate in radians
  78506. * @param space Space to rotate in (Default: local)
  78507. * @returns the TransformNode.
  78508. */
  78509. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78510. /**
  78511. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78512. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78513. * The passed axis is also normalized. .
  78514. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78515. * @param point the point to rotate around
  78516. * @param axis the axis to rotate around
  78517. * @param amount the amount to rotate in radians
  78518. * @returns the TransformNode
  78519. */
  78520. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78521. /**
  78522. * Translates the mesh along the axis vector for the passed distance in the given space.
  78523. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78524. * @param axis the axis to translate in
  78525. * @param distance the distance to translate
  78526. * @param space Space to rotate in (Default: local)
  78527. * @returns the TransformNode.
  78528. */
  78529. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78530. /**
  78531. * Adds a rotation step to the mesh current rotation.
  78532. * x, y, z are Euler angles expressed in radians.
  78533. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78534. * This means this rotation is made in the mesh local space only.
  78535. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78536. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78537. * ```javascript
  78538. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78539. * ```
  78540. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78541. * 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.
  78542. * @param x Rotation to add
  78543. * @param y Rotation to add
  78544. * @param z Rotation to add
  78545. * @returns the TransformNode.
  78546. */
  78547. addRotation(x: number, y: number, z: number): TransformNode;
  78548. /**
  78549. * @hidden
  78550. */
  78551. protected _getEffectiveParent(): Nullable<Node>;
  78552. /**
  78553. * Computes the world matrix of the node
  78554. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78555. * @returns the world matrix
  78556. */
  78557. computeWorldMatrix(force?: boolean): Matrix;
  78558. protected _afterComputeWorldMatrix(): void;
  78559. /**
  78560. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78561. * @param func callback function to add
  78562. *
  78563. * @returns the TransformNode.
  78564. */
  78565. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78566. /**
  78567. * Removes a registered callback function.
  78568. * @param func callback function to remove
  78569. * @returns the TransformNode.
  78570. */
  78571. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78572. /**
  78573. * Gets the position of the current mesh in camera space
  78574. * @param camera defines the camera to use
  78575. * @returns a position
  78576. */
  78577. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78578. /**
  78579. * Returns the distance from the mesh to the active camera
  78580. * @param camera defines the camera to use
  78581. * @returns the distance
  78582. */
  78583. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78584. /**
  78585. * Clone the current transform node
  78586. * @param name Name of the new clone
  78587. * @param newParent New parent for the clone
  78588. * @param doNotCloneChildren Do not clone children hierarchy
  78589. * @returns the new transform node
  78590. */
  78591. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78592. /**
  78593. * Serializes the objects information.
  78594. * @param currentSerializationObject defines the object to serialize in
  78595. * @returns the serialized object
  78596. */
  78597. serialize(currentSerializationObject?: any): any;
  78598. /**
  78599. * Returns a new TransformNode object parsed from the source provided.
  78600. * @param parsedTransformNode is the source.
  78601. * @param scene the scne the object belongs to
  78602. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78603. * @returns a new TransformNode object parsed from the source provided.
  78604. */
  78605. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78606. /**
  78607. * Get all child-transformNodes of this node
  78608. * @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
  78609. * @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
  78610. * @returns an array of TransformNode
  78611. */
  78612. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78613. /**
  78614. * Releases resources associated with this transform node.
  78615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78617. */
  78618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78619. /**
  78620. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78621. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78622. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78623. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78624. * @returns the current mesh
  78625. */
  78626. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78627. private _syncAbsoluteScalingAndRotation;
  78628. }
  78629. }
  78630. declare module BABYLON {
  78631. /**
  78632. * Defines the types of pose enabled controllers that are supported
  78633. */
  78634. export enum PoseEnabledControllerType {
  78635. /**
  78636. * HTC Vive
  78637. */
  78638. VIVE = 0,
  78639. /**
  78640. * Oculus Rift
  78641. */
  78642. OCULUS = 1,
  78643. /**
  78644. * Windows mixed reality
  78645. */
  78646. WINDOWS = 2,
  78647. /**
  78648. * Samsung gear VR
  78649. */
  78650. GEAR_VR = 3,
  78651. /**
  78652. * Google Daydream
  78653. */
  78654. DAYDREAM = 4,
  78655. /**
  78656. * Generic
  78657. */
  78658. GENERIC = 5
  78659. }
  78660. /**
  78661. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78662. */
  78663. export interface MutableGamepadButton {
  78664. /**
  78665. * Value of the button/trigger
  78666. */
  78667. value: number;
  78668. /**
  78669. * If the button/trigger is currently touched
  78670. */
  78671. touched: boolean;
  78672. /**
  78673. * If the button/trigger is currently pressed
  78674. */
  78675. pressed: boolean;
  78676. }
  78677. /**
  78678. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78679. * @hidden
  78680. */
  78681. export interface ExtendedGamepadButton extends GamepadButton {
  78682. /**
  78683. * If the button/trigger is currently pressed
  78684. */
  78685. readonly pressed: boolean;
  78686. /**
  78687. * If the button/trigger is currently touched
  78688. */
  78689. readonly touched: boolean;
  78690. /**
  78691. * Value of the button/trigger
  78692. */
  78693. readonly value: number;
  78694. }
  78695. /** @hidden */
  78696. export interface _GamePadFactory {
  78697. /**
  78698. * Returns wether or not the current gamepad can be created for this type of controller.
  78699. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78700. * @returns true if it can be created, otherwise false
  78701. */
  78702. canCreate(gamepadInfo: any): boolean;
  78703. /**
  78704. * Creates a new instance of the Gamepad.
  78705. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78706. * @returns the new gamepad instance
  78707. */
  78708. create(gamepadInfo: any): Gamepad;
  78709. }
  78710. /**
  78711. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78712. */
  78713. export class PoseEnabledControllerHelper {
  78714. /** @hidden */
  78715. static _ControllerFactories: _GamePadFactory[];
  78716. /** @hidden */
  78717. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78718. /**
  78719. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78720. * @param vrGamepad the gamepad to initialized
  78721. * @returns a vr controller of the type the gamepad identified as
  78722. */
  78723. static InitiateController(vrGamepad: any): Gamepad;
  78724. }
  78725. /**
  78726. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78727. */
  78728. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78729. /**
  78730. * If the controller is used in a webXR session
  78731. */
  78732. isXR: boolean;
  78733. private _deviceRoomPosition;
  78734. private _deviceRoomRotationQuaternion;
  78735. /**
  78736. * The device position in babylon space
  78737. */
  78738. devicePosition: Vector3;
  78739. /**
  78740. * The device rotation in babylon space
  78741. */
  78742. deviceRotationQuaternion: Quaternion;
  78743. /**
  78744. * The scale factor of the device in babylon space
  78745. */
  78746. deviceScaleFactor: number;
  78747. /**
  78748. * (Likely devicePosition should be used instead) The device position in its room space
  78749. */
  78750. position: Vector3;
  78751. /**
  78752. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78753. */
  78754. rotationQuaternion: Quaternion;
  78755. /**
  78756. * The type of controller (Eg. Windows mixed reality)
  78757. */
  78758. controllerType: PoseEnabledControllerType;
  78759. protected _calculatedPosition: Vector3;
  78760. private _calculatedRotation;
  78761. /**
  78762. * The raw pose from the device
  78763. */
  78764. rawPose: DevicePose;
  78765. private _trackPosition;
  78766. private _maxRotationDistFromHeadset;
  78767. private _draggedRoomRotation;
  78768. /**
  78769. * @hidden
  78770. */
  78771. _disableTrackPosition(fixedPosition: Vector3): void;
  78772. /**
  78773. * Internal, the mesh attached to the controller
  78774. * @hidden
  78775. */
  78776. _mesh: Nullable<AbstractMesh>;
  78777. private _poseControlledCamera;
  78778. private _leftHandSystemQuaternion;
  78779. /**
  78780. * Internal, matrix used to convert room space to babylon space
  78781. * @hidden
  78782. */
  78783. _deviceToWorld: Matrix;
  78784. /**
  78785. * Node to be used when casting a ray from the controller
  78786. * @hidden
  78787. */
  78788. _pointingPoseNode: Nullable<TransformNode>;
  78789. /**
  78790. * Name of the child mesh that can be used to cast a ray from the controller
  78791. */
  78792. static readonly POINTING_POSE: string;
  78793. /**
  78794. * Creates a new PoseEnabledController from a gamepad
  78795. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78796. */
  78797. constructor(browserGamepad: any);
  78798. private _workingMatrix;
  78799. /**
  78800. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78801. */
  78802. update(): void;
  78803. /**
  78804. * Updates only the pose device and mesh without doing any button event checking
  78805. */
  78806. protected _updatePoseAndMesh(): void;
  78807. /**
  78808. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78809. * @param poseData raw pose fromthe device
  78810. */
  78811. updateFromDevice(poseData: DevicePose): void;
  78812. /**
  78813. * @hidden
  78814. */
  78815. _meshAttachedObservable: Observable<AbstractMesh>;
  78816. /**
  78817. * Attaches a mesh to the controller
  78818. * @param mesh the mesh to be attached
  78819. */
  78820. attachToMesh(mesh: AbstractMesh): void;
  78821. /**
  78822. * Attaches the controllers mesh to a camera
  78823. * @param camera the camera the mesh should be attached to
  78824. */
  78825. attachToPoseControlledCamera(camera: TargetCamera): void;
  78826. /**
  78827. * Disposes of the controller
  78828. */
  78829. dispose(): void;
  78830. /**
  78831. * The mesh that is attached to the controller
  78832. */
  78833. readonly mesh: Nullable<AbstractMesh>;
  78834. /**
  78835. * Gets the ray of the controller in the direction the controller is pointing
  78836. * @param length the length the resulting ray should be
  78837. * @returns a ray in the direction the controller is pointing
  78838. */
  78839. getForwardRay(length?: number): Ray;
  78840. }
  78841. }
  78842. declare module BABYLON {
  78843. /**
  78844. * Defines the WebVRController object that represents controllers tracked in 3D space
  78845. */
  78846. export abstract class WebVRController extends PoseEnabledController {
  78847. /**
  78848. * Internal, the default controller model for the controller
  78849. */
  78850. protected _defaultModel: AbstractMesh;
  78851. /**
  78852. * Fired when the trigger state has changed
  78853. */
  78854. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78855. /**
  78856. * Fired when the main button state has changed
  78857. */
  78858. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78859. /**
  78860. * Fired when the secondary button state has changed
  78861. */
  78862. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78863. /**
  78864. * Fired when the pad state has changed
  78865. */
  78866. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78867. /**
  78868. * Fired when controllers stick values have changed
  78869. */
  78870. onPadValuesChangedObservable: Observable<StickValues>;
  78871. /**
  78872. * Array of button availible on the controller
  78873. */
  78874. protected _buttons: Array<MutableGamepadButton>;
  78875. private _onButtonStateChange;
  78876. /**
  78877. * Fired when a controller button's state has changed
  78878. * @param callback the callback containing the button that was modified
  78879. */
  78880. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78881. /**
  78882. * X and Y axis corresponding to the controllers joystick
  78883. */
  78884. pad: StickValues;
  78885. /**
  78886. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78887. */
  78888. hand: string;
  78889. /**
  78890. * The default controller model for the controller
  78891. */
  78892. readonly defaultModel: AbstractMesh;
  78893. /**
  78894. * Creates a new WebVRController from a gamepad
  78895. * @param vrGamepad the gamepad that the WebVRController should be created from
  78896. */
  78897. constructor(vrGamepad: any);
  78898. /**
  78899. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78900. */
  78901. update(): void;
  78902. /**
  78903. * Function to be called when a button is modified
  78904. */
  78905. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78906. /**
  78907. * Loads a mesh and attaches it to the controller
  78908. * @param scene the scene the mesh should be added to
  78909. * @param meshLoaded callback for when the mesh has been loaded
  78910. */
  78911. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78912. private _setButtonValue;
  78913. private _changes;
  78914. private _checkChanges;
  78915. /**
  78916. * Disposes of th webVRCOntroller
  78917. */
  78918. dispose(): void;
  78919. }
  78920. }
  78921. declare module BABYLON {
  78922. /**
  78923. * The HemisphericLight simulates the ambient environment light,
  78924. * so the passed direction is the light reflection direction, not the incoming direction.
  78925. */
  78926. export class HemisphericLight extends Light {
  78927. /**
  78928. * The groundColor is the light in the opposite direction to the one specified during creation.
  78929. * 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.
  78930. */
  78931. groundColor: Color3;
  78932. /**
  78933. * The light reflection direction, not the incoming direction.
  78934. */
  78935. direction: Vector3;
  78936. /**
  78937. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78938. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78939. * The HemisphericLight can't cast shadows.
  78940. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78941. * @param name The friendly name of the light
  78942. * @param direction The direction of the light reflection
  78943. * @param scene The scene the light belongs to
  78944. */
  78945. constructor(name: string, direction: Vector3, scene: Scene);
  78946. protected _buildUniformLayout(): void;
  78947. /**
  78948. * Returns the string "HemisphericLight".
  78949. * @return The class name
  78950. */
  78951. getClassName(): string;
  78952. /**
  78953. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78954. * Returns the updated direction.
  78955. * @param target The target the direction should point to
  78956. * @return The computed direction
  78957. */
  78958. setDirectionToTarget(target: Vector3): Vector3;
  78959. /**
  78960. * Returns the shadow generator associated to the light.
  78961. * @returns Always null for hemispheric lights because it does not support shadows.
  78962. */
  78963. getShadowGenerator(): Nullable<IShadowGenerator>;
  78964. /**
  78965. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78966. * @param effect The effect to update
  78967. * @param lightIndex The index of the light in the effect to update
  78968. * @returns The hemispheric light
  78969. */
  78970. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78971. /**
  78972. * Computes the world matrix of the node
  78973. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78974. * @param useWasUpdatedFlag defines a reserved property
  78975. * @returns the world matrix
  78976. */
  78977. computeWorldMatrix(): Matrix;
  78978. /**
  78979. * Returns the integer 3.
  78980. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78981. */
  78982. getTypeID(): number;
  78983. /**
  78984. * Prepares the list of defines specific to the light type.
  78985. * @param defines the list of defines
  78986. * @param lightIndex defines the index of the light for the effect
  78987. */
  78988. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78989. }
  78990. }
  78991. declare module BABYLON {
  78992. /** @hidden */
  78993. export var vrMultiviewToSingleviewPixelShader: {
  78994. name: string;
  78995. shader: string;
  78996. };
  78997. }
  78998. declare module BABYLON {
  78999. /**
  79000. * Renders to multiple views with a single draw call
  79001. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79002. */
  79003. export class MultiviewRenderTarget extends RenderTargetTexture {
  79004. /**
  79005. * Creates a multiview render target
  79006. * @param scene scene used with the render target
  79007. * @param size the size of the render target (used for each view)
  79008. */
  79009. constructor(scene: Scene, size?: number | {
  79010. width: number;
  79011. height: number;
  79012. } | {
  79013. ratio: number;
  79014. });
  79015. /**
  79016. * @hidden
  79017. * @param faceIndex the face index, if its a cube texture
  79018. */
  79019. _bindFrameBuffer(faceIndex?: number): void;
  79020. /**
  79021. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79022. * @returns the view count
  79023. */
  79024. getViewCount(): number;
  79025. }
  79026. }
  79027. declare module BABYLON {
  79028. /**
  79029. * Reprasents a camera frustum
  79030. */
  79031. export class Frustum {
  79032. /**
  79033. * Gets the planes representing the frustum
  79034. * @param transform matrix to be applied to the returned planes
  79035. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79036. */
  79037. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79038. /**
  79039. * Gets the near frustum plane transformed by the transform matrix
  79040. * @param transform transformation matrix to be applied to the resulting frustum plane
  79041. * @param frustumPlane the resuling frustum plane
  79042. */
  79043. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79044. /**
  79045. * Gets the far frustum plane transformed by the transform matrix
  79046. * @param transform transformation matrix to be applied to the resulting frustum plane
  79047. * @param frustumPlane the resuling frustum plane
  79048. */
  79049. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79050. /**
  79051. * Gets the left frustum plane transformed by the transform matrix
  79052. * @param transform transformation matrix to be applied to the resulting frustum plane
  79053. * @param frustumPlane the resuling frustum plane
  79054. */
  79055. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79056. /**
  79057. * Gets the right frustum plane transformed by the transform matrix
  79058. * @param transform transformation matrix to be applied to the resulting frustum plane
  79059. * @param frustumPlane the resuling frustum plane
  79060. */
  79061. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79062. /**
  79063. * Gets the top frustum plane transformed by the transform matrix
  79064. * @param transform transformation matrix to be applied to the resulting frustum plane
  79065. * @param frustumPlane the resuling frustum plane
  79066. */
  79067. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79068. /**
  79069. * Gets the bottom frustum plane transformed by the transform matrix
  79070. * @param transform transformation matrix to be applied to the resulting frustum plane
  79071. * @param frustumPlane the resuling frustum plane
  79072. */
  79073. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79074. /**
  79075. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79076. * @param transform transformation matrix to be applied to the resulting frustum planes
  79077. * @param frustumPlanes the resuling frustum planes
  79078. */
  79079. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79080. }
  79081. }
  79082. declare module BABYLON {
  79083. interface Engine {
  79084. /**
  79085. * Creates a new multiview render target
  79086. * @param width defines the width of the texture
  79087. * @param height defines the height of the texture
  79088. * @returns the created multiview texture
  79089. */
  79090. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79091. /**
  79092. * Binds a multiview framebuffer to be drawn to
  79093. * @param multiviewTexture texture to bind
  79094. */
  79095. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79096. }
  79097. interface Camera {
  79098. /**
  79099. * @hidden
  79100. * 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)
  79101. */
  79102. _useMultiviewToSingleView: boolean;
  79103. /**
  79104. * @hidden
  79105. * 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)
  79106. */
  79107. _multiviewTexture: Nullable<RenderTargetTexture>;
  79108. /**
  79109. * @hidden
  79110. * ensures the multiview texture of the camera exists and has the specified width/height
  79111. * @param width height to set on the multiview texture
  79112. * @param height width to set on the multiview texture
  79113. */
  79114. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79115. }
  79116. interface Scene {
  79117. /** @hidden */
  79118. _transformMatrixR: Matrix;
  79119. /** @hidden */
  79120. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79121. /** @hidden */
  79122. _createMultiviewUbo(): void;
  79123. /** @hidden */
  79124. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79125. /** @hidden */
  79126. _renderMultiviewToSingleView(camera: Camera): void;
  79127. }
  79128. }
  79129. declare module BABYLON {
  79130. /**
  79131. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79132. * This will not be used for webXR as it supports displaying texture arrays directly
  79133. */
  79134. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79135. /**
  79136. * Initializes a VRMultiviewToSingleview
  79137. * @param name name of the post process
  79138. * @param camera camera to be applied to
  79139. * @param scaleFactor scaling factor to the size of the output texture
  79140. */
  79141. constructor(name: string, camera: Camera, scaleFactor: number);
  79142. }
  79143. }
  79144. declare module BABYLON {
  79145. interface Engine {
  79146. /** @hidden */
  79147. _vrDisplay: any;
  79148. /** @hidden */
  79149. _vrSupported: boolean;
  79150. /** @hidden */
  79151. _oldSize: Size;
  79152. /** @hidden */
  79153. _oldHardwareScaleFactor: number;
  79154. /** @hidden */
  79155. _vrExclusivePointerMode: boolean;
  79156. /** @hidden */
  79157. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79158. /** @hidden */
  79159. _onVRDisplayPointerRestricted: () => void;
  79160. /** @hidden */
  79161. _onVRDisplayPointerUnrestricted: () => void;
  79162. /** @hidden */
  79163. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79164. /** @hidden */
  79165. _onVrDisplayDisconnect: Nullable<() => void>;
  79166. /** @hidden */
  79167. _onVrDisplayPresentChange: Nullable<() => void>;
  79168. /**
  79169. * Observable signaled when VR display mode changes
  79170. */
  79171. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79172. /**
  79173. * Observable signaled when VR request present is complete
  79174. */
  79175. onVRRequestPresentComplete: Observable<boolean>;
  79176. /**
  79177. * Observable signaled when VR request present starts
  79178. */
  79179. onVRRequestPresentStart: Observable<Engine>;
  79180. /**
  79181. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79182. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79183. */
  79184. isInVRExclusivePointerMode: boolean;
  79185. /**
  79186. * Gets a boolean indicating if a webVR device was detected
  79187. * @returns true if a webVR device was detected
  79188. */
  79189. isVRDevicePresent(): boolean;
  79190. /**
  79191. * Gets the current webVR device
  79192. * @returns the current webVR device (or null)
  79193. */
  79194. getVRDevice(): any;
  79195. /**
  79196. * Initializes a webVR display and starts listening to display change events
  79197. * The onVRDisplayChangedObservable will be notified upon these changes
  79198. * @returns A promise containing a VRDisplay and if vr is supported
  79199. */
  79200. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79201. /** @hidden */
  79202. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79203. /**
  79204. * Call this function to switch to webVR mode
  79205. * Will do nothing if webVR is not supported or if there is no webVR device
  79206. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79207. */
  79208. enableVR(): void;
  79209. /** @hidden */
  79210. _onVRFullScreenTriggered(): void;
  79211. }
  79212. }
  79213. declare module BABYLON {
  79214. /**
  79215. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79216. * IMPORTANT!! The data is right-hand data.
  79217. * @export
  79218. * @interface DevicePose
  79219. */
  79220. export interface DevicePose {
  79221. /**
  79222. * The position of the device, values in array are [x,y,z].
  79223. */
  79224. readonly position: Nullable<Float32Array>;
  79225. /**
  79226. * The linearVelocity of the device, values in array are [x,y,z].
  79227. */
  79228. readonly linearVelocity: Nullable<Float32Array>;
  79229. /**
  79230. * The linearAcceleration of the device, values in array are [x,y,z].
  79231. */
  79232. readonly linearAcceleration: Nullable<Float32Array>;
  79233. /**
  79234. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79235. */
  79236. readonly orientation: Nullable<Float32Array>;
  79237. /**
  79238. * The angularVelocity of the device, values in array are [x,y,z].
  79239. */
  79240. readonly angularVelocity: Nullable<Float32Array>;
  79241. /**
  79242. * The angularAcceleration of the device, values in array are [x,y,z].
  79243. */
  79244. readonly angularAcceleration: Nullable<Float32Array>;
  79245. }
  79246. /**
  79247. * Interface representing a pose controlled object in Babylon.
  79248. * A pose controlled object has both regular pose values as well as pose values
  79249. * from an external device such as a VR head mounted display
  79250. */
  79251. export interface PoseControlled {
  79252. /**
  79253. * The position of the object in babylon space.
  79254. */
  79255. position: Vector3;
  79256. /**
  79257. * The rotation quaternion of the object in babylon space.
  79258. */
  79259. rotationQuaternion: Quaternion;
  79260. /**
  79261. * The position of the device in babylon space.
  79262. */
  79263. devicePosition?: Vector3;
  79264. /**
  79265. * The rotation quaternion of the device in babylon space.
  79266. */
  79267. deviceRotationQuaternion: Quaternion;
  79268. /**
  79269. * The raw pose coming from the device.
  79270. */
  79271. rawPose: Nullable<DevicePose>;
  79272. /**
  79273. * The scale of the device to be used when translating from device space to babylon space.
  79274. */
  79275. deviceScaleFactor: number;
  79276. /**
  79277. * Updates the poseControlled values based on the input device pose.
  79278. * @param poseData the pose data to update the object with
  79279. */
  79280. updateFromDevice(poseData: DevicePose): void;
  79281. }
  79282. /**
  79283. * Set of options to customize the webVRCamera
  79284. */
  79285. export interface WebVROptions {
  79286. /**
  79287. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79288. */
  79289. trackPosition?: boolean;
  79290. /**
  79291. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79292. */
  79293. positionScale?: number;
  79294. /**
  79295. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79296. */
  79297. displayName?: string;
  79298. /**
  79299. * Should the native controller meshes be initialized. (default: true)
  79300. */
  79301. controllerMeshes?: boolean;
  79302. /**
  79303. * Creating a default HemiLight only on controllers. (default: true)
  79304. */
  79305. defaultLightingOnControllers?: boolean;
  79306. /**
  79307. * If you don't want to use the default VR button of the helper. (default: false)
  79308. */
  79309. useCustomVRButton?: boolean;
  79310. /**
  79311. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79312. */
  79313. customVRButton?: HTMLButtonElement;
  79314. /**
  79315. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79316. */
  79317. rayLength?: number;
  79318. /**
  79319. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79320. */
  79321. defaultHeight?: number;
  79322. /**
  79323. * If multiview should be used if availible (default: false)
  79324. */
  79325. useMultiview?: boolean;
  79326. }
  79327. /**
  79328. * This represents a WebVR camera.
  79329. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79330. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79331. */
  79332. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79333. private webVROptions;
  79334. /**
  79335. * @hidden
  79336. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79337. */
  79338. _vrDevice: any;
  79339. /**
  79340. * The rawPose of the vrDevice.
  79341. */
  79342. rawPose: Nullable<DevicePose>;
  79343. private _onVREnabled;
  79344. private _specsVersion;
  79345. private _attached;
  79346. private _frameData;
  79347. protected _descendants: Array<Node>;
  79348. private _deviceRoomPosition;
  79349. /** @hidden */
  79350. _deviceRoomRotationQuaternion: Quaternion;
  79351. private _standingMatrix;
  79352. /**
  79353. * Represents device position in babylon space.
  79354. */
  79355. devicePosition: Vector3;
  79356. /**
  79357. * Represents device rotation in babylon space.
  79358. */
  79359. deviceRotationQuaternion: Quaternion;
  79360. /**
  79361. * The scale of the device to be used when translating from device space to babylon space.
  79362. */
  79363. deviceScaleFactor: number;
  79364. private _deviceToWorld;
  79365. private _worldToDevice;
  79366. /**
  79367. * References to the webVR controllers for the vrDevice.
  79368. */
  79369. controllers: Array<WebVRController>;
  79370. /**
  79371. * Emits an event when a controller is attached.
  79372. */
  79373. onControllersAttachedObservable: Observable<WebVRController[]>;
  79374. /**
  79375. * Emits an event when a controller's mesh has been loaded;
  79376. */
  79377. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79378. /**
  79379. * Emits an event when the HMD's pose has been updated.
  79380. */
  79381. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79382. private _poseSet;
  79383. /**
  79384. * If the rig cameras be used as parent instead of this camera.
  79385. */
  79386. rigParenting: boolean;
  79387. private _lightOnControllers;
  79388. private _defaultHeight?;
  79389. /**
  79390. * Instantiates a WebVRFreeCamera.
  79391. * @param name The name of the WebVRFreeCamera
  79392. * @param position The starting anchor position for the camera
  79393. * @param scene The scene the camera belongs to
  79394. * @param webVROptions a set of customizable options for the webVRCamera
  79395. */
  79396. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79397. /**
  79398. * Gets the device distance from the ground in meters.
  79399. * @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.
  79400. */
  79401. deviceDistanceToRoomGround(): number;
  79402. /**
  79403. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79404. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79405. */
  79406. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79407. /**
  79408. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79409. * @returns A promise with a boolean set to if the standing matrix is supported.
  79410. */
  79411. useStandingMatrixAsync(): Promise<boolean>;
  79412. /**
  79413. * Disposes the camera
  79414. */
  79415. dispose(): void;
  79416. /**
  79417. * Gets a vrController by name.
  79418. * @param name The name of the controller to retreive
  79419. * @returns the controller matching the name specified or null if not found
  79420. */
  79421. getControllerByName(name: string): Nullable<WebVRController>;
  79422. private _leftController;
  79423. /**
  79424. * The controller corresponding to the users left hand.
  79425. */
  79426. readonly leftController: Nullable<WebVRController>;
  79427. private _rightController;
  79428. /**
  79429. * The controller corresponding to the users right hand.
  79430. */
  79431. readonly rightController: Nullable<WebVRController>;
  79432. /**
  79433. * Casts a ray forward from the vrCamera's gaze.
  79434. * @param length Length of the ray (default: 100)
  79435. * @returns the ray corresponding to the gaze
  79436. */
  79437. getForwardRay(length?: number): Ray;
  79438. /**
  79439. * @hidden
  79440. * Updates the camera based on device's frame data
  79441. */
  79442. _checkInputs(): void;
  79443. /**
  79444. * Updates the poseControlled values based on the input device pose.
  79445. * @param poseData Pose coming from the device
  79446. */
  79447. updateFromDevice(poseData: DevicePose): void;
  79448. private _htmlElementAttached;
  79449. private _detachIfAttached;
  79450. /**
  79451. * WebVR's attach control will start broadcasting frames to the device.
  79452. * Note that in certain browsers (chrome for example) this function must be called
  79453. * within a user-interaction callback. Example:
  79454. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79455. *
  79456. * @param element html element to attach the vrDevice to
  79457. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79458. */
  79459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79460. /**
  79461. * Detaches the camera from the html element and disables VR
  79462. *
  79463. * @param element html element to detach from
  79464. */
  79465. detachControl(element: HTMLElement): void;
  79466. /**
  79467. * @returns the name of this class
  79468. */
  79469. getClassName(): string;
  79470. /**
  79471. * Calls resetPose on the vrDisplay
  79472. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79473. */
  79474. resetToCurrentRotation(): void;
  79475. /**
  79476. * @hidden
  79477. * Updates the rig cameras (left and right eye)
  79478. */
  79479. _updateRigCameras(): void;
  79480. private _workingVector;
  79481. private _oneVector;
  79482. private _workingMatrix;
  79483. private updateCacheCalled;
  79484. private _correctPositionIfNotTrackPosition;
  79485. /**
  79486. * @hidden
  79487. * Updates the cached values of the camera
  79488. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79489. */
  79490. _updateCache(ignoreParentClass?: boolean): void;
  79491. /**
  79492. * @hidden
  79493. * Get current device position in babylon world
  79494. */
  79495. _computeDevicePosition(): void;
  79496. /**
  79497. * Updates the current device position and rotation in the babylon world
  79498. */
  79499. update(): void;
  79500. /**
  79501. * @hidden
  79502. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79503. * @returns an identity matrix
  79504. */
  79505. _getViewMatrix(): Matrix;
  79506. private _tmpMatrix;
  79507. /**
  79508. * This function is called by the two RIG cameras.
  79509. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79510. * @hidden
  79511. */
  79512. _getWebVRViewMatrix(): Matrix;
  79513. /** @hidden */
  79514. _getWebVRProjectionMatrix(): Matrix;
  79515. private _onGamepadConnectedObserver;
  79516. private _onGamepadDisconnectedObserver;
  79517. private _updateCacheWhenTrackingDisabledObserver;
  79518. /**
  79519. * Initializes the controllers and their meshes
  79520. */
  79521. initControllers(): void;
  79522. }
  79523. }
  79524. declare module BABYLON {
  79525. /**
  79526. * Size options for a post process
  79527. */
  79528. export type PostProcessOptions = {
  79529. width: number;
  79530. height: number;
  79531. };
  79532. /**
  79533. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79534. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79535. */
  79536. export class PostProcess {
  79537. /** Name of the PostProcess. */
  79538. name: string;
  79539. /**
  79540. * Gets or sets the unique id of the post process
  79541. */
  79542. uniqueId: number;
  79543. /**
  79544. * Width of the texture to apply the post process on
  79545. */
  79546. width: number;
  79547. /**
  79548. * Height of the texture to apply the post process on
  79549. */
  79550. height: number;
  79551. /**
  79552. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79553. * @hidden
  79554. */
  79555. _outputTexture: Nullable<InternalTexture>;
  79556. /**
  79557. * Sampling mode used by the shader
  79558. * See https://doc.babylonjs.com/classes/3.1/texture
  79559. */
  79560. renderTargetSamplingMode: number;
  79561. /**
  79562. * Clear color to use when screen clearing
  79563. */
  79564. clearColor: Color4;
  79565. /**
  79566. * If the buffer needs to be cleared before applying the post process. (default: true)
  79567. * Should be set to false if shader will overwrite all previous pixels.
  79568. */
  79569. autoClear: boolean;
  79570. /**
  79571. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79572. */
  79573. alphaMode: number;
  79574. /**
  79575. * Sets the setAlphaBlendConstants of the babylon engine
  79576. */
  79577. alphaConstants: Color4;
  79578. /**
  79579. * Animations to be used for the post processing
  79580. */
  79581. animations: Animation[];
  79582. /**
  79583. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79584. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79585. */
  79586. enablePixelPerfectMode: boolean;
  79587. /**
  79588. * Force the postprocess to be applied without taking in account viewport
  79589. */
  79590. forceFullscreenViewport: boolean;
  79591. /**
  79592. * List of inspectable custom properties (used by the Inspector)
  79593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79594. */
  79595. inspectableCustomProperties: IInspectable[];
  79596. /**
  79597. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79598. *
  79599. * | Value | Type | Description |
  79600. * | ----- | ----------------------------------- | ----------- |
  79601. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79602. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79603. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79604. *
  79605. */
  79606. scaleMode: number;
  79607. /**
  79608. * Force textures to be a power of two (default: false)
  79609. */
  79610. alwaysForcePOT: boolean;
  79611. private _samples;
  79612. /**
  79613. * Number of sample textures (default: 1)
  79614. */
  79615. samples: number;
  79616. /**
  79617. * Modify the scale of the post process to be the same as the viewport (default: false)
  79618. */
  79619. adaptScaleToCurrentViewport: boolean;
  79620. private _camera;
  79621. private _scene;
  79622. private _engine;
  79623. private _options;
  79624. private _reusable;
  79625. private _textureType;
  79626. /**
  79627. * Smart array of input and output textures for the post process.
  79628. * @hidden
  79629. */
  79630. _textures: SmartArray<InternalTexture>;
  79631. /**
  79632. * The index in _textures that corresponds to the output texture.
  79633. * @hidden
  79634. */
  79635. _currentRenderTextureInd: number;
  79636. private _effect;
  79637. private _samplers;
  79638. private _fragmentUrl;
  79639. private _vertexUrl;
  79640. private _parameters;
  79641. private _scaleRatio;
  79642. protected _indexParameters: any;
  79643. private _shareOutputWithPostProcess;
  79644. private _texelSize;
  79645. private _forcedOutputTexture;
  79646. /**
  79647. * Returns the fragment url or shader name used in the post process.
  79648. * @returns the fragment url or name in the shader store.
  79649. */
  79650. getEffectName(): string;
  79651. /**
  79652. * An event triggered when the postprocess is activated.
  79653. */
  79654. onActivateObservable: Observable<Camera>;
  79655. private _onActivateObserver;
  79656. /**
  79657. * A function that is added to the onActivateObservable
  79658. */
  79659. onActivate: Nullable<(camera: Camera) => void>;
  79660. /**
  79661. * An event triggered when the postprocess changes its size.
  79662. */
  79663. onSizeChangedObservable: Observable<PostProcess>;
  79664. private _onSizeChangedObserver;
  79665. /**
  79666. * A function that is added to the onSizeChangedObservable
  79667. */
  79668. onSizeChanged: (postProcess: PostProcess) => void;
  79669. /**
  79670. * An event triggered when the postprocess applies its effect.
  79671. */
  79672. onApplyObservable: Observable<Effect>;
  79673. private _onApplyObserver;
  79674. /**
  79675. * A function that is added to the onApplyObservable
  79676. */
  79677. onApply: (effect: Effect) => void;
  79678. /**
  79679. * An event triggered before rendering the postprocess
  79680. */
  79681. onBeforeRenderObservable: Observable<Effect>;
  79682. private _onBeforeRenderObserver;
  79683. /**
  79684. * A function that is added to the onBeforeRenderObservable
  79685. */
  79686. onBeforeRender: (effect: Effect) => void;
  79687. /**
  79688. * An event triggered after rendering the postprocess
  79689. */
  79690. onAfterRenderObservable: Observable<Effect>;
  79691. private _onAfterRenderObserver;
  79692. /**
  79693. * A function that is added to the onAfterRenderObservable
  79694. */
  79695. onAfterRender: (efect: Effect) => void;
  79696. /**
  79697. * 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
  79698. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79699. */
  79700. inputTexture: InternalTexture;
  79701. /**
  79702. * Gets the camera which post process is applied to.
  79703. * @returns The camera the post process is applied to.
  79704. */
  79705. getCamera(): Camera;
  79706. /**
  79707. * Gets the texel size of the postprocess.
  79708. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79709. */
  79710. readonly texelSize: Vector2;
  79711. /**
  79712. * Creates a new instance PostProcess
  79713. * @param name The name of the PostProcess.
  79714. * @param fragmentUrl The url of the fragment shader to be used.
  79715. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79716. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79718. * @param camera The camera to apply the render pass to.
  79719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79720. * @param engine The engine which the post process will be applied. (default: current engine)
  79721. * @param reusable If the post process can be reused on the same frame. (default: false)
  79722. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79723. * @param textureType Type of textures used when performing the post process. (default: 0)
  79724. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79725. * @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
  79726. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79727. */
  79728. constructor(
  79729. /** Name of the PostProcess. */
  79730. 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);
  79731. /**
  79732. * Gets a string idenfifying the name of the class
  79733. * @returns "PostProcess" string
  79734. */
  79735. getClassName(): string;
  79736. /**
  79737. * Gets the engine which this post process belongs to.
  79738. * @returns The engine the post process was enabled with.
  79739. */
  79740. getEngine(): Engine;
  79741. /**
  79742. * The effect that is created when initializing the post process.
  79743. * @returns The created effect corresponding the the postprocess.
  79744. */
  79745. getEffect(): Effect;
  79746. /**
  79747. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79748. * @param postProcess The post process to share the output with.
  79749. * @returns This post process.
  79750. */
  79751. shareOutputWith(postProcess: PostProcess): PostProcess;
  79752. /**
  79753. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79754. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79755. */
  79756. useOwnOutput(): void;
  79757. /**
  79758. * Updates the effect with the current post process compile time values and recompiles the shader.
  79759. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79760. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79761. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79762. * @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
  79763. * @param onCompiled Called when the shader has been compiled.
  79764. * @param onError Called if there is an error when compiling a shader.
  79765. */
  79766. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79767. /**
  79768. * The post process is reusable if it can be used multiple times within one frame.
  79769. * @returns If the post process is reusable
  79770. */
  79771. isReusable(): boolean;
  79772. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79773. markTextureDirty(): void;
  79774. /**
  79775. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79776. * 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.
  79777. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79778. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79779. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79780. * @returns The target texture that was bound to be written to.
  79781. */
  79782. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79783. /**
  79784. * If the post process is supported.
  79785. */
  79786. readonly isSupported: boolean;
  79787. /**
  79788. * The aspect ratio of the output texture.
  79789. */
  79790. readonly aspectRatio: number;
  79791. /**
  79792. * Get a value indicating if the post-process is ready to be used
  79793. * @returns true if the post-process is ready (shader is compiled)
  79794. */
  79795. isReady(): boolean;
  79796. /**
  79797. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79798. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79799. */
  79800. apply(): Nullable<Effect>;
  79801. private _disposeTextures;
  79802. /**
  79803. * Disposes the post process.
  79804. * @param camera The camera to dispose the post process on.
  79805. */
  79806. dispose(camera?: Camera): void;
  79807. }
  79808. }
  79809. declare module BABYLON {
  79810. /** @hidden */
  79811. export var kernelBlurVaryingDeclaration: {
  79812. name: string;
  79813. shader: string;
  79814. };
  79815. }
  79816. declare module BABYLON {
  79817. /** @hidden */
  79818. export var kernelBlurFragment: {
  79819. name: string;
  79820. shader: string;
  79821. };
  79822. }
  79823. declare module BABYLON {
  79824. /** @hidden */
  79825. export var kernelBlurFragment2: {
  79826. name: string;
  79827. shader: string;
  79828. };
  79829. }
  79830. declare module BABYLON {
  79831. /** @hidden */
  79832. export var kernelBlurPixelShader: {
  79833. name: string;
  79834. shader: string;
  79835. };
  79836. }
  79837. declare module BABYLON {
  79838. /** @hidden */
  79839. export var kernelBlurVertex: {
  79840. name: string;
  79841. shader: string;
  79842. };
  79843. }
  79844. declare module BABYLON {
  79845. /** @hidden */
  79846. export var kernelBlurVertexShader: {
  79847. name: string;
  79848. shader: string;
  79849. };
  79850. }
  79851. declare module BABYLON {
  79852. /**
  79853. * The Blur Post Process which blurs an image based on a kernel and direction.
  79854. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79855. */
  79856. export class BlurPostProcess extends PostProcess {
  79857. /** The direction in which to blur the image. */
  79858. direction: Vector2;
  79859. private blockCompilation;
  79860. protected _kernel: number;
  79861. protected _idealKernel: number;
  79862. protected _packedFloat: boolean;
  79863. private _staticDefines;
  79864. /**
  79865. * Sets the length in pixels of the blur sample region
  79866. */
  79867. /**
  79868. * Gets the length in pixels of the blur sample region
  79869. */
  79870. kernel: number;
  79871. /**
  79872. * Sets wether or not the blur needs to unpack/repack floats
  79873. */
  79874. /**
  79875. * Gets wether or not the blur is unpacking/repacking floats
  79876. */
  79877. packedFloat: boolean;
  79878. /**
  79879. * Creates a new instance BlurPostProcess
  79880. * @param name The name of the effect.
  79881. * @param direction The direction in which to blur the image.
  79882. * @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.
  79883. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79884. * @param camera The camera to apply the render pass to.
  79885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79886. * @param engine The engine which the post process will be applied. (default: current engine)
  79887. * @param reusable If the post process can be reused on the same frame. (default: false)
  79888. * @param textureType Type of textures used when performing the post process. (default: 0)
  79889. * @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)
  79890. */
  79891. constructor(name: string,
  79892. /** The direction in which to blur the image. */
  79893. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79894. /**
  79895. * Updates the effect with the current post process compile time values and recompiles the shader.
  79896. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79897. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79898. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79899. * @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
  79900. * @param onCompiled Called when the shader has been compiled.
  79901. * @param onError Called if there is an error when compiling a shader.
  79902. */
  79903. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79904. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79905. /**
  79906. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79907. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79908. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79909. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79910. * The gaps between physical kernels are compensated for in the weighting of the samples
  79911. * @param idealKernel Ideal blur kernel.
  79912. * @return Nearest best kernel.
  79913. */
  79914. protected _nearestBestKernel(idealKernel: number): number;
  79915. /**
  79916. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79917. * @param x The point on the Gaussian distribution to sample.
  79918. * @return the value of the Gaussian function at x.
  79919. */
  79920. protected _gaussianWeight(x: number): number;
  79921. /**
  79922. * Generates a string that can be used as a floating point number in GLSL.
  79923. * @param x Value to print.
  79924. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79925. * @return GLSL float string.
  79926. */
  79927. protected _glslFloat(x: number, decimalFigures?: number): string;
  79928. }
  79929. }
  79930. declare module BABYLON {
  79931. /**
  79932. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79933. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79934. * You can then easily use it as a reflectionTexture on a flat surface.
  79935. * In case the surface is not a plane, please consider relying on reflection probes.
  79936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79937. */
  79938. export class MirrorTexture extends RenderTargetTexture {
  79939. private scene;
  79940. /**
  79941. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79942. * 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.
  79943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79944. */
  79945. mirrorPlane: Plane;
  79946. /**
  79947. * Define the blur ratio used to blur the reflection if needed.
  79948. */
  79949. blurRatio: number;
  79950. /**
  79951. * Define the adaptive blur kernel used to blur the reflection if needed.
  79952. * This will autocompute the closest best match for the `blurKernel`
  79953. */
  79954. adaptiveBlurKernel: number;
  79955. /**
  79956. * Define the blur kernel used to blur the reflection if needed.
  79957. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79958. */
  79959. blurKernel: number;
  79960. /**
  79961. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79962. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79963. */
  79964. blurKernelX: number;
  79965. /**
  79966. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79968. */
  79969. blurKernelY: number;
  79970. private _autoComputeBlurKernel;
  79971. protected _onRatioRescale(): void;
  79972. private _updateGammaSpace;
  79973. private _imageProcessingConfigChangeObserver;
  79974. private _transformMatrix;
  79975. private _mirrorMatrix;
  79976. private _savedViewMatrix;
  79977. private _blurX;
  79978. private _blurY;
  79979. private _adaptiveBlurKernel;
  79980. private _blurKernelX;
  79981. private _blurKernelY;
  79982. private _blurRatio;
  79983. /**
  79984. * Instantiates a Mirror Texture.
  79985. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79986. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79987. * You can then easily use it as a reflectionTexture on a flat surface.
  79988. * In case the surface is not a plane, please consider relying on reflection probes.
  79989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79990. * @param name
  79991. * @param size
  79992. * @param scene
  79993. * @param generateMipMaps
  79994. * @param type
  79995. * @param samplingMode
  79996. * @param generateDepthBuffer
  79997. */
  79998. constructor(name: string, size: number | {
  79999. width: number;
  80000. height: number;
  80001. } | {
  80002. ratio: number;
  80003. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80004. private _preparePostProcesses;
  80005. /**
  80006. * Clone the mirror texture.
  80007. * @returns the cloned texture
  80008. */
  80009. clone(): MirrorTexture;
  80010. /**
  80011. * Serialize the texture to a JSON representation you could use in Parse later on
  80012. * @returns the serialized JSON representation
  80013. */
  80014. serialize(): any;
  80015. /**
  80016. * Dispose the texture and release its associated resources.
  80017. */
  80018. dispose(): void;
  80019. }
  80020. }
  80021. declare module BABYLON {
  80022. /**
  80023. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80024. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80025. */
  80026. export class Texture extends BaseTexture {
  80027. /** @hidden */
  80028. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80029. /** @hidden */
  80030. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80031. /** @hidden */
  80032. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80033. /** nearest is mag = nearest and min = nearest and mip = linear */
  80034. static readonly NEAREST_SAMPLINGMODE: number;
  80035. /** nearest is mag = nearest and min = nearest and mip = linear */
  80036. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80038. static readonly BILINEAR_SAMPLINGMODE: number;
  80039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80040. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80041. /** Trilinear is mag = linear and min = linear and mip = linear */
  80042. static readonly TRILINEAR_SAMPLINGMODE: number;
  80043. /** Trilinear is mag = linear and min = linear and mip = linear */
  80044. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80045. /** mag = nearest and min = nearest and mip = nearest */
  80046. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80047. /** mag = nearest and min = linear and mip = nearest */
  80048. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80049. /** mag = nearest and min = linear and mip = linear */
  80050. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80051. /** mag = nearest and min = linear and mip = none */
  80052. static readonly NEAREST_LINEAR: number;
  80053. /** mag = nearest and min = nearest and mip = none */
  80054. static readonly NEAREST_NEAREST: number;
  80055. /** mag = linear and min = nearest and mip = nearest */
  80056. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80057. /** mag = linear and min = nearest and mip = linear */
  80058. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80059. /** mag = linear and min = linear and mip = none */
  80060. static readonly LINEAR_LINEAR: number;
  80061. /** mag = linear and min = nearest and mip = none */
  80062. static readonly LINEAR_NEAREST: number;
  80063. /** Explicit coordinates mode */
  80064. static readonly EXPLICIT_MODE: number;
  80065. /** Spherical coordinates mode */
  80066. static readonly SPHERICAL_MODE: number;
  80067. /** Planar coordinates mode */
  80068. static readonly PLANAR_MODE: number;
  80069. /** Cubic coordinates mode */
  80070. static readonly CUBIC_MODE: number;
  80071. /** Projection coordinates mode */
  80072. static readonly PROJECTION_MODE: number;
  80073. /** Inverse Cubic coordinates mode */
  80074. static readonly SKYBOX_MODE: number;
  80075. /** Inverse Cubic coordinates mode */
  80076. static readonly INVCUBIC_MODE: number;
  80077. /** Equirectangular coordinates mode */
  80078. static readonly EQUIRECTANGULAR_MODE: number;
  80079. /** Equirectangular Fixed coordinates mode */
  80080. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80081. /** Equirectangular Fixed Mirrored coordinates mode */
  80082. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80083. /** Texture is not repeating outside of 0..1 UVs */
  80084. static readonly CLAMP_ADDRESSMODE: number;
  80085. /** Texture is repeating outside of 0..1 UVs */
  80086. static readonly WRAP_ADDRESSMODE: number;
  80087. /** Texture is repeating and mirrored */
  80088. static readonly MIRROR_ADDRESSMODE: number;
  80089. /**
  80090. * 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
  80091. */
  80092. static UseSerializedUrlIfAny: boolean;
  80093. /**
  80094. * Define the url of the texture.
  80095. */
  80096. url: Nullable<string>;
  80097. /**
  80098. * Define an offset on the texture to offset the u coordinates of the UVs
  80099. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80100. */
  80101. uOffset: number;
  80102. /**
  80103. * Define an offset on the texture to offset the v coordinates of the UVs
  80104. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80105. */
  80106. vOffset: number;
  80107. /**
  80108. * Define an offset on the texture to scale the u coordinates of the UVs
  80109. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80110. */
  80111. uScale: number;
  80112. /**
  80113. * Define an offset on the texture to scale the v coordinates of the UVs
  80114. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80115. */
  80116. vScale: number;
  80117. /**
  80118. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80119. * @see http://doc.babylonjs.com/how_to/more_materials
  80120. */
  80121. uAng: number;
  80122. /**
  80123. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80124. * @see http://doc.babylonjs.com/how_to/more_materials
  80125. */
  80126. vAng: number;
  80127. /**
  80128. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80129. * @see http://doc.babylonjs.com/how_to/more_materials
  80130. */
  80131. wAng: number;
  80132. /**
  80133. * Defines the center of rotation (U)
  80134. */
  80135. uRotationCenter: number;
  80136. /**
  80137. * Defines the center of rotation (V)
  80138. */
  80139. vRotationCenter: number;
  80140. /**
  80141. * Defines the center of rotation (W)
  80142. */
  80143. wRotationCenter: number;
  80144. /**
  80145. * Are mip maps generated for this texture or not.
  80146. */
  80147. readonly noMipmap: boolean;
  80148. /**
  80149. * List of inspectable custom properties (used by the Inspector)
  80150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80151. */
  80152. inspectableCustomProperties: Nullable<IInspectable[]>;
  80153. private _noMipmap;
  80154. /** @hidden */
  80155. _invertY: boolean;
  80156. private _rowGenerationMatrix;
  80157. private _cachedTextureMatrix;
  80158. private _projectionModeMatrix;
  80159. private _t0;
  80160. private _t1;
  80161. private _t2;
  80162. private _cachedUOffset;
  80163. private _cachedVOffset;
  80164. private _cachedUScale;
  80165. private _cachedVScale;
  80166. private _cachedUAng;
  80167. private _cachedVAng;
  80168. private _cachedWAng;
  80169. private _cachedProjectionMatrixId;
  80170. private _cachedCoordinatesMode;
  80171. /** @hidden */
  80172. protected _initialSamplingMode: number;
  80173. /** @hidden */
  80174. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80175. private _deleteBuffer;
  80176. protected _format: Nullable<number>;
  80177. private _delayedOnLoad;
  80178. private _delayedOnError;
  80179. /**
  80180. * Observable triggered once the texture has been loaded.
  80181. */
  80182. onLoadObservable: Observable<Texture>;
  80183. protected _isBlocking: boolean;
  80184. /**
  80185. * Is the texture preventing material to render while loading.
  80186. * If false, a default texture will be used instead of the loading one during the preparation step.
  80187. */
  80188. isBlocking: boolean;
  80189. /**
  80190. * Get the current sampling mode associated with the texture.
  80191. */
  80192. readonly samplingMode: number;
  80193. /**
  80194. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80195. */
  80196. readonly invertY: boolean;
  80197. /**
  80198. * Instantiates a new texture.
  80199. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80200. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80201. * @param url define the url of the picture to load as a texture
  80202. * @param scene define the scene or engine the texture will belong to
  80203. * @param noMipmap define if the texture will require mip maps or not
  80204. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80205. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80206. * @param onLoad define a callback triggered when the texture has been loaded
  80207. * @param onError define a callback triggered when an error occurred during the loading session
  80208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80209. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80210. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80211. */
  80212. 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);
  80213. /**
  80214. * Update the url (and optional buffer) of this texture if url was null during construction.
  80215. * @param url the url of the texture
  80216. * @param buffer the buffer of the texture (defaults to null)
  80217. * @param onLoad callback called when the texture is loaded (defaults to null)
  80218. */
  80219. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80220. /**
  80221. * Finish the loading sequence of a texture flagged as delayed load.
  80222. * @hidden
  80223. */
  80224. delayLoad(): void;
  80225. private _prepareRowForTextureGeneration;
  80226. /**
  80227. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80228. * @returns the transform matrix of the texture.
  80229. */
  80230. getTextureMatrix(): Matrix;
  80231. /**
  80232. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80233. * @returns The reflection texture transform
  80234. */
  80235. getReflectionTextureMatrix(): Matrix;
  80236. /**
  80237. * Clones the texture.
  80238. * @returns the cloned texture
  80239. */
  80240. clone(): Texture;
  80241. /**
  80242. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80243. * @returns The JSON representation of the texture
  80244. */
  80245. serialize(): any;
  80246. /**
  80247. * Get the current class name of the texture useful for serialization or dynamic coding.
  80248. * @returns "Texture"
  80249. */
  80250. getClassName(): string;
  80251. /**
  80252. * Dispose the texture and release its associated resources.
  80253. */
  80254. dispose(): void;
  80255. /**
  80256. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80257. * @param parsedTexture Define the JSON representation of the texture
  80258. * @param scene Define the scene the parsed texture should be instantiated in
  80259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80260. * @returns The parsed texture if successful
  80261. */
  80262. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80263. /**
  80264. * Creates a texture from its base 64 representation.
  80265. * @param data Define the base64 payload without the data: prefix
  80266. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80267. * @param scene Define the scene the texture should belong to
  80268. * @param noMipmap Forces the texture to not create mip map information if true
  80269. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80270. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80271. * @param onLoad define a callback triggered when the texture has been loaded
  80272. * @param onError define a callback triggered when an error occurred during the loading session
  80273. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80274. * @returns the created texture
  80275. */
  80276. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80277. /**
  80278. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80279. * @param data Define the base64 payload without the data: prefix
  80280. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80281. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80282. * @param scene Define the scene the texture should belong to
  80283. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80284. * @param noMipmap Forces the texture to not create mip map information if true
  80285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80287. * @param onLoad define a callback triggered when the texture has been loaded
  80288. * @param onError define a callback triggered when an error occurred during the loading session
  80289. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80290. * @returns the created texture
  80291. */
  80292. 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;
  80293. }
  80294. }
  80295. declare module BABYLON {
  80296. /**
  80297. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80298. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80299. */
  80300. export class PostProcessManager {
  80301. private _scene;
  80302. private _indexBuffer;
  80303. private _vertexBuffers;
  80304. /**
  80305. * Creates a new instance PostProcess
  80306. * @param scene The scene that the post process is associated with.
  80307. */
  80308. constructor(scene: Scene);
  80309. private _prepareBuffers;
  80310. private _buildIndexBuffer;
  80311. /**
  80312. * Rebuilds the vertex buffers of the manager.
  80313. * @hidden
  80314. */
  80315. _rebuild(): void;
  80316. /**
  80317. * Prepares a frame to be run through a post process.
  80318. * @param sourceTexture The input texture to the post procesess. (default: null)
  80319. * @param postProcesses An array of post processes to be run. (default: null)
  80320. * @returns True if the post processes were able to be run.
  80321. * @hidden
  80322. */
  80323. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80324. /**
  80325. * Manually render a set of post processes to a texture.
  80326. * @param postProcesses An array of post processes to be run.
  80327. * @param targetTexture The target texture to render to.
  80328. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80329. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80330. * @param lodLevel defines which lod of the texture to render to
  80331. */
  80332. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80333. /**
  80334. * Finalize the result of the output of the postprocesses.
  80335. * @param doNotPresent If true the result will not be displayed to the screen.
  80336. * @param targetTexture The target texture to render to.
  80337. * @param faceIndex The index of the face to bind the target texture to.
  80338. * @param postProcesses The array of post processes to render.
  80339. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80340. * @hidden
  80341. */
  80342. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80343. /**
  80344. * Disposes of the post process manager.
  80345. */
  80346. dispose(): void;
  80347. }
  80348. }
  80349. declare module BABYLON {
  80350. /** Interface used by value gradients (color, factor, ...) */
  80351. export interface IValueGradient {
  80352. /**
  80353. * Gets or sets the gradient value (between 0 and 1)
  80354. */
  80355. gradient: number;
  80356. }
  80357. /** Class used to store color4 gradient */
  80358. export class ColorGradient implements IValueGradient {
  80359. /**
  80360. * Gets or sets the gradient value (between 0 and 1)
  80361. */
  80362. gradient: number;
  80363. /**
  80364. * Gets or sets first associated color
  80365. */
  80366. color1: Color4;
  80367. /**
  80368. * Gets or sets second associated color
  80369. */
  80370. color2?: Color4;
  80371. /**
  80372. * Will get a color picked randomly between color1 and color2.
  80373. * If color2 is undefined then color1 will be used
  80374. * @param result defines the target Color4 to store the result in
  80375. */
  80376. getColorToRef(result: Color4): void;
  80377. }
  80378. /** Class used to store color 3 gradient */
  80379. export class Color3Gradient implements IValueGradient {
  80380. /**
  80381. * Gets or sets the gradient value (between 0 and 1)
  80382. */
  80383. gradient: number;
  80384. /**
  80385. * Gets or sets the associated color
  80386. */
  80387. color: Color3;
  80388. }
  80389. /** Class used to store factor gradient */
  80390. export class FactorGradient implements IValueGradient {
  80391. /**
  80392. * Gets or sets the gradient value (between 0 and 1)
  80393. */
  80394. gradient: number;
  80395. /**
  80396. * Gets or sets first associated factor
  80397. */
  80398. factor1: number;
  80399. /**
  80400. * Gets or sets second associated factor
  80401. */
  80402. factor2?: number;
  80403. /**
  80404. * Will get a number picked randomly between factor1 and factor2.
  80405. * If factor2 is undefined then factor1 will be used
  80406. * @returns the picked number
  80407. */
  80408. getFactor(): number;
  80409. }
  80410. /**
  80411. * Helper used to simplify some generic gradient tasks
  80412. */
  80413. export class GradientHelper {
  80414. /**
  80415. * Gets the current gradient from an array of IValueGradient
  80416. * @param ratio defines the current ratio to get
  80417. * @param gradients defines the array of IValueGradient
  80418. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80419. */
  80420. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80421. }
  80422. }
  80423. declare module BABYLON {
  80424. interface AbstractScene {
  80425. /**
  80426. * The list of procedural textures added to the scene
  80427. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80428. */
  80429. proceduralTextures: Array<ProceduralTexture>;
  80430. }
  80431. /**
  80432. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80433. * in a given scene.
  80434. */
  80435. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80436. /**
  80437. * The component name helpfull to identify the component in the list of scene components.
  80438. */
  80439. readonly name: string;
  80440. /**
  80441. * The scene the component belongs to.
  80442. */
  80443. scene: Scene;
  80444. /**
  80445. * Creates a new instance of the component for the given scene
  80446. * @param scene Defines the scene to register the component in
  80447. */
  80448. constructor(scene: Scene);
  80449. /**
  80450. * Registers the component in a given scene
  80451. */
  80452. register(): void;
  80453. /**
  80454. * Rebuilds the elements related to this component in case of
  80455. * context lost for instance.
  80456. */
  80457. rebuild(): void;
  80458. /**
  80459. * Disposes the component and the associated ressources.
  80460. */
  80461. dispose(): void;
  80462. private _beforeClear;
  80463. }
  80464. }
  80465. declare module BABYLON {
  80466. interface Engine {
  80467. /**
  80468. * Creates a new render target cube texture
  80469. * @param size defines the size of the texture
  80470. * @param options defines the options used to create the texture
  80471. * @returns a new render target cube texture stored in an InternalTexture
  80472. */
  80473. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80474. }
  80475. }
  80476. declare module BABYLON {
  80477. /** @hidden */
  80478. export var proceduralVertexShader: {
  80479. name: string;
  80480. shader: string;
  80481. };
  80482. }
  80483. declare module BABYLON {
  80484. /**
  80485. * 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.
  80486. * This is the base class of any Procedural texture and contains most of the shareable code.
  80487. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80488. */
  80489. export class ProceduralTexture extends Texture {
  80490. isCube: boolean;
  80491. /**
  80492. * Define if the texture is enabled or not (disabled texture will not render)
  80493. */
  80494. isEnabled: boolean;
  80495. /**
  80496. * Define if the texture must be cleared before rendering (default is true)
  80497. */
  80498. autoClear: boolean;
  80499. /**
  80500. * Callback called when the texture is generated
  80501. */
  80502. onGenerated: () => void;
  80503. /**
  80504. * Event raised when the texture is generated
  80505. */
  80506. onGeneratedObservable: Observable<ProceduralTexture>;
  80507. /** @hidden */
  80508. _generateMipMaps: boolean;
  80509. /** @hidden **/
  80510. _effect: Effect;
  80511. /** @hidden */
  80512. _textures: {
  80513. [key: string]: Texture;
  80514. };
  80515. private _size;
  80516. private _currentRefreshId;
  80517. private _refreshRate;
  80518. private _vertexBuffers;
  80519. private _indexBuffer;
  80520. private _uniforms;
  80521. private _samplers;
  80522. private _fragment;
  80523. private _floats;
  80524. private _ints;
  80525. private _floatsArrays;
  80526. private _colors3;
  80527. private _colors4;
  80528. private _vectors2;
  80529. private _vectors3;
  80530. private _matrices;
  80531. private _fallbackTexture;
  80532. private _fallbackTextureUsed;
  80533. private _engine;
  80534. private _cachedDefines;
  80535. private _contentUpdateId;
  80536. private _contentData;
  80537. /**
  80538. * Instantiates a new procedural texture.
  80539. * 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.
  80540. * This is the base class of any Procedural texture and contains most of the shareable code.
  80541. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80542. * @param name Define the name of the texture
  80543. * @param size Define the size of the texture to create
  80544. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80545. * @param scene Define the scene the texture belongs to
  80546. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80547. * @param generateMipMaps Define if the texture should creates mip maps or not
  80548. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80549. */
  80550. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80551. /**
  80552. * The effect that is created when initializing the post process.
  80553. * @returns The created effect corresponding the the postprocess.
  80554. */
  80555. getEffect(): Effect;
  80556. /**
  80557. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80558. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80559. */
  80560. getContent(): Nullable<ArrayBufferView>;
  80561. private _createIndexBuffer;
  80562. /** @hidden */
  80563. _rebuild(): void;
  80564. /**
  80565. * Resets the texture in order to recreate its associated resources.
  80566. * This can be called in case of context loss
  80567. */
  80568. reset(): void;
  80569. protected _getDefines(): string;
  80570. /**
  80571. * Is the texture ready to be used ? (rendered at least once)
  80572. * @returns true if ready, otherwise, false.
  80573. */
  80574. isReady(): boolean;
  80575. /**
  80576. * Resets the refresh counter of the texture and start bak from scratch.
  80577. * Could be useful to regenerate the texture if it is setup to render only once.
  80578. */
  80579. resetRefreshCounter(): void;
  80580. /**
  80581. * Set the fragment shader to use in order to render the texture.
  80582. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80583. */
  80584. setFragment(fragment: any): void;
  80585. /**
  80586. * Define the refresh rate of the texture or the rendering frequency.
  80587. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80588. */
  80589. refreshRate: number;
  80590. /** @hidden */
  80591. _shouldRender(): boolean;
  80592. /**
  80593. * Get the size the texture is rendering at.
  80594. * @returns the size (texture is always squared)
  80595. */
  80596. getRenderSize(): number;
  80597. /**
  80598. * Resize the texture to new value.
  80599. * @param size Define the new size the texture should have
  80600. * @param generateMipMaps Define whether the new texture should create mip maps
  80601. */
  80602. resize(size: number, generateMipMaps: boolean): void;
  80603. private _checkUniform;
  80604. /**
  80605. * Set a texture in the shader program used to render.
  80606. * @param name Define the name of the uniform samplers as defined in the shader
  80607. * @param texture Define the texture to bind to this sampler
  80608. * @return the texture itself allowing "fluent" like uniform updates
  80609. */
  80610. setTexture(name: string, texture: Texture): ProceduralTexture;
  80611. /**
  80612. * Set a float in the shader.
  80613. * @param name Define the name of the uniform as defined in the shader
  80614. * @param value Define the value to give to the uniform
  80615. * @return the texture itself allowing "fluent" like uniform updates
  80616. */
  80617. setFloat(name: string, value: number): ProceduralTexture;
  80618. /**
  80619. * Set a int in the shader.
  80620. * @param name Define the name of the uniform as defined in the shader
  80621. * @param value Define the value to give to the uniform
  80622. * @return the texture itself allowing "fluent" like uniform updates
  80623. */
  80624. setInt(name: string, value: number): ProceduralTexture;
  80625. /**
  80626. * Set an array of floats in the shader.
  80627. * @param name Define the name of the uniform as defined in the shader
  80628. * @param value Define the value to give to the uniform
  80629. * @return the texture itself allowing "fluent" like uniform updates
  80630. */
  80631. setFloats(name: string, value: number[]): ProceduralTexture;
  80632. /**
  80633. * Set a vec3 in the shader from a Color3.
  80634. * @param name Define the name of the uniform as defined in the shader
  80635. * @param value Define the value to give to the uniform
  80636. * @return the texture itself allowing "fluent" like uniform updates
  80637. */
  80638. setColor3(name: string, value: Color3): ProceduralTexture;
  80639. /**
  80640. * Set a vec4 in the shader from a Color4.
  80641. * @param name Define the name of the uniform as defined in the shader
  80642. * @param value Define the value to give to the uniform
  80643. * @return the texture itself allowing "fluent" like uniform updates
  80644. */
  80645. setColor4(name: string, value: Color4): ProceduralTexture;
  80646. /**
  80647. * Set a vec2 in the shader from a Vector2.
  80648. * @param name Define the name of the uniform as defined in the shader
  80649. * @param value Define the value to give to the uniform
  80650. * @return the texture itself allowing "fluent" like uniform updates
  80651. */
  80652. setVector2(name: string, value: Vector2): ProceduralTexture;
  80653. /**
  80654. * Set a vec3 in the shader from a Vector3.
  80655. * @param name Define the name of the uniform as defined in the shader
  80656. * @param value Define the value to give to the uniform
  80657. * @return the texture itself allowing "fluent" like uniform updates
  80658. */
  80659. setVector3(name: string, value: Vector3): ProceduralTexture;
  80660. /**
  80661. * Set a mat4 in the shader from a MAtrix.
  80662. * @param name Define the name of the uniform as defined in the shader
  80663. * @param value Define the value to give to the uniform
  80664. * @return the texture itself allowing "fluent" like uniform updates
  80665. */
  80666. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80667. /**
  80668. * Render the texture to its associated render target.
  80669. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80670. */
  80671. render(useCameraPostProcess?: boolean): void;
  80672. /**
  80673. * Clone the texture.
  80674. * @returns the cloned texture
  80675. */
  80676. clone(): ProceduralTexture;
  80677. /**
  80678. * Dispose the texture and release its asoociated resources.
  80679. */
  80680. dispose(): void;
  80681. }
  80682. }
  80683. declare module BABYLON {
  80684. /**
  80685. * This represents the base class for particle system in Babylon.
  80686. * 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.
  80687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80688. * @example https://doc.babylonjs.com/babylon101/particles
  80689. */
  80690. export class BaseParticleSystem {
  80691. /**
  80692. * Source color is added to the destination color without alpha affecting the result
  80693. */
  80694. static BLENDMODE_ONEONE: number;
  80695. /**
  80696. * Blend current color and particle color using particle’s alpha
  80697. */
  80698. static BLENDMODE_STANDARD: number;
  80699. /**
  80700. * Add current color and particle color multiplied by particle’s alpha
  80701. */
  80702. static BLENDMODE_ADD: number;
  80703. /**
  80704. * Multiply current color with particle color
  80705. */
  80706. static BLENDMODE_MULTIPLY: number;
  80707. /**
  80708. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80709. */
  80710. static BLENDMODE_MULTIPLYADD: number;
  80711. /**
  80712. * List of animations used by the particle system.
  80713. */
  80714. animations: Animation[];
  80715. /**
  80716. * The id of the Particle system.
  80717. */
  80718. id: string;
  80719. /**
  80720. * The friendly name of the Particle system.
  80721. */
  80722. name: string;
  80723. /**
  80724. * The rendering group used by the Particle system to chose when to render.
  80725. */
  80726. renderingGroupId: number;
  80727. /**
  80728. * The emitter represents the Mesh or position we are attaching the particle system to.
  80729. */
  80730. emitter: Nullable<AbstractMesh | Vector3>;
  80731. /**
  80732. * The maximum number of particles to emit per frame
  80733. */
  80734. emitRate: number;
  80735. /**
  80736. * If you want to launch only a few particles at once, that can be done, as well.
  80737. */
  80738. manualEmitCount: number;
  80739. /**
  80740. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80741. */
  80742. updateSpeed: number;
  80743. /**
  80744. * The amount of time the particle system is running (depends of the overall update speed).
  80745. */
  80746. targetStopDuration: number;
  80747. /**
  80748. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80749. */
  80750. disposeOnStop: boolean;
  80751. /**
  80752. * Minimum power of emitting particles.
  80753. */
  80754. minEmitPower: number;
  80755. /**
  80756. * Maximum power of emitting particles.
  80757. */
  80758. maxEmitPower: number;
  80759. /**
  80760. * Minimum life time of emitting particles.
  80761. */
  80762. minLifeTime: number;
  80763. /**
  80764. * Maximum life time of emitting particles.
  80765. */
  80766. maxLifeTime: number;
  80767. /**
  80768. * Minimum Size of emitting particles.
  80769. */
  80770. minSize: number;
  80771. /**
  80772. * Maximum Size of emitting particles.
  80773. */
  80774. maxSize: number;
  80775. /**
  80776. * Minimum scale of emitting particles on X axis.
  80777. */
  80778. minScaleX: number;
  80779. /**
  80780. * Maximum scale of emitting particles on X axis.
  80781. */
  80782. maxScaleX: number;
  80783. /**
  80784. * Minimum scale of emitting particles on Y axis.
  80785. */
  80786. minScaleY: number;
  80787. /**
  80788. * Maximum scale of emitting particles on Y axis.
  80789. */
  80790. maxScaleY: number;
  80791. /**
  80792. * Gets or sets the minimal initial rotation in radians.
  80793. */
  80794. minInitialRotation: number;
  80795. /**
  80796. * Gets or sets the maximal initial rotation in radians.
  80797. */
  80798. maxInitialRotation: number;
  80799. /**
  80800. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80801. */
  80802. minAngularSpeed: number;
  80803. /**
  80804. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80805. */
  80806. maxAngularSpeed: number;
  80807. /**
  80808. * The texture used to render each particle. (this can be a spritesheet)
  80809. */
  80810. particleTexture: Nullable<Texture>;
  80811. /**
  80812. * The layer mask we are rendering the particles through.
  80813. */
  80814. layerMask: number;
  80815. /**
  80816. * This can help using your own shader to render the particle system.
  80817. * The according effect will be created
  80818. */
  80819. customShader: any;
  80820. /**
  80821. * By default particle system starts as soon as they are created. This prevents the
  80822. * automatic start to happen and let you decide when to start emitting particles.
  80823. */
  80824. preventAutoStart: boolean;
  80825. private _noiseTexture;
  80826. /**
  80827. * Gets or sets a texture used to add random noise to particle positions
  80828. */
  80829. noiseTexture: Nullable<ProceduralTexture>;
  80830. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80831. noiseStrength: Vector3;
  80832. /**
  80833. * Callback triggered when the particle animation is ending.
  80834. */
  80835. onAnimationEnd: Nullable<() => void>;
  80836. /**
  80837. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80838. */
  80839. blendMode: number;
  80840. /**
  80841. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80842. * to override the particles.
  80843. */
  80844. forceDepthWrite: boolean;
  80845. /** 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 */
  80846. preWarmCycles: number;
  80847. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80848. preWarmStepOffset: number;
  80849. /**
  80850. * 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)
  80851. */
  80852. spriteCellChangeSpeed: number;
  80853. /**
  80854. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80855. */
  80856. startSpriteCellID: number;
  80857. /**
  80858. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80859. */
  80860. endSpriteCellID: number;
  80861. /**
  80862. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80863. */
  80864. spriteCellWidth: number;
  80865. /**
  80866. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80867. */
  80868. spriteCellHeight: number;
  80869. /**
  80870. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80871. */
  80872. spriteRandomStartCell: boolean;
  80873. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80874. translationPivot: Vector2;
  80875. /** @hidden */
  80876. protected _isAnimationSheetEnabled: boolean;
  80877. /**
  80878. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80879. */
  80880. beginAnimationOnStart: boolean;
  80881. /**
  80882. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80883. */
  80884. beginAnimationFrom: number;
  80885. /**
  80886. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80887. */
  80888. beginAnimationTo: number;
  80889. /**
  80890. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80891. */
  80892. beginAnimationLoop: boolean;
  80893. /**
  80894. * Gets or sets a world offset applied to all particles
  80895. */
  80896. worldOffset: Vector3;
  80897. /**
  80898. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80899. */
  80900. isAnimationSheetEnabled: boolean;
  80901. /**
  80902. * Get hosting scene
  80903. * @returns the scene
  80904. */
  80905. getScene(): Scene;
  80906. /**
  80907. * You can use gravity if you want to give an orientation to your particles.
  80908. */
  80909. gravity: Vector3;
  80910. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80911. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80912. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80913. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80914. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80915. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80916. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80917. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80918. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80919. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80920. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80921. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80922. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80923. /**
  80924. * Defines the delay in milliseconds before starting the system (0 by default)
  80925. */
  80926. startDelay: number;
  80927. /**
  80928. * Gets the current list of drag gradients.
  80929. * You must use addDragGradient and removeDragGradient to udpate this list
  80930. * @returns the list of drag gradients
  80931. */
  80932. getDragGradients(): Nullable<Array<FactorGradient>>;
  80933. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80934. limitVelocityDamping: number;
  80935. /**
  80936. * Gets the current list of limit velocity gradients.
  80937. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80938. * @returns the list of limit velocity gradients
  80939. */
  80940. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80941. /**
  80942. * Gets the current list of color gradients.
  80943. * You must use addColorGradient and removeColorGradient to udpate this list
  80944. * @returns the list of color gradients
  80945. */
  80946. getColorGradients(): Nullable<Array<ColorGradient>>;
  80947. /**
  80948. * Gets the current list of size gradients.
  80949. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80950. * @returns the list of size gradients
  80951. */
  80952. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80953. /**
  80954. * Gets the current list of color remap gradients.
  80955. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80956. * @returns the list of color remap gradients
  80957. */
  80958. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80959. /**
  80960. * Gets the current list of alpha remap gradients.
  80961. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80962. * @returns the list of alpha remap gradients
  80963. */
  80964. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80965. /**
  80966. * Gets the current list of life time gradients.
  80967. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80968. * @returns the list of life time gradients
  80969. */
  80970. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80971. /**
  80972. * Gets the current list of angular speed gradients.
  80973. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80974. * @returns the list of angular speed gradients
  80975. */
  80976. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80977. /**
  80978. * Gets the current list of velocity gradients.
  80979. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80980. * @returns the list of velocity gradients
  80981. */
  80982. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80983. /**
  80984. * Gets the current list of start size gradients.
  80985. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80986. * @returns the list of start size gradients
  80987. */
  80988. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80989. /**
  80990. * Gets the current list of emit rate gradients.
  80991. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80992. * @returns the list of emit rate gradients
  80993. */
  80994. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80995. /**
  80996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80997. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80998. */
  80999. direction1: Vector3;
  81000. /**
  81001. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81002. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81003. */
  81004. direction2: Vector3;
  81005. /**
  81006. * 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.
  81007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81008. */
  81009. minEmitBox: Vector3;
  81010. /**
  81011. * 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.
  81012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81013. */
  81014. maxEmitBox: Vector3;
  81015. /**
  81016. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81017. */
  81018. color1: Color4;
  81019. /**
  81020. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81021. */
  81022. color2: Color4;
  81023. /**
  81024. * Color the particle will have at the end of its lifetime
  81025. */
  81026. colorDead: Color4;
  81027. /**
  81028. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81029. */
  81030. textureMask: Color4;
  81031. /**
  81032. * The particle emitter type defines the emitter used by the particle system.
  81033. * It can be for example box, sphere, or cone...
  81034. */
  81035. particleEmitterType: IParticleEmitterType;
  81036. /** @hidden */
  81037. _isSubEmitter: boolean;
  81038. /**
  81039. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81040. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81041. */
  81042. billboardMode: number;
  81043. protected _isBillboardBased: boolean;
  81044. /**
  81045. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81046. */
  81047. isBillboardBased: boolean;
  81048. /**
  81049. * The scene the particle system belongs to.
  81050. */
  81051. protected _scene: Scene;
  81052. /**
  81053. * Local cache of defines for image processing.
  81054. */
  81055. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81056. /**
  81057. * Default configuration related to image processing available in the standard Material.
  81058. */
  81059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81060. /**
  81061. * Gets the image processing configuration used either in this material.
  81062. */
  81063. /**
  81064. * Sets the Default image processing configuration used either in the this material.
  81065. *
  81066. * If sets to null, the scene one is in use.
  81067. */
  81068. imageProcessingConfiguration: ImageProcessingConfiguration;
  81069. /**
  81070. * Attaches a new image processing configuration to the Standard Material.
  81071. * @param configuration
  81072. */
  81073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81074. /** @hidden */
  81075. protected _reset(): void;
  81076. /** @hidden */
  81077. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81078. /**
  81079. * Instantiates a particle system.
  81080. * 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.
  81081. * @param name The name of the particle system
  81082. */
  81083. constructor(name: string);
  81084. /**
  81085. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81086. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81087. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81088. * @returns the emitter
  81089. */
  81090. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81091. /**
  81092. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81093. * @param radius The radius of the hemisphere to emit from
  81094. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81095. * @returns the emitter
  81096. */
  81097. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81098. /**
  81099. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81100. * @param radius The radius of the sphere to emit from
  81101. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81102. * @returns the emitter
  81103. */
  81104. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81105. /**
  81106. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81107. * @param radius The radius of the sphere to emit from
  81108. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81109. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81110. * @returns the emitter
  81111. */
  81112. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81113. /**
  81114. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81115. * @param radius The radius of the emission cylinder
  81116. * @param height The height of the emission cylinder
  81117. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81118. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81119. * @returns the emitter
  81120. */
  81121. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81122. /**
  81123. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81124. * @param radius The radius of the cylinder to emit from
  81125. * @param height The height of the emission cylinder
  81126. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81129. * @returns the emitter
  81130. */
  81131. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81132. /**
  81133. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81134. * @param radius The radius of the cone to emit from
  81135. * @param angle The base angle of the cone
  81136. * @returns the emitter
  81137. */
  81138. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81139. /**
  81140. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81143. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81144. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81145. * @returns the emitter
  81146. */
  81147. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81148. }
  81149. }
  81150. declare module BABYLON {
  81151. /**
  81152. * Type of sub emitter
  81153. */
  81154. export enum SubEmitterType {
  81155. /**
  81156. * Attached to the particle over it's lifetime
  81157. */
  81158. ATTACHED = 0,
  81159. /**
  81160. * Created when the particle dies
  81161. */
  81162. END = 1
  81163. }
  81164. /**
  81165. * Sub emitter class used to emit particles from an existing particle
  81166. */
  81167. export class SubEmitter {
  81168. /**
  81169. * the particle system to be used by the sub emitter
  81170. */
  81171. particleSystem: ParticleSystem;
  81172. /**
  81173. * Type of the submitter (Default: END)
  81174. */
  81175. type: SubEmitterType;
  81176. /**
  81177. * 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)
  81178. * Note: This only is supported when using an emitter of type Mesh
  81179. */
  81180. inheritDirection: boolean;
  81181. /**
  81182. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81183. */
  81184. inheritedVelocityAmount: number;
  81185. /**
  81186. * Creates a sub emitter
  81187. * @param particleSystem the particle system to be used by the sub emitter
  81188. */
  81189. constructor(
  81190. /**
  81191. * the particle system to be used by the sub emitter
  81192. */
  81193. particleSystem: ParticleSystem);
  81194. /**
  81195. * Clones the sub emitter
  81196. * @returns the cloned sub emitter
  81197. */
  81198. clone(): SubEmitter;
  81199. /**
  81200. * Serialize current object to a JSON object
  81201. * @returns the serialized object
  81202. */
  81203. serialize(): any;
  81204. /** @hidden */
  81205. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81206. /**
  81207. * Creates a new SubEmitter from a serialized JSON version
  81208. * @param serializationObject defines the JSON object to read from
  81209. * @param scene defines the hosting scene
  81210. * @param rootUrl defines the rootUrl for data loading
  81211. * @returns a new SubEmitter
  81212. */
  81213. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81214. /** Release associated resources */
  81215. dispose(): void;
  81216. }
  81217. }
  81218. declare module BABYLON {
  81219. /** @hidden */
  81220. export var clipPlaneFragmentDeclaration: {
  81221. name: string;
  81222. shader: string;
  81223. };
  81224. }
  81225. declare module BABYLON {
  81226. /** @hidden */
  81227. export var imageProcessingDeclaration: {
  81228. name: string;
  81229. shader: string;
  81230. };
  81231. }
  81232. declare module BABYLON {
  81233. /** @hidden */
  81234. export var imageProcessingFunctions: {
  81235. name: string;
  81236. shader: string;
  81237. };
  81238. }
  81239. declare module BABYLON {
  81240. /** @hidden */
  81241. export var clipPlaneFragment: {
  81242. name: string;
  81243. shader: string;
  81244. };
  81245. }
  81246. declare module BABYLON {
  81247. /** @hidden */
  81248. export var particlesPixelShader: {
  81249. name: string;
  81250. shader: string;
  81251. };
  81252. }
  81253. declare module BABYLON {
  81254. /** @hidden */
  81255. export var clipPlaneVertexDeclaration: {
  81256. name: string;
  81257. shader: string;
  81258. };
  81259. }
  81260. declare module BABYLON {
  81261. /** @hidden */
  81262. export var clipPlaneVertex: {
  81263. name: string;
  81264. shader: string;
  81265. };
  81266. }
  81267. declare module BABYLON {
  81268. /** @hidden */
  81269. export var particlesVertexShader: {
  81270. name: string;
  81271. shader: string;
  81272. };
  81273. }
  81274. declare module BABYLON {
  81275. /**
  81276. * This represents a particle system in Babylon.
  81277. * 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.
  81278. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81279. * @example https://doc.babylonjs.com/babylon101/particles
  81280. */
  81281. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81282. /**
  81283. * Billboard mode will only apply to Y axis
  81284. */
  81285. static readonly BILLBOARDMODE_Y: number;
  81286. /**
  81287. * Billboard mode will apply to all axes
  81288. */
  81289. static readonly BILLBOARDMODE_ALL: number;
  81290. /**
  81291. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81292. */
  81293. static readonly BILLBOARDMODE_STRETCHED: number;
  81294. /**
  81295. * This function can be defined to provide custom update for active particles.
  81296. * This function will be called instead of regular update (age, position, color, etc.).
  81297. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81298. */
  81299. updateFunction: (particles: Particle[]) => void;
  81300. private _emitterWorldMatrix;
  81301. /**
  81302. * This function can be defined to specify initial direction for every new particle.
  81303. * It by default use the emitterType defined function
  81304. */
  81305. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81306. /**
  81307. * This function can be defined to specify initial position for every new particle.
  81308. * It by default use the emitterType defined function
  81309. */
  81310. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81311. /**
  81312. * @hidden
  81313. */
  81314. _inheritedVelocityOffset: Vector3;
  81315. /**
  81316. * An event triggered when the system is disposed
  81317. */
  81318. onDisposeObservable: Observable<ParticleSystem>;
  81319. private _onDisposeObserver;
  81320. /**
  81321. * Sets a callback that will be triggered when the system is disposed
  81322. */
  81323. onDispose: () => void;
  81324. private _particles;
  81325. private _epsilon;
  81326. private _capacity;
  81327. private _stockParticles;
  81328. private _newPartsExcess;
  81329. private _vertexData;
  81330. private _vertexBuffer;
  81331. private _vertexBuffers;
  81332. private _spriteBuffer;
  81333. private _indexBuffer;
  81334. private _effect;
  81335. private _customEffect;
  81336. private _cachedDefines;
  81337. private _scaledColorStep;
  81338. private _colorDiff;
  81339. private _scaledDirection;
  81340. private _scaledGravity;
  81341. private _currentRenderId;
  81342. private _alive;
  81343. private _useInstancing;
  81344. private _started;
  81345. private _stopped;
  81346. private _actualFrame;
  81347. private _scaledUpdateSpeed;
  81348. private _vertexBufferSize;
  81349. /** @hidden */
  81350. _currentEmitRateGradient: Nullable<FactorGradient>;
  81351. /** @hidden */
  81352. _currentEmitRate1: number;
  81353. /** @hidden */
  81354. _currentEmitRate2: number;
  81355. /** @hidden */
  81356. _currentStartSizeGradient: Nullable<FactorGradient>;
  81357. /** @hidden */
  81358. _currentStartSize1: number;
  81359. /** @hidden */
  81360. _currentStartSize2: number;
  81361. private readonly _rawTextureWidth;
  81362. private _rampGradientsTexture;
  81363. private _useRampGradients;
  81364. /** Gets or sets a boolean indicating that ramp gradients must be used
  81365. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81366. */
  81367. useRampGradients: boolean;
  81368. /**
  81369. * 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.
  81370. * 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: [])
  81371. */
  81372. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81373. private _subEmitters;
  81374. /**
  81375. * @hidden
  81376. * If the particle systems emitter should be disposed when the particle system is disposed
  81377. */
  81378. _disposeEmitterOnDispose: boolean;
  81379. /**
  81380. * The current active Sub-systems, this property is used by the root particle system only.
  81381. */
  81382. activeSubSystems: Array<ParticleSystem>;
  81383. private _rootParticleSystem;
  81384. /**
  81385. * Gets the current list of active particles
  81386. */
  81387. readonly particles: Particle[];
  81388. /**
  81389. * Returns the string "ParticleSystem"
  81390. * @returns a string containing the class name
  81391. */
  81392. getClassName(): string;
  81393. /**
  81394. * Instantiates a particle system.
  81395. * 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.
  81396. * @param name The name of the particle system
  81397. * @param capacity The max number of particles alive at the same time
  81398. * @param scene The scene the particle system belongs to
  81399. * @param customEffect a custom effect used to change the way particles are rendered by default
  81400. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81401. * @param epsilon Offset used to render the particles
  81402. */
  81403. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81404. private _addFactorGradient;
  81405. private _removeFactorGradient;
  81406. /**
  81407. * Adds a new life time gradient
  81408. * @param gradient defines the gradient to use (between 0 and 1)
  81409. * @param factor defines the life time factor to affect to the specified gradient
  81410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81411. * @returns the current particle system
  81412. */
  81413. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81414. /**
  81415. * Remove a specific life time gradient
  81416. * @param gradient defines the gradient to remove
  81417. * @returns the current particle system
  81418. */
  81419. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81420. /**
  81421. * Adds a new size gradient
  81422. * @param gradient defines the gradient to use (between 0 and 1)
  81423. * @param factor defines the size factor to affect to the specified gradient
  81424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81425. * @returns the current particle system
  81426. */
  81427. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81428. /**
  81429. * Remove a specific size gradient
  81430. * @param gradient defines the gradient to remove
  81431. * @returns the current particle system
  81432. */
  81433. removeSizeGradient(gradient: number): IParticleSystem;
  81434. /**
  81435. * Adds a new color remap gradient
  81436. * @param gradient defines the gradient to use (between 0 and 1)
  81437. * @param min defines the color remap minimal range
  81438. * @param max defines the color remap maximal range
  81439. * @returns the current particle system
  81440. */
  81441. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81442. /**
  81443. * Remove a specific color remap gradient
  81444. * @param gradient defines the gradient to remove
  81445. * @returns the current particle system
  81446. */
  81447. removeColorRemapGradient(gradient: number): IParticleSystem;
  81448. /**
  81449. * Adds a new alpha remap gradient
  81450. * @param gradient defines the gradient to use (between 0 and 1)
  81451. * @param min defines the alpha remap minimal range
  81452. * @param max defines the alpha remap maximal range
  81453. * @returns the current particle system
  81454. */
  81455. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81456. /**
  81457. * Remove a specific alpha remap gradient
  81458. * @param gradient defines the gradient to remove
  81459. * @returns the current particle system
  81460. */
  81461. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81462. /**
  81463. * Adds a new angular speed gradient
  81464. * @param gradient defines the gradient to use (between 0 and 1)
  81465. * @param factor defines the angular speed to affect to the specified gradient
  81466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81467. * @returns the current particle system
  81468. */
  81469. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81470. /**
  81471. * Remove a specific angular speed gradient
  81472. * @param gradient defines the gradient to remove
  81473. * @returns the current particle system
  81474. */
  81475. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81476. /**
  81477. * Adds a new velocity gradient
  81478. * @param gradient defines the gradient to use (between 0 and 1)
  81479. * @param factor defines the velocity to affect to the specified gradient
  81480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81481. * @returns the current particle system
  81482. */
  81483. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81484. /**
  81485. * Remove a specific velocity gradient
  81486. * @param gradient defines the gradient to remove
  81487. * @returns the current particle system
  81488. */
  81489. removeVelocityGradient(gradient: number): IParticleSystem;
  81490. /**
  81491. * Adds a new limit velocity gradient
  81492. * @param gradient defines the gradient to use (between 0 and 1)
  81493. * @param factor defines the limit velocity value to affect to the specified gradient
  81494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81495. * @returns the current particle system
  81496. */
  81497. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81498. /**
  81499. * Remove a specific limit velocity gradient
  81500. * @param gradient defines the gradient to remove
  81501. * @returns the current particle system
  81502. */
  81503. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81504. /**
  81505. * Adds a new drag gradient
  81506. * @param gradient defines the gradient to use (between 0 and 1)
  81507. * @param factor defines the drag value to affect to the specified gradient
  81508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81509. * @returns the current particle system
  81510. */
  81511. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81512. /**
  81513. * Remove a specific drag gradient
  81514. * @param gradient defines the gradient to remove
  81515. * @returns the current particle system
  81516. */
  81517. removeDragGradient(gradient: number): IParticleSystem;
  81518. /**
  81519. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81520. * @param gradient defines the gradient to use (between 0 and 1)
  81521. * @param factor defines the emit rate value to affect to the specified gradient
  81522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81523. * @returns the current particle system
  81524. */
  81525. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81526. /**
  81527. * Remove a specific emit rate gradient
  81528. * @param gradient defines the gradient to remove
  81529. * @returns the current particle system
  81530. */
  81531. removeEmitRateGradient(gradient: number): IParticleSystem;
  81532. /**
  81533. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81534. * @param gradient defines the gradient to use (between 0 and 1)
  81535. * @param factor defines the start size value to affect to the specified gradient
  81536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81537. * @returns the current particle system
  81538. */
  81539. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81540. /**
  81541. * Remove a specific start size gradient
  81542. * @param gradient defines the gradient to remove
  81543. * @returns the current particle system
  81544. */
  81545. removeStartSizeGradient(gradient: number): IParticleSystem;
  81546. private _createRampGradientTexture;
  81547. /**
  81548. * Gets the current list of ramp gradients.
  81549. * You must use addRampGradient and removeRampGradient to udpate this list
  81550. * @returns the list of ramp gradients
  81551. */
  81552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81553. /**
  81554. * Adds a new ramp gradient used to remap particle colors
  81555. * @param gradient defines the gradient to use (between 0 and 1)
  81556. * @param color defines the color to affect to the specified gradient
  81557. * @returns the current particle system
  81558. */
  81559. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81560. /**
  81561. * Remove a specific ramp gradient
  81562. * @param gradient defines the gradient to remove
  81563. * @returns the current particle system
  81564. */
  81565. removeRampGradient(gradient: number): ParticleSystem;
  81566. /**
  81567. * Adds a new color gradient
  81568. * @param gradient defines the gradient to use (between 0 and 1)
  81569. * @param color1 defines the color to affect to the specified gradient
  81570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81571. * @returns this particle system
  81572. */
  81573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81574. /**
  81575. * Remove a specific color gradient
  81576. * @param gradient defines the gradient to remove
  81577. * @returns this particle system
  81578. */
  81579. removeColorGradient(gradient: number): IParticleSystem;
  81580. private _fetchR;
  81581. protected _reset(): void;
  81582. private _resetEffect;
  81583. private _createVertexBuffers;
  81584. private _createIndexBuffer;
  81585. /**
  81586. * Gets the maximum number of particles active at the same time.
  81587. * @returns The max number of active particles.
  81588. */
  81589. getCapacity(): number;
  81590. /**
  81591. * Gets whether there are still active particles in the system.
  81592. * @returns True if it is alive, otherwise false.
  81593. */
  81594. isAlive(): boolean;
  81595. /**
  81596. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81597. * @returns True if it has been started, otherwise false.
  81598. */
  81599. isStarted(): boolean;
  81600. private _prepareSubEmitterInternalArray;
  81601. /**
  81602. * Starts the particle system and begins to emit
  81603. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81604. */
  81605. start(delay?: number): void;
  81606. /**
  81607. * Stops the particle system.
  81608. * @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.
  81609. */
  81610. stop(stopSubEmitters?: boolean): void;
  81611. /**
  81612. * Remove all active particles
  81613. */
  81614. reset(): void;
  81615. /**
  81616. * @hidden (for internal use only)
  81617. */
  81618. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81619. /**
  81620. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81621. * Its lifetime will start back at 0.
  81622. */
  81623. recycleParticle: (particle: Particle) => void;
  81624. private _stopSubEmitters;
  81625. private _createParticle;
  81626. private _removeFromRoot;
  81627. private _emitFromParticle;
  81628. private _update;
  81629. /** @hidden */
  81630. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81631. /** @hidden */
  81632. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81633. /** @hidden */
  81634. private _getEffect;
  81635. /**
  81636. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81637. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81638. */
  81639. animate(preWarmOnly?: boolean): void;
  81640. private _appendParticleVertices;
  81641. /**
  81642. * Rebuilds the particle system.
  81643. */
  81644. rebuild(): void;
  81645. /**
  81646. * Is this system ready to be used/rendered
  81647. * @return true if the system is ready
  81648. */
  81649. isReady(): boolean;
  81650. private _render;
  81651. /**
  81652. * Renders the particle system in its current state.
  81653. * @returns the current number of particles
  81654. */
  81655. render(): number;
  81656. /**
  81657. * Disposes the particle system and free the associated resources
  81658. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81659. */
  81660. dispose(disposeTexture?: boolean): void;
  81661. /**
  81662. * Clones the particle system.
  81663. * @param name The name of the cloned object
  81664. * @param newEmitter The new emitter to use
  81665. * @returns the cloned particle system
  81666. */
  81667. clone(name: string, newEmitter: any): ParticleSystem;
  81668. /**
  81669. * Serializes the particle system to a JSON object.
  81670. * @returns the JSON object
  81671. */
  81672. serialize(): any;
  81673. /** @hidden */
  81674. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81675. /** @hidden */
  81676. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81677. /**
  81678. * Parses a JSON object to create a particle system.
  81679. * @param parsedParticleSystem The JSON object to parse
  81680. * @param scene The scene to create the particle system in
  81681. * @param rootUrl The root url to use to load external dependencies like texture
  81682. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81683. * @returns the Parsed particle system
  81684. */
  81685. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81686. }
  81687. }
  81688. declare module BABYLON {
  81689. /**
  81690. * A particle represents one of the element emitted by a particle system.
  81691. * This is mainly define by its coordinates, direction, velocity and age.
  81692. */
  81693. export class Particle {
  81694. /**
  81695. * The particle system the particle belongs to.
  81696. */
  81697. particleSystem: ParticleSystem;
  81698. private static _Count;
  81699. /**
  81700. * Unique ID of the particle
  81701. */
  81702. id: number;
  81703. /**
  81704. * The world position of the particle in the scene.
  81705. */
  81706. position: Vector3;
  81707. /**
  81708. * The world direction of the particle in the scene.
  81709. */
  81710. direction: Vector3;
  81711. /**
  81712. * The color of the particle.
  81713. */
  81714. color: Color4;
  81715. /**
  81716. * The color change of the particle per step.
  81717. */
  81718. colorStep: Color4;
  81719. /**
  81720. * Defines how long will the life of the particle be.
  81721. */
  81722. lifeTime: number;
  81723. /**
  81724. * The current age of the particle.
  81725. */
  81726. age: number;
  81727. /**
  81728. * The current size of the particle.
  81729. */
  81730. size: number;
  81731. /**
  81732. * The current scale of the particle.
  81733. */
  81734. scale: Vector2;
  81735. /**
  81736. * The current angle of the particle.
  81737. */
  81738. angle: number;
  81739. /**
  81740. * Defines how fast is the angle changing.
  81741. */
  81742. angularSpeed: number;
  81743. /**
  81744. * Defines the cell index used by the particle to be rendered from a sprite.
  81745. */
  81746. cellIndex: number;
  81747. /**
  81748. * The information required to support color remapping
  81749. */
  81750. remapData: Vector4;
  81751. /** @hidden */
  81752. _randomCellOffset?: number;
  81753. /** @hidden */
  81754. _initialDirection: Nullable<Vector3>;
  81755. /** @hidden */
  81756. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81757. /** @hidden */
  81758. _initialStartSpriteCellID: number;
  81759. /** @hidden */
  81760. _initialEndSpriteCellID: number;
  81761. /** @hidden */
  81762. _currentColorGradient: Nullable<ColorGradient>;
  81763. /** @hidden */
  81764. _currentColor1: Color4;
  81765. /** @hidden */
  81766. _currentColor2: Color4;
  81767. /** @hidden */
  81768. _currentSizeGradient: Nullable<FactorGradient>;
  81769. /** @hidden */
  81770. _currentSize1: number;
  81771. /** @hidden */
  81772. _currentSize2: number;
  81773. /** @hidden */
  81774. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81775. /** @hidden */
  81776. _currentAngularSpeed1: number;
  81777. /** @hidden */
  81778. _currentAngularSpeed2: number;
  81779. /** @hidden */
  81780. _currentVelocityGradient: Nullable<FactorGradient>;
  81781. /** @hidden */
  81782. _currentVelocity1: number;
  81783. /** @hidden */
  81784. _currentVelocity2: number;
  81785. /** @hidden */
  81786. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81787. /** @hidden */
  81788. _currentLimitVelocity1: number;
  81789. /** @hidden */
  81790. _currentLimitVelocity2: number;
  81791. /** @hidden */
  81792. _currentDragGradient: Nullable<FactorGradient>;
  81793. /** @hidden */
  81794. _currentDrag1: number;
  81795. /** @hidden */
  81796. _currentDrag2: number;
  81797. /** @hidden */
  81798. _randomNoiseCoordinates1: Vector3;
  81799. /** @hidden */
  81800. _randomNoiseCoordinates2: Vector3;
  81801. /**
  81802. * Creates a new instance Particle
  81803. * @param particleSystem the particle system the particle belongs to
  81804. */
  81805. constructor(
  81806. /**
  81807. * The particle system the particle belongs to.
  81808. */
  81809. particleSystem: ParticleSystem);
  81810. private updateCellInfoFromSystem;
  81811. /**
  81812. * Defines how the sprite cell index is updated for the particle
  81813. */
  81814. updateCellIndex(): void;
  81815. /** @hidden */
  81816. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81817. /** @hidden */
  81818. _inheritParticleInfoToSubEmitters(): void;
  81819. /** @hidden */
  81820. _reset(): void;
  81821. /**
  81822. * Copy the properties of particle to another one.
  81823. * @param other the particle to copy the information to.
  81824. */
  81825. copyTo(other: Particle): void;
  81826. }
  81827. }
  81828. declare module BABYLON {
  81829. /**
  81830. * Particle emitter represents a volume emitting particles.
  81831. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81832. */
  81833. export interface IParticleEmitterType {
  81834. /**
  81835. * Called by the particle System when the direction is computed for the created particle.
  81836. * @param worldMatrix is the world matrix of the particle system
  81837. * @param directionToUpdate is the direction vector to update with the result
  81838. * @param particle is the particle we are computed the direction for
  81839. */
  81840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81841. /**
  81842. * Called by the particle System when the position is computed for the created particle.
  81843. * @param worldMatrix is the world matrix of the particle system
  81844. * @param positionToUpdate is the position vector to update with the result
  81845. * @param particle is the particle we are computed the position for
  81846. */
  81847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81848. /**
  81849. * Clones the current emitter and returns a copy of it
  81850. * @returns the new emitter
  81851. */
  81852. clone(): IParticleEmitterType;
  81853. /**
  81854. * Called by the GPUParticleSystem to setup the update shader
  81855. * @param effect defines the update shader
  81856. */
  81857. applyToShader(effect: Effect): void;
  81858. /**
  81859. * Returns a string to use to update the GPU particles update shader
  81860. * @returns the effect defines string
  81861. */
  81862. getEffectDefines(): string;
  81863. /**
  81864. * Returns a string representing the class name
  81865. * @returns a string containing the class name
  81866. */
  81867. getClassName(): string;
  81868. /**
  81869. * Serializes the particle system to a JSON object.
  81870. * @returns the JSON object
  81871. */
  81872. serialize(): any;
  81873. /**
  81874. * Parse properties from a JSON object
  81875. * @param serializationObject defines the JSON object
  81876. */
  81877. parse(serializationObject: any): void;
  81878. }
  81879. }
  81880. declare module BABYLON {
  81881. /**
  81882. * Particle emitter emitting particles from the inside of a box.
  81883. * It emits the particles randomly between 2 given directions.
  81884. */
  81885. export class BoxParticleEmitter implements IParticleEmitterType {
  81886. /**
  81887. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81888. */
  81889. direction1: Vector3;
  81890. /**
  81891. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81892. */
  81893. direction2: Vector3;
  81894. /**
  81895. * 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.
  81896. */
  81897. minEmitBox: Vector3;
  81898. /**
  81899. * 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.
  81900. */
  81901. maxEmitBox: Vector3;
  81902. /**
  81903. * Creates a new instance BoxParticleEmitter
  81904. */
  81905. constructor();
  81906. /**
  81907. * Called by the particle System when the direction is computed for the created particle.
  81908. * @param worldMatrix is the world matrix of the particle system
  81909. * @param directionToUpdate is the direction vector to update with the result
  81910. * @param particle is the particle we are computed the direction for
  81911. */
  81912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81913. /**
  81914. * Called by the particle System when the position is computed for the created particle.
  81915. * @param worldMatrix is the world matrix of the particle system
  81916. * @param positionToUpdate is the position vector to update with the result
  81917. * @param particle is the particle we are computed the position for
  81918. */
  81919. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81920. /**
  81921. * Clones the current emitter and returns a copy of it
  81922. * @returns the new emitter
  81923. */
  81924. clone(): BoxParticleEmitter;
  81925. /**
  81926. * Called by the GPUParticleSystem to setup the update shader
  81927. * @param effect defines the update shader
  81928. */
  81929. applyToShader(effect: Effect): void;
  81930. /**
  81931. * Returns a string to use to update the GPU particles update shader
  81932. * @returns a string containng the defines string
  81933. */
  81934. getEffectDefines(): string;
  81935. /**
  81936. * Returns the string "BoxParticleEmitter"
  81937. * @returns a string containing the class name
  81938. */
  81939. getClassName(): string;
  81940. /**
  81941. * Serializes the particle system to a JSON object.
  81942. * @returns the JSON object
  81943. */
  81944. serialize(): any;
  81945. /**
  81946. * Parse properties from a JSON object
  81947. * @param serializationObject defines the JSON object
  81948. */
  81949. parse(serializationObject: any): void;
  81950. }
  81951. }
  81952. declare module BABYLON {
  81953. /**
  81954. * Particle emitter emitting particles from the inside of a cone.
  81955. * It emits the particles alongside the cone volume from the base to the particle.
  81956. * The emission direction might be randomized.
  81957. */
  81958. export class ConeParticleEmitter implements IParticleEmitterType {
  81959. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81960. directionRandomizer: number;
  81961. private _radius;
  81962. private _angle;
  81963. private _height;
  81964. /**
  81965. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81966. */
  81967. radiusRange: number;
  81968. /**
  81969. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81970. */
  81971. heightRange: number;
  81972. /**
  81973. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81974. */
  81975. emitFromSpawnPointOnly: boolean;
  81976. /**
  81977. * Gets or sets the radius of the emission cone
  81978. */
  81979. radius: number;
  81980. /**
  81981. * Gets or sets the angle of the emission cone
  81982. */
  81983. angle: number;
  81984. private _buildHeight;
  81985. /**
  81986. * Creates a new instance ConeParticleEmitter
  81987. * @param radius the radius of the emission cone (1 by default)
  81988. * @param angle the cone base angle (PI by default)
  81989. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81990. */
  81991. constructor(radius?: number, angle?: number,
  81992. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81993. directionRandomizer?: number);
  81994. /**
  81995. * Called by the particle System when the direction is computed for the created particle.
  81996. * @param worldMatrix is the world matrix of the particle system
  81997. * @param directionToUpdate is the direction vector to update with the result
  81998. * @param particle is the particle we are computed the direction for
  81999. */
  82000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82001. /**
  82002. * Called by the particle System when the position is computed for the created particle.
  82003. * @param worldMatrix is the world matrix of the particle system
  82004. * @param positionToUpdate is the position vector to update with the result
  82005. * @param particle is the particle we are computed the position for
  82006. */
  82007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82008. /**
  82009. * Clones the current emitter and returns a copy of it
  82010. * @returns the new emitter
  82011. */
  82012. clone(): ConeParticleEmitter;
  82013. /**
  82014. * Called by the GPUParticleSystem to setup the update shader
  82015. * @param effect defines the update shader
  82016. */
  82017. applyToShader(effect: Effect): void;
  82018. /**
  82019. * Returns a string to use to update the GPU particles update shader
  82020. * @returns a string containng the defines string
  82021. */
  82022. getEffectDefines(): string;
  82023. /**
  82024. * Returns the string "ConeParticleEmitter"
  82025. * @returns a string containing the class name
  82026. */
  82027. getClassName(): string;
  82028. /**
  82029. * Serializes the particle system to a JSON object.
  82030. * @returns the JSON object
  82031. */
  82032. serialize(): any;
  82033. /**
  82034. * Parse properties from a JSON object
  82035. * @param serializationObject defines the JSON object
  82036. */
  82037. parse(serializationObject: any): void;
  82038. }
  82039. }
  82040. declare module BABYLON {
  82041. /**
  82042. * Particle emitter emitting particles from the inside of a cylinder.
  82043. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82044. */
  82045. export class CylinderParticleEmitter implements IParticleEmitterType {
  82046. /**
  82047. * The radius of the emission cylinder.
  82048. */
  82049. radius: number;
  82050. /**
  82051. * The height of the emission cylinder.
  82052. */
  82053. height: number;
  82054. /**
  82055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82056. */
  82057. radiusRange: number;
  82058. /**
  82059. * How much to randomize the particle direction [0-1].
  82060. */
  82061. directionRandomizer: number;
  82062. /**
  82063. * Creates a new instance CylinderParticleEmitter
  82064. * @param radius the radius of the emission cylinder (1 by default)
  82065. * @param height the height of the emission cylinder (1 by default)
  82066. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82067. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82068. */
  82069. constructor(
  82070. /**
  82071. * The radius of the emission cylinder.
  82072. */
  82073. radius?: number,
  82074. /**
  82075. * The height of the emission cylinder.
  82076. */
  82077. height?: number,
  82078. /**
  82079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82080. */
  82081. radiusRange?: number,
  82082. /**
  82083. * How much to randomize the particle direction [0-1].
  82084. */
  82085. directionRandomizer?: number);
  82086. /**
  82087. * Called by the particle System when the direction is computed for the created particle.
  82088. * @param worldMatrix is the world matrix of the particle system
  82089. * @param directionToUpdate is the direction vector to update with the result
  82090. * @param particle is the particle we are computed the direction for
  82091. */
  82092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82093. /**
  82094. * Called by the particle System when the position is computed for the created particle.
  82095. * @param worldMatrix is the world matrix of the particle system
  82096. * @param positionToUpdate is the position vector to update with the result
  82097. * @param particle is the particle we are computed the position for
  82098. */
  82099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82100. /**
  82101. * Clones the current emitter and returns a copy of it
  82102. * @returns the new emitter
  82103. */
  82104. clone(): CylinderParticleEmitter;
  82105. /**
  82106. * Called by the GPUParticleSystem to setup the update shader
  82107. * @param effect defines the update shader
  82108. */
  82109. applyToShader(effect: Effect): void;
  82110. /**
  82111. * Returns a string to use to update the GPU particles update shader
  82112. * @returns a string containng the defines string
  82113. */
  82114. getEffectDefines(): string;
  82115. /**
  82116. * Returns the string "CylinderParticleEmitter"
  82117. * @returns a string containing the class name
  82118. */
  82119. getClassName(): string;
  82120. /**
  82121. * Serializes the particle system to a JSON object.
  82122. * @returns the JSON object
  82123. */
  82124. serialize(): any;
  82125. /**
  82126. * Parse properties from a JSON object
  82127. * @param serializationObject defines the JSON object
  82128. */
  82129. parse(serializationObject: any): void;
  82130. }
  82131. /**
  82132. * Particle emitter emitting particles from the inside of a cylinder.
  82133. * It emits the particles randomly between two vectors.
  82134. */
  82135. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82136. /**
  82137. * The min limit of the emission direction.
  82138. */
  82139. direction1: Vector3;
  82140. /**
  82141. * The max limit of the emission direction.
  82142. */
  82143. direction2: Vector3;
  82144. /**
  82145. * Creates a new instance CylinderDirectedParticleEmitter
  82146. * @param radius the radius of the emission cylinder (1 by default)
  82147. * @param height the height of the emission cylinder (1 by default)
  82148. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82149. * @param direction1 the min limit of the emission direction (up vector by default)
  82150. * @param direction2 the max limit of the emission direction (up vector by default)
  82151. */
  82152. constructor(radius?: number, height?: number, radiusRange?: number,
  82153. /**
  82154. * The min limit of the emission direction.
  82155. */
  82156. direction1?: Vector3,
  82157. /**
  82158. * The max limit of the emission direction.
  82159. */
  82160. direction2?: Vector3);
  82161. /**
  82162. * Called by the particle System when the direction is computed for the created particle.
  82163. * @param worldMatrix is the world matrix of the particle system
  82164. * @param directionToUpdate is the direction vector to update with the result
  82165. * @param particle is the particle we are computed the direction for
  82166. */
  82167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82168. /**
  82169. * Clones the current emitter and returns a copy of it
  82170. * @returns the new emitter
  82171. */
  82172. clone(): CylinderDirectedParticleEmitter;
  82173. /**
  82174. * Called by the GPUParticleSystem to setup the update shader
  82175. * @param effect defines the update shader
  82176. */
  82177. applyToShader(effect: Effect): void;
  82178. /**
  82179. * Returns a string to use to update the GPU particles update shader
  82180. * @returns a string containng the defines string
  82181. */
  82182. getEffectDefines(): string;
  82183. /**
  82184. * Returns the string "CylinderDirectedParticleEmitter"
  82185. * @returns a string containing the class name
  82186. */
  82187. getClassName(): string;
  82188. /**
  82189. * Serializes the particle system to a JSON object.
  82190. * @returns the JSON object
  82191. */
  82192. serialize(): any;
  82193. /**
  82194. * Parse properties from a JSON object
  82195. * @param serializationObject defines the JSON object
  82196. */
  82197. parse(serializationObject: any): void;
  82198. }
  82199. }
  82200. declare module BABYLON {
  82201. /**
  82202. * Particle emitter emitting particles from the inside of a hemisphere.
  82203. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82204. */
  82205. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82206. /**
  82207. * The radius of the emission hemisphere.
  82208. */
  82209. radius: number;
  82210. /**
  82211. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82212. */
  82213. radiusRange: number;
  82214. /**
  82215. * How much to randomize the particle direction [0-1].
  82216. */
  82217. directionRandomizer: number;
  82218. /**
  82219. * Creates a new instance HemisphericParticleEmitter
  82220. * @param radius the radius of the emission hemisphere (1 by default)
  82221. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82222. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82223. */
  82224. constructor(
  82225. /**
  82226. * The radius of the emission hemisphere.
  82227. */
  82228. radius?: number,
  82229. /**
  82230. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82231. */
  82232. radiusRange?: number,
  82233. /**
  82234. * How much to randomize the particle direction [0-1].
  82235. */
  82236. directionRandomizer?: number);
  82237. /**
  82238. * Called by the particle System when the direction is computed for the created particle.
  82239. * @param worldMatrix is the world matrix of the particle system
  82240. * @param directionToUpdate is the direction vector to update with the result
  82241. * @param particle is the particle we are computed the direction for
  82242. */
  82243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82244. /**
  82245. * Called by the particle System when the position is computed for the created particle.
  82246. * @param worldMatrix is the world matrix of the particle system
  82247. * @param positionToUpdate is the position vector to update with the result
  82248. * @param particle is the particle we are computed the position for
  82249. */
  82250. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82251. /**
  82252. * Clones the current emitter and returns a copy of it
  82253. * @returns the new emitter
  82254. */
  82255. clone(): HemisphericParticleEmitter;
  82256. /**
  82257. * Called by the GPUParticleSystem to setup the update shader
  82258. * @param effect defines the update shader
  82259. */
  82260. applyToShader(effect: Effect): void;
  82261. /**
  82262. * Returns a string to use to update the GPU particles update shader
  82263. * @returns a string containng the defines string
  82264. */
  82265. getEffectDefines(): string;
  82266. /**
  82267. * Returns the string "HemisphericParticleEmitter"
  82268. * @returns a string containing the class name
  82269. */
  82270. getClassName(): string;
  82271. /**
  82272. * Serializes the particle system to a JSON object.
  82273. * @returns the JSON object
  82274. */
  82275. serialize(): any;
  82276. /**
  82277. * Parse properties from a JSON object
  82278. * @param serializationObject defines the JSON object
  82279. */
  82280. parse(serializationObject: any): void;
  82281. }
  82282. }
  82283. declare module BABYLON {
  82284. /**
  82285. * Particle emitter emitting particles from a point.
  82286. * It emits the particles randomly between 2 given directions.
  82287. */
  82288. export class PointParticleEmitter implements IParticleEmitterType {
  82289. /**
  82290. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82291. */
  82292. direction1: Vector3;
  82293. /**
  82294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82295. */
  82296. direction2: Vector3;
  82297. /**
  82298. * Creates a new instance PointParticleEmitter
  82299. */
  82300. constructor();
  82301. /**
  82302. * Called by the particle System when the direction is computed for the created particle.
  82303. * @param worldMatrix is the world matrix of the particle system
  82304. * @param directionToUpdate is the direction vector to update with the result
  82305. * @param particle is the particle we are computed the direction for
  82306. */
  82307. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82308. /**
  82309. * Called by the particle System when the position is computed for the created particle.
  82310. * @param worldMatrix is the world matrix of the particle system
  82311. * @param positionToUpdate is the position vector to update with the result
  82312. * @param particle is the particle we are computed the position for
  82313. */
  82314. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82315. /**
  82316. * Clones the current emitter and returns a copy of it
  82317. * @returns the new emitter
  82318. */
  82319. clone(): PointParticleEmitter;
  82320. /**
  82321. * Called by the GPUParticleSystem to setup the update shader
  82322. * @param effect defines the update shader
  82323. */
  82324. applyToShader(effect: Effect): void;
  82325. /**
  82326. * Returns a string to use to update the GPU particles update shader
  82327. * @returns a string containng the defines string
  82328. */
  82329. getEffectDefines(): string;
  82330. /**
  82331. * Returns the string "PointParticleEmitter"
  82332. * @returns a string containing the class name
  82333. */
  82334. getClassName(): string;
  82335. /**
  82336. * Serializes the particle system to a JSON object.
  82337. * @returns the JSON object
  82338. */
  82339. serialize(): any;
  82340. /**
  82341. * Parse properties from a JSON object
  82342. * @param serializationObject defines the JSON object
  82343. */
  82344. parse(serializationObject: any): void;
  82345. }
  82346. }
  82347. declare module BABYLON {
  82348. /**
  82349. * Particle emitter emitting particles from the inside of a sphere.
  82350. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82351. */
  82352. export class SphereParticleEmitter implements IParticleEmitterType {
  82353. /**
  82354. * The radius of the emission sphere.
  82355. */
  82356. radius: number;
  82357. /**
  82358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82359. */
  82360. radiusRange: number;
  82361. /**
  82362. * How much to randomize the particle direction [0-1].
  82363. */
  82364. directionRandomizer: number;
  82365. /**
  82366. * Creates a new instance SphereParticleEmitter
  82367. * @param radius the radius of the emission sphere (1 by default)
  82368. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82370. */
  82371. constructor(
  82372. /**
  82373. * The radius of the emission sphere.
  82374. */
  82375. radius?: number,
  82376. /**
  82377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82378. */
  82379. radiusRange?: number,
  82380. /**
  82381. * How much to randomize the particle direction [0-1].
  82382. */
  82383. directionRandomizer?: number);
  82384. /**
  82385. * Called by the particle System when the direction is computed for the created particle.
  82386. * @param worldMatrix is the world matrix of the particle system
  82387. * @param directionToUpdate is the direction vector to update with the result
  82388. * @param particle is the particle we are computed the direction for
  82389. */
  82390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82391. /**
  82392. * Called by the particle System when the position is computed for the created particle.
  82393. * @param worldMatrix is the world matrix of the particle system
  82394. * @param positionToUpdate is the position vector to update with the result
  82395. * @param particle is the particle we are computed the position for
  82396. */
  82397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82398. /**
  82399. * Clones the current emitter and returns a copy of it
  82400. * @returns the new emitter
  82401. */
  82402. clone(): SphereParticleEmitter;
  82403. /**
  82404. * Called by the GPUParticleSystem to setup the update shader
  82405. * @param effect defines the update shader
  82406. */
  82407. applyToShader(effect: Effect): void;
  82408. /**
  82409. * Returns a string to use to update the GPU particles update shader
  82410. * @returns a string containng the defines string
  82411. */
  82412. getEffectDefines(): string;
  82413. /**
  82414. * Returns the string "SphereParticleEmitter"
  82415. * @returns a string containing the class name
  82416. */
  82417. getClassName(): string;
  82418. /**
  82419. * Serializes the particle system to a JSON object.
  82420. * @returns the JSON object
  82421. */
  82422. serialize(): any;
  82423. /**
  82424. * Parse properties from a JSON object
  82425. * @param serializationObject defines the JSON object
  82426. */
  82427. parse(serializationObject: any): void;
  82428. }
  82429. /**
  82430. * Particle emitter emitting particles from the inside of a sphere.
  82431. * It emits the particles randomly between two vectors.
  82432. */
  82433. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82434. /**
  82435. * The min limit of the emission direction.
  82436. */
  82437. direction1: Vector3;
  82438. /**
  82439. * The max limit of the emission direction.
  82440. */
  82441. direction2: Vector3;
  82442. /**
  82443. * Creates a new instance SphereDirectedParticleEmitter
  82444. * @param radius the radius of the emission sphere (1 by default)
  82445. * @param direction1 the min limit of the emission direction (up vector by default)
  82446. * @param direction2 the max limit of the emission direction (up vector by default)
  82447. */
  82448. constructor(radius?: number,
  82449. /**
  82450. * The min limit of the emission direction.
  82451. */
  82452. direction1?: Vector3,
  82453. /**
  82454. * The max limit of the emission direction.
  82455. */
  82456. direction2?: Vector3);
  82457. /**
  82458. * Called by the particle System when the direction is computed for the created particle.
  82459. * @param worldMatrix is the world matrix of the particle system
  82460. * @param directionToUpdate is the direction vector to update with the result
  82461. * @param particle is the particle we are computed the direction for
  82462. */
  82463. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82464. /**
  82465. * Clones the current emitter and returns a copy of it
  82466. * @returns the new emitter
  82467. */
  82468. clone(): SphereDirectedParticleEmitter;
  82469. /**
  82470. * Called by the GPUParticleSystem to setup the update shader
  82471. * @param effect defines the update shader
  82472. */
  82473. applyToShader(effect: Effect): void;
  82474. /**
  82475. * Returns a string to use to update the GPU particles update shader
  82476. * @returns a string containng the defines string
  82477. */
  82478. getEffectDefines(): string;
  82479. /**
  82480. * Returns the string "SphereDirectedParticleEmitter"
  82481. * @returns a string containing the class name
  82482. */
  82483. getClassName(): string;
  82484. /**
  82485. * Serializes the particle system to a JSON object.
  82486. * @returns the JSON object
  82487. */
  82488. serialize(): any;
  82489. /**
  82490. * Parse properties from a JSON object
  82491. * @param serializationObject defines the JSON object
  82492. */
  82493. parse(serializationObject: any): void;
  82494. }
  82495. }
  82496. declare module BABYLON {
  82497. /**
  82498. * Interface representing a particle system in Babylon.js.
  82499. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82500. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82501. */
  82502. export interface IParticleSystem {
  82503. /**
  82504. * List of animations used by the particle system.
  82505. */
  82506. animations: Animation[];
  82507. /**
  82508. * The id of the Particle system.
  82509. */
  82510. id: string;
  82511. /**
  82512. * The name of the Particle system.
  82513. */
  82514. name: string;
  82515. /**
  82516. * The emitter represents the Mesh or position we are attaching the particle system to.
  82517. */
  82518. emitter: Nullable<AbstractMesh | Vector3>;
  82519. /**
  82520. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82521. */
  82522. isBillboardBased: boolean;
  82523. /**
  82524. * The rendering group used by the Particle system to chose when to render.
  82525. */
  82526. renderingGroupId: number;
  82527. /**
  82528. * The layer mask we are rendering the particles through.
  82529. */
  82530. layerMask: number;
  82531. /**
  82532. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82533. */
  82534. updateSpeed: number;
  82535. /**
  82536. * The amount of time the particle system is running (depends of the overall update speed).
  82537. */
  82538. targetStopDuration: number;
  82539. /**
  82540. * The texture used to render each particle. (this can be a spritesheet)
  82541. */
  82542. particleTexture: Nullable<Texture>;
  82543. /**
  82544. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82545. */
  82546. blendMode: number;
  82547. /**
  82548. * Minimum life time of emitting particles.
  82549. */
  82550. minLifeTime: number;
  82551. /**
  82552. * Maximum life time of emitting particles.
  82553. */
  82554. maxLifeTime: number;
  82555. /**
  82556. * Minimum Size of emitting particles.
  82557. */
  82558. minSize: number;
  82559. /**
  82560. * Maximum Size of emitting particles.
  82561. */
  82562. maxSize: number;
  82563. /**
  82564. * Minimum scale of emitting particles on X axis.
  82565. */
  82566. minScaleX: number;
  82567. /**
  82568. * Maximum scale of emitting particles on X axis.
  82569. */
  82570. maxScaleX: number;
  82571. /**
  82572. * Minimum scale of emitting particles on Y axis.
  82573. */
  82574. minScaleY: number;
  82575. /**
  82576. * Maximum scale of emitting particles on Y axis.
  82577. */
  82578. maxScaleY: number;
  82579. /**
  82580. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82581. */
  82582. color1: Color4;
  82583. /**
  82584. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82585. */
  82586. color2: Color4;
  82587. /**
  82588. * Color the particle will have at the end of its lifetime.
  82589. */
  82590. colorDead: Color4;
  82591. /**
  82592. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82593. */
  82594. emitRate: number;
  82595. /**
  82596. * You can use gravity if you want to give an orientation to your particles.
  82597. */
  82598. gravity: Vector3;
  82599. /**
  82600. * Minimum power of emitting particles.
  82601. */
  82602. minEmitPower: number;
  82603. /**
  82604. * Maximum power of emitting particles.
  82605. */
  82606. maxEmitPower: number;
  82607. /**
  82608. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82609. */
  82610. minAngularSpeed: number;
  82611. /**
  82612. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82613. */
  82614. maxAngularSpeed: number;
  82615. /**
  82616. * Gets or sets the minimal initial rotation in radians.
  82617. */
  82618. minInitialRotation: number;
  82619. /**
  82620. * Gets or sets the maximal initial rotation in radians.
  82621. */
  82622. maxInitialRotation: number;
  82623. /**
  82624. * The particle emitter type defines the emitter used by the particle system.
  82625. * It can be for example box, sphere, or cone...
  82626. */
  82627. particleEmitterType: Nullable<IParticleEmitterType>;
  82628. /**
  82629. * Defines the delay in milliseconds before starting the system (0 by default)
  82630. */
  82631. startDelay: number;
  82632. /**
  82633. * 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
  82634. */
  82635. preWarmCycles: number;
  82636. /**
  82637. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82638. */
  82639. preWarmStepOffset: number;
  82640. /**
  82641. * 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)
  82642. */
  82643. spriteCellChangeSpeed: number;
  82644. /**
  82645. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82646. */
  82647. startSpriteCellID: number;
  82648. /**
  82649. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82650. */
  82651. endSpriteCellID: number;
  82652. /**
  82653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82654. */
  82655. spriteCellWidth: number;
  82656. /**
  82657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82658. */
  82659. spriteCellHeight: number;
  82660. /**
  82661. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82662. */
  82663. spriteRandomStartCell: boolean;
  82664. /**
  82665. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82666. */
  82667. isAnimationSheetEnabled: boolean;
  82668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82669. translationPivot: Vector2;
  82670. /**
  82671. * Gets or sets a texture used to add random noise to particle positions
  82672. */
  82673. noiseTexture: Nullable<BaseTexture>;
  82674. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82675. noiseStrength: Vector3;
  82676. /**
  82677. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82678. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82679. */
  82680. billboardMode: number;
  82681. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82682. limitVelocityDamping: number;
  82683. /**
  82684. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82685. */
  82686. beginAnimationOnStart: boolean;
  82687. /**
  82688. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82689. */
  82690. beginAnimationFrom: number;
  82691. /**
  82692. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82693. */
  82694. beginAnimationTo: number;
  82695. /**
  82696. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82697. */
  82698. beginAnimationLoop: boolean;
  82699. /**
  82700. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82701. */
  82702. disposeOnStop: boolean;
  82703. /**
  82704. * Gets the maximum number of particles active at the same time.
  82705. * @returns The max number of active particles.
  82706. */
  82707. getCapacity(): number;
  82708. /**
  82709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82710. * @returns True if it has been started, otherwise false.
  82711. */
  82712. isStarted(): boolean;
  82713. /**
  82714. * Animates the particle system for this frame.
  82715. */
  82716. animate(): void;
  82717. /**
  82718. * Renders the particle system in its current state.
  82719. * @returns the current number of particles
  82720. */
  82721. render(): number;
  82722. /**
  82723. * Dispose the particle system and frees its associated resources.
  82724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82725. */
  82726. dispose(disposeTexture?: boolean): void;
  82727. /**
  82728. * Clones the particle system.
  82729. * @param name The name of the cloned object
  82730. * @param newEmitter The new emitter to use
  82731. * @returns the cloned particle system
  82732. */
  82733. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82734. /**
  82735. * Serializes the particle system to a JSON object.
  82736. * @returns the JSON object
  82737. */
  82738. serialize(): any;
  82739. /**
  82740. * Rebuild the particle system
  82741. */
  82742. rebuild(): void;
  82743. /**
  82744. * Starts the particle system and begins to emit
  82745. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82746. */
  82747. start(delay?: number): void;
  82748. /**
  82749. * Stops the particle system.
  82750. */
  82751. stop(): void;
  82752. /**
  82753. * Remove all active particles
  82754. */
  82755. reset(): void;
  82756. /**
  82757. * Is this system ready to be used/rendered
  82758. * @return true if the system is ready
  82759. */
  82760. isReady(): boolean;
  82761. /**
  82762. * Adds a new color gradient
  82763. * @param gradient defines the gradient to use (between 0 and 1)
  82764. * @param color1 defines the color to affect to the specified gradient
  82765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82766. * @returns the current particle system
  82767. */
  82768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82769. /**
  82770. * Remove a specific color gradient
  82771. * @param gradient defines the gradient to remove
  82772. * @returns the current particle system
  82773. */
  82774. removeColorGradient(gradient: number): IParticleSystem;
  82775. /**
  82776. * Adds a new size gradient
  82777. * @param gradient defines the gradient to use (between 0 and 1)
  82778. * @param factor defines the size factor to affect to the specified gradient
  82779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82780. * @returns the current particle system
  82781. */
  82782. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82783. /**
  82784. * Remove a specific size gradient
  82785. * @param gradient defines the gradient to remove
  82786. * @returns the current particle system
  82787. */
  82788. removeSizeGradient(gradient: number): IParticleSystem;
  82789. /**
  82790. * Gets the current list of color gradients.
  82791. * You must use addColorGradient and removeColorGradient to udpate this list
  82792. * @returns the list of color gradients
  82793. */
  82794. getColorGradients(): Nullable<Array<ColorGradient>>;
  82795. /**
  82796. * Gets the current list of size gradients.
  82797. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82798. * @returns the list of size gradients
  82799. */
  82800. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82801. /**
  82802. * Gets the current list of angular speed gradients.
  82803. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82804. * @returns the list of angular speed gradients
  82805. */
  82806. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82807. /**
  82808. * Adds a new angular speed gradient
  82809. * @param gradient defines the gradient to use (between 0 and 1)
  82810. * @param factor defines the angular speed to affect to the specified gradient
  82811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82812. * @returns the current particle system
  82813. */
  82814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82815. /**
  82816. * Remove a specific angular speed gradient
  82817. * @param gradient defines the gradient to remove
  82818. * @returns the current particle system
  82819. */
  82820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82821. /**
  82822. * Gets the current list of velocity gradients.
  82823. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82824. * @returns the list of velocity gradients
  82825. */
  82826. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82827. /**
  82828. * Adds a new velocity gradient
  82829. * @param gradient defines the gradient to use (between 0 and 1)
  82830. * @param factor defines the velocity to affect to the specified gradient
  82831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82832. * @returns the current particle system
  82833. */
  82834. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82835. /**
  82836. * Remove a specific velocity gradient
  82837. * @param gradient defines the gradient to remove
  82838. * @returns the current particle system
  82839. */
  82840. removeVelocityGradient(gradient: number): IParticleSystem;
  82841. /**
  82842. * Gets the current list of limit velocity gradients.
  82843. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82844. * @returns the list of limit velocity gradients
  82845. */
  82846. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82847. /**
  82848. * Adds a new limit velocity gradient
  82849. * @param gradient defines the gradient to use (between 0 and 1)
  82850. * @param factor defines the limit velocity to affect to the specified gradient
  82851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82852. * @returns the current particle system
  82853. */
  82854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82855. /**
  82856. * Remove a specific limit velocity gradient
  82857. * @param gradient defines the gradient to remove
  82858. * @returns the current particle system
  82859. */
  82860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82861. /**
  82862. * Adds a new drag gradient
  82863. * @param gradient defines the gradient to use (between 0 and 1)
  82864. * @param factor defines the drag to affect to the specified gradient
  82865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82866. * @returns the current particle system
  82867. */
  82868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82869. /**
  82870. * Remove a specific drag gradient
  82871. * @param gradient defines the gradient to remove
  82872. * @returns the current particle system
  82873. */
  82874. removeDragGradient(gradient: number): IParticleSystem;
  82875. /**
  82876. * Gets the current list of drag gradients.
  82877. * You must use addDragGradient and removeDragGradient to udpate this list
  82878. * @returns the list of drag gradients
  82879. */
  82880. getDragGradients(): Nullable<Array<FactorGradient>>;
  82881. /**
  82882. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82883. * @param gradient defines the gradient to use (between 0 and 1)
  82884. * @param factor defines the emit rate to affect to the specified gradient
  82885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82886. * @returns the current particle system
  82887. */
  82888. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82889. /**
  82890. * Remove a specific emit rate gradient
  82891. * @param gradient defines the gradient to remove
  82892. * @returns the current particle system
  82893. */
  82894. removeEmitRateGradient(gradient: number): IParticleSystem;
  82895. /**
  82896. * Gets the current list of emit rate gradients.
  82897. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82898. * @returns the list of emit rate gradients
  82899. */
  82900. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82901. /**
  82902. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82903. * @param gradient defines the gradient to use (between 0 and 1)
  82904. * @param factor defines the start size to affect to the specified gradient
  82905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82906. * @returns the current particle system
  82907. */
  82908. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82909. /**
  82910. * Remove a specific start size gradient
  82911. * @param gradient defines the gradient to remove
  82912. * @returns the current particle system
  82913. */
  82914. removeStartSizeGradient(gradient: number): IParticleSystem;
  82915. /**
  82916. * Gets the current list of start size gradients.
  82917. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82918. * @returns the list of start size gradients
  82919. */
  82920. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82921. /**
  82922. * Adds a new life time gradient
  82923. * @param gradient defines the gradient to use (between 0 and 1)
  82924. * @param factor defines the life time factor to affect to the specified gradient
  82925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82926. * @returns the current particle system
  82927. */
  82928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82929. /**
  82930. * Remove a specific life time gradient
  82931. * @param gradient defines the gradient to remove
  82932. * @returns the current particle system
  82933. */
  82934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82935. /**
  82936. * Gets the current list of life time gradients.
  82937. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82938. * @returns the list of life time gradients
  82939. */
  82940. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82941. /**
  82942. * Gets the current list of color gradients.
  82943. * You must use addColorGradient and removeColorGradient to udpate this list
  82944. * @returns the list of color gradients
  82945. */
  82946. getColorGradients(): Nullable<Array<ColorGradient>>;
  82947. /**
  82948. * Adds a new ramp gradient used to remap particle colors
  82949. * @param gradient defines the gradient to use (between 0 and 1)
  82950. * @param color defines the color to affect to the specified gradient
  82951. * @returns the current particle system
  82952. */
  82953. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82954. /**
  82955. * Gets the current list of ramp gradients.
  82956. * You must use addRampGradient and removeRampGradient to udpate this list
  82957. * @returns the list of ramp gradients
  82958. */
  82959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82960. /** Gets or sets a boolean indicating that ramp gradients must be used
  82961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82962. */
  82963. useRampGradients: boolean;
  82964. /**
  82965. * Adds a new color remap gradient
  82966. * @param gradient defines the gradient to use (between 0 and 1)
  82967. * @param min defines the color remap minimal range
  82968. * @param max defines the color remap maximal range
  82969. * @returns the current particle system
  82970. */
  82971. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82972. /**
  82973. * Gets the current list of color remap gradients.
  82974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82975. * @returns the list of color remap gradients
  82976. */
  82977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82978. /**
  82979. * Adds a new alpha remap gradient
  82980. * @param gradient defines the gradient to use (between 0 and 1)
  82981. * @param min defines the alpha remap minimal range
  82982. * @param max defines the alpha remap maximal range
  82983. * @returns the current particle system
  82984. */
  82985. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82986. /**
  82987. * Gets the current list of alpha remap gradients.
  82988. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82989. * @returns the list of alpha remap gradients
  82990. */
  82991. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82992. /**
  82993. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82996. * @returns the emitter
  82997. */
  82998. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82999. /**
  83000. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83001. * @param radius The radius of the hemisphere to emit from
  83002. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83003. * @returns the emitter
  83004. */
  83005. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83006. /**
  83007. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83008. * @param radius The radius of the sphere to emit from
  83009. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83010. * @returns the emitter
  83011. */
  83012. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83013. /**
  83014. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83015. * @param radius The radius of the sphere to emit from
  83016. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83017. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83018. * @returns the emitter
  83019. */
  83020. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83021. /**
  83022. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83023. * @param radius The radius of the emission cylinder
  83024. * @param height The height of the emission cylinder
  83025. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83026. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83027. * @returns the emitter
  83028. */
  83029. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83030. /**
  83031. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83032. * @param radius The radius of the cylinder to emit from
  83033. * @param height The height of the emission cylinder
  83034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83037. * @returns the emitter
  83038. */
  83039. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83040. /**
  83041. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83042. * @param radius The radius of the cone to emit from
  83043. * @param angle The base angle of the cone
  83044. * @returns the emitter
  83045. */
  83046. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83047. /**
  83048. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83051. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83052. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83053. * @returns the emitter
  83054. */
  83055. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83056. /**
  83057. * Get hosting scene
  83058. * @returns the scene
  83059. */
  83060. getScene(): Scene;
  83061. }
  83062. }
  83063. declare module BABYLON {
  83064. /**
  83065. * Creates an instance based on a source mesh.
  83066. */
  83067. export class InstancedMesh extends AbstractMesh {
  83068. private _sourceMesh;
  83069. private _currentLOD;
  83070. /** @hidden */
  83071. _indexInSourceMeshInstanceArray: number;
  83072. constructor(name: string, source: Mesh);
  83073. /**
  83074. * Returns the string "InstancedMesh".
  83075. */
  83076. getClassName(): string;
  83077. /** Gets the list of lights affecting that mesh */
  83078. readonly lightSources: Light[];
  83079. _resyncLightSources(): void;
  83080. _resyncLighSource(light: Light): void;
  83081. _removeLightSource(light: Light): void;
  83082. /**
  83083. * If the source mesh receives shadows
  83084. */
  83085. readonly receiveShadows: boolean;
  83086. /**
  83087. * The material of the source mesh
  83088. */
  83089. readonly material: Nullable<Material>;
  83090. /**
  83091. * Visibility of the source mesh
  83092. */
  83093. readonly visibility: number;
  83094. /**
  83095. * Skeleton of the source mesh
  83096. */
  83097. readonly skeleton: Nullable<Skeleton>;
  83098. /**
  83099. * Rendering ground id of the source mesh
  83100. */
  83101. renderingGroupId: number;
  83102. /**
  83103. * Returns the total number of vertices (integer).
  83104. */
  83105. getTotalVertices(): number;
  83106. /**
  83107. * Returns a positive integer : the total number of indices in this mesh geometry.
  83108. * @returns the numner of indices or zero if the mesh has no geometry.
  83109. */
  83110. getTotalIndices(): number;
  83111. /**
  83112. * The source mesh of the instance
  83113. */
  83114. readonly sourceMesh: Mesh;
  83115. /**
  83116. * Is this node ready to be used/rendered
  83117. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83118. * @return {boolean} is it ready
  83119. */
  83120. isReady(completeCheck?: boolean): boolean;
  83121. /**
  83122. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83123. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83124. * @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.
  83125. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83126. */
  83127. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83128. /**
  83129. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83130. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83131. * The `data` are either a numeric array either a Float32Array.
  83132. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83133. * 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).
  83134. * Note that a new underlying VertexBuffer object is created each call.
  83135. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83136. *
  83137. * Possible `kind` values :
  83138. * - VertexBuffer.PositionKind
  83139. * - VertexBuffer.UVKind
  83140. * - VertexBuffer.UV2Kind
  83141. * - VertexBuffer.UV3Kind
  83142. * - VertexBuffer.UV4Kind
  83143. * - VertexBuffer.UV5Kind
  83144. * - VertexBuffer.UV6Kind
  83145. * - VertexBuffer.ColorKind
  83146. * - VertexBuffer.MatricesIndicesKind
  83147. * - VertexBuffer.MatricesIndicesExtraKind
  83148. * - VertexBuffer.MatricesWeightsKind
  83149. * - VertexBuffer.MatricesWeightsExtraKind
  83150. *
  83151. * Returns the Mesh.
  83152. */
  83153. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83154. /**
  83155. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83156. * If the mesh has no geometry, it is simply returned as it is.
  83157. * The `data` are either a numeric array either a Float32Array.
  83158. * No new underlying VertexBuffer object is created.
  83159. * 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.
  83160. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83161. *
  83162. * Possible `kind` values :
  83163. * - VertexBuffer.PositionKind
  83164. * - VertexBuffer.UVKind
  83165. * - VertexBuffer.UV2Kind
  83166. * - VertexBuffer.UV3Kind
  83167. * - VertexBuffer.UV4Kind
  83168. * - VertexBuffer.UV5Kind
  83169. * - VertexBuffer.UV6Kind
  83170. * - VertexBuffer.ColorKind
  83171. * - VertexBuffer.MatricesIndicesKind
  83172. * - VertexBuffer.MatricesIndicesExtraKind
  83173. * - VertexBuffer.MatricesWeightsKind
  83174. * - VertexBuffer.MatricesWeightsExtraKind
  83175. *
  83176. * Returns the Mesh.
  83177. */
  83178. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83179. /**
  83180. * Sets the mesh indices.
  83181. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83182. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83183. * This method creates a new index buffer each call.
  83184. * Returns the Mesh.
  83185. */
  83186. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83187. /**
  83188. * Boolean : True if the mesh owns the requested kind of data.
  83189. */
  83190. isVerticesDataPresent(kind: string): boolean;
  83191. /**
  83192. * Returns an array of indices (IndicesArray).
  83193. */
  83194. getIndices(): Nullable<IndicesArray>;
  83195. readonly _positions: Nullable<Vector3[]>;
  83196. /**
  83197. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83198. * This means the mesh underlying bounding box and sphere are recomputed.
  83199. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83200. * @returns the current mesh
  83201. */
  83202. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83203. /** @hidden */
  83204. _preActivate(): InstancedMesh;
  83205. /** @hidden */
  83206. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83207. /** @hidden */
  83208. _postActivate(): void;
  83209. getWorldMatrix(): Matrix;
  83210. readonly isAnInstance: boolean;
  83211. /**
  83212. * Returns the current associated LOD AbstractMesh.
  83213. */
  83214. getLOD(camera: Camera): AbstractMesh;
  83215. /** @hidden */
  83216. _syncSubMeshes(): InstancedMesh;
  83217. /** @hidden */
  83218. _generatePointsArray(): boolean;
  83219. /**
  83220. * Creates a new InstancedMesh from the current mesh.
  83221. * - name (string) : the cloned mesh name
  83222. * - newParent (optional Node) : the optional Node to parent the clone to.
  83223. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83224. *
  83225. * Returns the clone.
  83226. */
  83227. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  83228. /**
  83229. * Disposes the InstancedMesh.
  83230. * Returns nothing.
  83231. */
  83232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83233. }
  83234. }
  83235. declare module BABYLON {
  83236. /**
  83237. * Defines the options associated with the creation of a shader material.
  83238. */
  83239. export interface IShaderMaterialOptions {
  83240. /**
  83241. * Does the material work in alpha blend mode
  83242. */
  83243. needAlphaBlending: boolean;
  83244. /**
  83245. * Does the material work in alpha test mode
  83246. */
  83247. needAlphaTesting: boolean;
  83248. /**
  83249. * The list of attribute names used in the shader
  83250. */
  83251. attributes: string[];
  83252. /**
  83253. * The list of unifrom names used in the shader
  83254. */
  83255. uniforms: string[];
  83256. /**
  83257. * The list of UBO names used in the shader
  83258. */
  83259. uniformBuffers: string[];
  83260. /**
  83261. * The list of sampler names used in the shader
  83262. */
  83263. samplers: string[];
  83264. /**
  83265. * The list of defines used in the shader
  83266. */
  83267. defines: string[];
  83268. }
  83269. /**
  83270. * 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.
  83271. *
  83272. * This returned material effects how the mesh will look based on the code in the shaders.
  83273. *
  83274. * @see http://doc.babylonjs.com/how_to/shader_material
  83275. */
  83276. export class ShaderMaterial extends Material {
  83277. private _shaderPath;
  83278. private _options;
  83279. private _textures;
  83280. private _textureArrays;
  83281. private _floats;
  83282. private _ints;
  83283. private _floatsArrays;
  83284. private _colors3;
  83285. private _colors3Arrays;
  83286. private _colors4;
  83287. private _colors4Arrays;
  83288. private _vectors2;
  83289. private _vectors3;
  83290. private _vectors4;
  83291. private _matrices;
  83292. private _matrices3x3;
  83293. private _matrices2x2;
  83294. private _vectors2Arrays;
  83295. private _vectors3Arrays;
  83296. private _vectors4Arrays;
  83297. private _cachedWorldViewMatrix;
  83298. private _cachedWorldViewProjectionMatrix;
  83299. private _renderId;
  83300. /**
  83301. * Instantiate a new shader material.
  83302. * 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.
  83303. * This returned material effects how the mesh will look based on the code in the shaders.
  83304. * @see http://doc.babylonjs.com/how_to/shader_material
  83305. * @param name Define the name of the material in the scene
  83306. * @param scene Define the scene the material belongs to
  83307. * @param shaderPath Defines the route to the shader code in one of three ways:
  83308. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83309. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83310. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83311. * @param options Define the options used to create the shader
  83312. */
  83313. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83314. /**
  83315. * Gets the options used to compile the shader.
  83316. * They can be modified to trigger a new compilation
  83317. */
  83318. readonly options: IShaderMaterialOptions;
  83319. /**
  83320. * Gets the current class name of the material e.g. "ShaderMaterial"
  83321. * Mainly use in serialization.
  83322. * @returns the class name
  83323. */
  83324. getClassName(): string;
  83325. /**
  83326. * Specifies if the material will require alpha blending
  83327. * @returns a boolean specifying if alpha blending is needed
  83328. */
  83329. needAlphaBlending(): boolean;
  83330. /**
  83331. * Specifies if this material should be rendered in alpha test mode
  83332. * @returns a boolean specifying if an alpha test is needed.
  83333. */
  83334. needAlphaTesting(): boolean;
  83335. private _checkUniform;
  83336. /**
  83337. * Set a texture in the shader.
  83338. * @param name Define the name of the uniform samplers as defined in the shader
  83339. * @param texture Define the texture to bind to this sampler
  83340. * @return the material itself allowing "fluent" like uniform updates
  83341. */
  83342. setTexture(name: string, texture: Texture): ShaderMaterial;
  83343. /**
  83344. * Set a texture array in the shader.
  83345. * @param name Define the name of the uniform sampler array as defined in the shader
  83346. * @param textures Define the list of textures to bind to this sampler
  83347. * @return the material itself allowing "fluent" like uniform updates
  83348. */
  83349. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83350. /**
  83351. * Set a float in the shader.
  83352. * @param name Define the name of the uniform as defined in the shader
  83353. * @param value Define the value to give to the uniform
  83354. * @return the material itself allowing "fluent" like uniform updates
  83355. */
  83356. setFloat(name: string, value: number): ShaderMaterial;
  83357. /**
  83358. * Set a int in the shader.
  83359. * @param name Define the name of the uniform as defined in the shader
  83360. * @param value Define the value to give to the uniform
  83361. * @return the material itself allowing "fluent" like uniform updates
  83362. */
  83363. setInt(name: string, value: number): ShaderMaterial;
  83364. /**
  83365. * Set an array of floats in the shader.
  83366. * @param name Define the name of the uniform as defined in the shader
  83367. * @param value Define the value to give to the uniform
  83368. * @return the material itself allowing "fluent" like uniform updates
  83369. */
  83370. setFloats(name: string, value: number[]): ShaderMaterial;
  83371. /**
  83372. * Set a vec3 in the shader from a Color3.
  83373. * @param name Define the name of the uniform as defined in the shader
  83374. * @param value Define the value to give to the uniform
  83375. * @return the material itself allowing "fluent" like uniform updates
  83376. */
  83377. setColor3(name: string, value: Color3): ShaderMaterial;
  83378. /**
  83379. * Set a vec3 array in the shader from a Color3 array.
  83380. * @param name Define the name of the uniform as defined in the shader
  83381. * @param value Define the value to give to the uniform
  83382. * @return the material itself allowing "fluent" like uniform updates
  83383. */
  83384. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83385. /**
  83386. * Set a vec4 in the shader from a Color4.
  83387. * @param name Define the name of the uniform as defined in the shader
  83388. * @param value Define the value to give to the uniform
  83389. * @return the material itself allowing "fluent" like uniform updates
  83390. */
  83391. setColor4(name: string, value: Color4): ShaderMaterial;
  83392. /**
  83393. * Set a vec4 array in the shader from a Color4 array.
  83394. * @param name Define the name of the uniform as defined in the shader
  83395. * @param value Define the value to give to the uniform
  83396. * @return the material itself allowing "fluent" like uniform updates
  83397. */
  83398. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83399. /**
  83400. * Set a vec2 in the shader from a Vector2.
  83401. * @param name Define the name of the uniform as defined in the shader
  83402. * @param value Define the value to give to the uniform
  83403. * @return the material itself allowing "fluent" like uniform updates
  83404. */
  83405. setVector2(name: string, value: Vector2): ShaderMaterial;
  83406. /**
  83407. * Set a vec3 in the shader from a Vector3.
  83408. * @param name Define the name of the uniform as defined in the shader
  83409. * @param value Define the value to give to the uniform
  83410. * @return the material itself allowing "fluent" like uniform updates
  83411. */
  83412. setVector3(name: string, value: Vector3): ShaderMaterial;
  83413. /**
  83414. * Set a vec4 in the shader from a Vector4.
  83415. * @param name Define the name of the uniform as defined in the shader
  83416. * @param value Define the value to give to the uniform
  83417. * @return the material itself allowing "fluent" like uniform updates
  83418. */
  83419. setVector4(name: string, value: Vector4): ShaderMaterial;
  83420. /**
  83421. * Set a mat4 in the shader from a Matrix.
  83422. * @param name Define the name of the uniform as defined in the shader
  83423. * @param value Define the value to give to the uniform
  83424. * @return the material itself allowing "fluent" like uniform updates
  83425. */
  83426. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83427. /**
  83428. * Set a mat3 in the shader from a Float32Array.
  83429. * @param name Define the name of the uniform as defined in the shader
  83430. * @param value Define the value to give to the uniform
  83431. * @return the material itself allowing "fluent" like uniform updates
  83432. */
  83433. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83434. /**
  83435. * Set a mat2 in the shader from a Float32Array.
  83436. * @param name Define the name of the uniform as defined in the shader
  83437. * @param value Define the value to give to the uniform
  83438. * @return the material itself allowing "fluent" like uniform updates
  83439. */
  83440. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83441. /**
  83442. * Set a vec2 array in the shader from a number array.
  83443. * @param name Define the name of the uniform as defined in the shader
  83444. * @param value Define the value to give to the uniform
  83445. * @return the material itself allowing "fluent" like uniform updates
  83446. */
  83447. setArray2(name: string, value: number[]): ShaderMaterial;
  83448. /**
  83449. * Set a vec3 array in the shader from a number array.
  83450. * @param name Define the name of the uniform as defined in the shader
  83451. * @param value Define the value to give to the uniform
  83452. * @return the material itself allowing "fluent" like uniform updates
  83453. */
  83454. setArray3(name: string, value: number[]): ShaderMaterial;
  83455. /**
  83456. * Set a vec4 array in the shader from a number array.
  83457. * @param name Define the name of the uniform as defined in the shader
  83458. * @param value Define the value to give to the uniform
  83459. * @return the material itself allowing "fluent" like uniform updates
  83460. */
  83461. setArray4(name: string, value: number[]): ShaderMaterial;
  83462. private _checkCache;
  83463. /**
  83464. * Specifies that the submesh is ready to be used
  83465. * @param mesh defines the mesh to check
  83466. * @param subMesh defines which submesh to check
  83467. * @param useInstances specifies that instances should be used
  83468. * @returns a boolean indicating that the submesh is ready or not
  83469. */
  83470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83471. /**
  83472. * Checks if the material is ready to render the requested mesh
  83473. * @param mesh Define the mesh to render
  83474. * @param useInstances Define whether or not the material is used with instances
  83475. * @returns true if ready, otherwise false
  83476. */
  83477. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83478. /**
  83479. * Binds the world matrix to the material
  83480. * @param world defines the world transformation matrix
  83481. */
  83482. bindOnlyWorldMatrix(world: Matrix): void;
  83483. /**
  83484. * Binds the material to the mesh
  83485. * @param world defines the world transformation matrix
  83486. * @param mesh defines the mesh to bind the material to
  83487. */
  83488. bind(world: Matrix, mesh?: Mesh): void;
  83489. /**
  83490. * Gets the active textures from the material
  83491. * @returns an array of textures
  83492. */
  83493. getActiveTextures(): BaseTexture[];
  83494. /**
  83495. * Specifies if the material uses a texture
  83496. * @param texture defines the texture to check against the material
  83497. * @returns a boolean specifying if the material uses the texture
  83498. */
  83499. hasTexture(texture: BaseTexture): boolean;
  83500. /**
  83501. * Makes a duplicate of the material, and gives it a new name
  83502. * @param name defines the new name for the duplicated material
  83503. * @returns the cloned material
  83504. */
  83505. clone(name: string): ShaderMaterial;
  83506. /**
  83507. * Disposes the material
  83508. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83509. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83510. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83511. */
  83512. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83513. /**
  83514. * Serializes this material in a JSON representation
  83515. * @returns the serialized material object
  83516. */
  83517. serialize(): any;
  83518. /**
  83519. * Creates a shader material from parsed shader material data
  83520. * @param source defines the JSON represnetation of the material
  83521. * @param scene defines the hosting scene
  83522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83523. * @returns a new material
  83524. */
  83525. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83526. }
  83527. }
  83528. declare module BABYLON {
  83529. /** @hidden */
  83530. export var colorPixelShader: {
  83531. name: string;
  83532. shader: string;
  83533. };
  83534. }
  83535. declare module BABYLON {
  83536. /** @hidden */
  83537. export var colorVertexShader: {
  83538. name: string;
  83539. shader: string;
  83540. };
  83541. }
  83542. declare module BABYLON {
  83543. /**
  83544. * Line mesh
  83545. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83546. */
  83547. export class LinesMesh extends Mesh {
  83548. /**
  83549. * If vertex color should be applied to the mesh
  83550. */
  83551. readonly useVertexColor?: boolean | undefined;
  83552. /**
  83553. * If vertex alpha should be applied to the mesh
  83554. */
  83555. readonly useVertexAlpha?: boolean | undefined;
  83556. /**
  83557. * Color of the line (Default: White)
  83558. */
  83559. color: Color3;
  83560. /**
  83561. * Alpha of the line (Default: 1)
  83562. */
  83563. alpha: number;
  83564. /**
  83565. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83566. * This margin is expressed in world space coordinates, so its value may vary.
  83567. * Default value is 0.1
  83568. */
  83569. intersectionThreshold: number;
  83570. private _colorShader;
  83571. private color4;
  83572. /**
  83573. * Creates a new LinesMesh
  83574. * @param name defines the name
  83575. * @param scene defines the hosting scene
  83576. * @param parent defines the parent mesh if any
  83577. * @param source defines the optional source LinesMesh used to clone data from
  83578. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83579. * When false, achieved by calling a clone(), also passing False.
  83580. * This will make creation of children, recursive.
  83581. * @param useVertexColor defines if this LinesMesh supports vertex color
  83582. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83583. */
  83584. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83585. /**
  83586. * If vertex color should be applied to the mesh
  83587. */
  83588. useVertexColor?: boolean | undefined,
  83589. /**
  83590. * If vertex alpha should be applied to the mesh
  83591. */
  83592. useVertexAlpha?: boolean | undefined);
  83593. private _addClipPlaneDefine;
  83594. private _removeClipPlaneDefine;
  83595. isReady(): boolean;
  83596. /**
  83597. * Returns the string "LineMesh"
  83598. */
  83599. getClassName(): string;
  83600. /**
  83601. * @hidden
  83602. */
  83603. /**
  83604. * @hidden
  83605. */
  83606. material: Material;
  83607. /**
  83608. * @hidden
  83609. */
  83610. readonly checkCollisions: boolean;
  83611. /** @hidden */
  83612. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83613. /** @hidden */
  83614. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83615. /**
  83616. * Disposes of the line mesh
  83617. * @param doNotRecurse If children should be disposed
  83618. */
  83619. dispose(doNotRecurse?: boolean): void;
  83620. /**
  83621. * Returns a new LineMesh object cloned from the current one.
  83622. */
  83623. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83624. /**
  83625. * Creates a new InstancedLinesMesh object from the mesh model.
  83626. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83627. * @param name defines the name of the new instance
  83628. * @returns a new InstancedLinesMesh
  83629. */
  83630. createInstance(name: string): InstancedLinesMesh;
  83631. }
  83632. /**
  83633. * Creates an instance based on a source LinesMesh
  83634. */
  83635. export class InstancedLinesMesh extends InstancedMesh {
  83636. /**
  83637. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83638. * This margin is expressed in world space coordinates, so its value may vary.
  83639. * Initilized with the intersectionThreshold value of the source LinesMesh
  83640. */
  83641. intersectionThreshold: number;
  83642. constructor(name: string, source: LinesMesh);
  83643. /**
  83644. * Returns the string "InstancedLinesMesh".
  83645. */
  83646. getClassName(): string;
  83647. }
  83648. }
  83649. declare module BABYLON {
  83650. /** @hidden */
  83651. export var linePixelShader: {
  83652. name: string;
  83653. shader: string;
  83654. };
  83655. }
  83656. declare module BABYLON {
  83657. /** @hidden */
  83658. export var lineVertexShader: {
  83659. name: string;
  83660. shader: string;
  83661. };
  83662. }
  83663. declare module BABYLON {
  83664. interface AbstractMesh {
  83665. /**
  83666. * Gets the edgesRenderer associated with the mesh
  83667. */
  83668. edgesRenderer: Nullable<EdgesRenderer>;
  83669. }
  83670. interface LinesMesh {
  83671. /**
  83672. * Enables the edge rendering mode on the mesh.
  83673. * This mode makes the mesh edges visible
  83674. * @param epsilon defines the maximal distance between two angles to detect a face
  83675. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83676. * @returns the currentAbstractMesh
  83677. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83678. */
  83679. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83680. }
  83681. interface InstancedLinesMesh {
  83682. /**
  83683. * Enables the edge rendering mode on the mesh.
  83684. * This mode makes the mesh edges visible
  83685. * @param epsilon defines the maximal distance between two angles to detect a face
  83686. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83687. * @returns the current InstancedLinesMesh
  83688. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83689. */
  83690. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83691. }
  83692. /**
  83693. * Defines the minimum contract an Edges renderer should follow.
  83694. */
  83695. export interface IEdgesRenderer extends IDisposable {
  83696. /**
  83697. * Gets or sets a boolean indicating if the edgesRenderer is active
  83698. */
  83699. isEnabled: boolean;
  83700. /**
  83701. * Renders the edges of the attached mesh,
  83702. */
  83703. render(): void;
  83704. /**
  83705. * Checks wether or not the edges renderer is ready to render.
  83706. * @return true if ready, otherwise false.
  83707. */
  83708. isReady(): boolean;
  83709. }
  83710. /**
  83711. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83712. */
  83713. export class EdgesRenderer implements IEdgesRenderer {
  83714. /**
  83715. * Define the size of the edges with an orthographic camera
  83716. */
  83717. edgesWidthScalerForOrthographic: number;
  83718. /**
  83719. * Define the size of the edges with a perspective camera
  83720. */
  83721. edgesWidthScalerForPerspective: number;
  83722. protected _source: AbstractMesh;
  83723. protected _linesPositions: number[];
  83724. protected _linesNormals: number[];
  83725. protected _linesIndices: number[];
  83726. protected _epsilon: number;
  83727. protected _indicesCount: number;
  83728. protected _lineShader: ShaderMaterial;
  83729. protected _ib: DataBuffer;
  83730. protected _buffers: {
  83731. [key: string]: Nullable<VertexBuffer>;
  83732. };
  83733. protected _checkVerticesInsteadOfIndices: boolean;
  83734. private _meshRebuildObserver;
  83735. private _meshDisposeObserver;
  83736. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83737. isEnabled: boolean;
  83738. /**
  83739. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83740. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83741. * @param source Mesh used to create edges
  83742. * @param epsilon sum of angles in adjacency to check for edge
  83743. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83744. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83745. */
  83746. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83747. protected _prepareRessources(): void;
  83748. /** @hidden */
  83749. _rebuild(): void;
  83750. /**
  83751. * Releases the required resources for the edges renderer
  83752. */
  83753. dispose(): void;
  83754. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83755. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83756. /**
  83757. * Checks if the pair of p0 and p1 is en edge
  83758. * @param faceIndex
  83759. * @param edge
  83760. * @param faceNormals
  83761. * @param p0
  83762. * @param p1
  83763. * @private
  83764. */
  83765. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83766. /**
  83767. * push line into the position, normal and index buffer
  83768. * @protected
  83769. */
  83770. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83771. /**
  83772. * Generates lines edges from adjacencjes
  83773. * @private
  83774. */
  83775. _generateEdgesLines(): void;
  83776. /**
  83777. * Checks wether or not the edges renderer is ready to render.
  83778. * @return true if ready, otherwise false.
  83779. */
  83780. isReady(): boolean;
  83781. /**
  83782. * Renders the edges of the attached mesh,
  83783. */
  83784. render(): void;
  83785. }
  83786. /**
  83787. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83788. */
  83789. export class LineEdgesRenderer extends EdgesRenderer {
  83790. /**
  83791. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83792. * @param source LineMesh used to generate edges
  83793. * @param epsilon not important (specified angle for edge detection)
  83794. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83795. */
  83796. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83797. /**
  83798. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83799. */
  83800. _generateEdgesLines(): void;
  83801. }
  83802. }
  83803. declare module BABYLON {
  83804. /**
  83805. * This represents the object necessary to create a rendering group.
  83806. * This is exclusively used and created by the rendering manager.
  83807. * To modify the behavior, you use the available helpers in your scene or meshes.
  83808. * @hidden
  83809. */
  83810. export class RenderingGroup {
  83811. index: number;
  83812. private static _zeroVector;
  83813. private _scene;
  83814. private _opaqueSubMeshes;
  83815. private _transparentSubMeshes;
  83816. private _alphaTestSubMeshes;
  83817. private _depthOnlySubMeshes;
  83818. private _particleSystems;
  83819. private _spriteManagers;
  83820. private _opaqueSortCompareFn;
  83821. private _alphaTestSortCompareFn;
  83822. private _transparentSortCompareFn;
  83823. private _renderOpaque;
  83824. private _renderAlphaTest;
  83825. private _renderTransparent;
  83826. /** @hidden */
  83827. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83828. onBeforeTransparentRendering: () => void;
  83829. /**
  83830. * Set the opaque sort comparison function.
  83831. * If null the sub meshes will be render in the order they were created
  83832. */
  83833. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83834. /**
  83835. * Set the alpha test sort comparison function.
  83836. * If null the sub meshes will be render in the order they were created
  83837. */
  83838. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83839. /**
  83840. * Set the transparent sort comparison function.
  83841. * If null the sub meshes will be render in the order they were created
  83842. */
  83843. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83844. /**
  83845. * Creates a new rendering group.
  83846. * @param index The rendering group index
  83847. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83848. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83849. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83850. */
  83851. 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>);
  83852. /**
  83853. * Render all the sub meshes contained in the group.
  83854. * @param customRenderFunction Used to override the default render behaviour of the group.
  83855. * @returns true if rendered some submeshes.
  83856. */
  83857. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83858. /**
  83859. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83860. * @param subMeshes The submeshes to render
  83861. */
  83862. private renderOpaqueSorted;
  83863. /**
  83864. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83865. * @param subMeshes The submeshes to render
  83866. */
  83867. private renderAlphaTestSorted;
  83868. /**
  83869. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83870. * @param subMeshes The submeshes to render
  83871. */
  83872. private renderTransparentSorted;
  83873. /**
  83874. * Renders the submeshes in a specified order.
  83875. * @param subMeshes The submeshes to sort before render
  83876. * @param sortCompareFn The comparison function use to sort
  83877. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83878. * @param transparent Specifies to activate blending if true
  83879. */
  83880. private static renderSorted;
  83881. /**
  83882. * Renders the submeshes in the order they were dispatched (no sort applied).
  83883. * @param subMeshes The submeshes to render
  83884. */
  83885. private static renderUnsorted;
  83886. /**
  83887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83888. * are rendered back to front if in the same alpha index.
  83889. *
  83890. * @param a The first submesh
  83891. * @param b The second submesh
  83892. * @returns The result of the comparison
  83893. */
  83894. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83895. /**
  83896. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83897. * are rendered back to front.
  83898. *
  83899. * @param a The first submesh
  83900. * @param b The second submesh
  83901. * @returns The result of the comparison
  83902. */
  83903. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83904. /**
  83905. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83906. * are rendered front to back (prevent overdraw).
  83907. *
  83908. * @param a The first submesh
  83909. * @param b The second submesh
  83910. * @returns The result of the comparison
  83911. */
  83912. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83913. /**
  83914. * Resets the different lists of submeshes to prepare a new frame.
  83915. */
  83916. prepare(): void;
  83917. dispose(): void;
  83918. /**
  83919. * Inserts the submesh in its correct queue depending on its material.
  83920. * @param subMesh The submesh to dispatch
  83921. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83922. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83923. */
  83924. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83925. dispatchSprites(spriteManager: ISpriteManager): void;
  83926. dispatchParticles(particleSystem: IParticleSystem): void;
  83927. private _renderParticles;
  83928. private _renderSprites;
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /**
  83933. * Interface describing the different options available in the rendering manager
  83934. * regarding Auto Clear between groups.
  83935. */
  83936. export interface IRenderingManagerAutoClearSetup {
  83937. /**
  83938. * Defines whether or not autoclear is enable.
  83939. */
  83940. autoClear: boolean;
  83941. /**
  83942. * Defines whether or not to autoclear the depth buffer.
  83943. */
  83944. depth: boolean;
  83945. /**
  83946. * Defines whether or not to autoclear the stencil buffer.
  83947. */
  83948. stencil: boolean;
  83949. }
  83950. /**
  83951. * This class is used by the onRenderingGroupObservable
  83952. */
  83953. export class RenderingGroupInfo {
  83954. /**
  83955. * The Scene that being rendered
  83956. */
  83957. scene: Scene;
  83958. /**
  83959. * The camera currently used for the rendering pass
  83960. */
  83961. camera: Nullable<Camera>;
  83962. /**
  83963. * The ID of the renderingGroup being processed
  83964. */
  83965. renderingGroupId: number;
  83966. }
  83967. /**
  83968. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83969. * It is enable to manage the different groups as well as the different necessary sort functions.
  83970. * This should not be used directly aside of the few static configurations
  83971. */
  83972. export class RenderingManager {
  83973. /**
  83974. * The max id used for rendering groups (not included)
  83975. */
  83976. static MAX_RENDERINGGROUPS: number;
  83977. /**
  83978. * The min id used for rendering groups (included)
  83979. */
  83980. static MIN_RENDERINGGROUPS: number;
  83981. /**
  83982. * Used to globally prevent autoclearing scenes.
  83983. */
  83984. static AUTOCLEAR: boolean;
  83985. /**
  83986. * @hidden
  83987. */
  83988. _useSceneAutoClearSetup: boolean;
  83989. private _scene;
  83990. private _renderingGroups;
  83991. private _depthStencilBufferAlreadyCleaned;
  83992. private _autoClearDepthStencil;
  83993. private _customOpaqueSortCompareFn;
  83994. private _customAlphaTestSortCompareFn;
  83995. private _customTransparentSortCompareFn;
  83996. private _renderingGroupInfo;
  83997. /**
  83998. * Instantiates a new rendering group for a particular scene
  83999. * @param scene Defines the scene the groups belongs to
  84000. */
  84001. constructor(scene: Scene);
  84002. private _clearDepthStencilBuffer;
  84003. /**
  84004. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84005. * @hidden
  84006. */
  84007. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84008. /**
  84009. * Resets the different information of the group to prepare a new frame
  84010. * @hidden
  84011. */
  84012. reset(): void;
  84013. /**
  84014. * Dispose and release the group and its associated resources.
  84015. * @hidden
  84016. */
  84017. dispose(): void;
  84018. /**
  84019. * Clear the info related to rendering groups preventing retention points during dispose.
  84020. */
  84021. freeRenderingGroups(): void;
  84022. private _prepareRenderingGroup;
  84023. /**
  84024. * Add a sprite manager to the rendering manager in order to render it this frame.
  84025. * @param spriteManager Define the sprite manager to render
  84026. */
  84027. dispatchSprites(spriteManager: ISpriteManager): void;
  84028. /**
  84029. * Add a particle system to the rendering manager in order to render it this frame.
  84030. * @param particleSystem Define the particle system to render
  84031. */
  84032. dispatchParticles(particleSystem: IParticleSystem): void;
  84033. /**
  84034. * Add a submesh to the manager in order to render it this frame
  84035. * @param subMesh The submesh to dispatch
  84036. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84037. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84038. */
  84039. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84040. /**
  84041. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84042. * This allowed control for front to back rendering or reversly depending of the special needs.
  84043. *
  84044. * @param renderingGroupId The rendering group id corresponding to its index
  84045. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84046. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84047. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84048. */
  84049. 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;
  84050. /**
  84051. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84052. *
  84053. * @param renderingGroupId The rendering group id corresponding to its index
  84054. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84055. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84056. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84057. */
  84058. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84059. /**
  84060. * Gets the current auto clear configuration for one rendering group of the rendering
  84061. * manager.
  84062. * @param index the rendering group index to get the information for
  84063. * @returns The auto clear setup for the requested rendering group
  84064. */
  84065. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84066. }
  84067. }
  84068. declare module BABYLON {
  84069. /**
  84070. * This Helps creating a texture that will be created from a camera in your scene.
  84071. * It is basically a dynamic texture that could be used to create special effects for instance.
  84072. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84073. */
  84074. export class RenderTargetTexture extends Texture {
  84075. isCube: boolean;
  84076. /**
  84077. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84078. */
  84079. static readonly REFRESHRATE_RENDER_ONCE: number;
  84080. /**
  84081. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84082. */
  84083. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84084. /**
  84085. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84086. * the central point of your effect and can save a lot of performances.
  84087. */
  84088. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84089. /**
  84090. * Use this predicate to dynamically define the list of mesh you want to render.
  84091. * If set, the renderList property will be overwritten.
  84092. */
  84093. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84094. private _renderList;
  84095. /**
  84096. * Use this list to define the list of mesh you want to render.
  84097. */
  84098. renderList: Nullable<Array<AbstractMesh>>;
  84099. private _hookArray;
  84100. /**
  84101. * Define if particles should be rendered in your texture.
  84102. */
  84103. renderParticles: boolean;
  84104. /**
  84105. * Define if sprites should be rendered in your texture.
  84106. */
  84107. renderSprites: boolean;
  84108. /**
  84109. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84110. */
  84111. coordinatesMode: number;
  84112. /**
  84113. * Define the camera used to render the texture.
  84114. */
  84115. activeCamera: Nullable<Camera>;
  84116. /**
  84117. * Override the render function of the texture with your own one.
  84118. */
  84119. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84120. /**
  84121. * Define if camera post processes should be use while rendering the texture.
  84122. */
  84123. useCameraPostProcesses: boolean;
  84124. /**
  84125. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84126. */
  84127. ignoreCameraViewport: boolean;
  84128. private _postProcessManager;
  84129. private _postProcesses;
  84130. private _resizeObserver;
  84131. /**
  84132. * An event triggered when the texture is unbind.
  84133. */
  84134. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84135. /**
  84136. * An event triggered when the texture is unbind.
  84137. */
  84138. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84139. private _onAfterUnbindObserver;
  84140. /**
  84141. * Set a after unbind callback in the texture.
  84142. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84143. */
  84144. onAfterUnbind: () => void;
  84145. /**
  84146. * An event triggered before rendering the texture
  84147. */
  84148. onBeforeRenderObservable: Observable<number>;
  84149. private _onBeforeRenderObserver;
  84150. /**
  84151. * Set a before render callback in the texture.
  84152. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84153. */
  84154. onBeforeRender: (faceIndex: number) => void;
  84155. /**
  84156. * An event triggered after rendering the texture
  84157. */
  84158. onAfterRenderObservable: Observable<number>;
  84159. private _onAfterRenderObserver;
  84160. /**
  84161. * Set a after render callback in the texture.
  84162. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84163. */
  84164. onAfterRender: (faceIndex: number) => void;
  84165. /**
  84166. * An event triggered after the texture clear
  84167. */
  84168. onClearObservable: Observable<Engine>;
  84169. private _onClearObserver;
  84170. /**
  84171. * Set a clear callback in the texture.
  84172. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84173. */
  84174. onClear: (Engine: Engine) => void;
  84175. /**
  84176. * An event triggered when the texture is resized.
  84177. */
  84178. onResizeObservable: Observable<RenderTargetTexture>;
  84179. /**
  84180. * Define the clear color of the Render Target if it should be different from the scene.
  84181. */
  84182. clearColor: Color4;
  84183. protected _size: number | {
  84184. width: number;
  84185. height: number;
  84186. };
  84187. protected _initialSizeParameter: number | {
  84188. width: number;
  84189. height: number;
  84190. } | {
  84191. ratio: number;
  84192. };
  84193. protected _sizeRatio: Nullable<number>;
  84194. /** @hidden */
  84195. _generateMipMaps: boolean;
  84196. protected _renderingManager: RenderingManager;
  84197. /** @hidden */
  84198. _waitingRenderList: string[];
  84199. protected _doNotChangeAspectRatio: boolean;
  84200. protected _currentRefreshId: number;
  84201. protected _refreshRate: number;
  84202. protected _textureMatrix: Matrix;
  84203. protected _samples: number;
  84204. protected _renderTargetOptions: RenderTargetCreationOptions;
  84205. /**
  84206. * Gets render target creation options that were used.
  84207. */
  84208. readonly renderTargetOptions: RenderTargetCreationOptions;
  84209. protected _engine: Engine;
  84210. protected _onRatioRescale(): void;
  84211. /**
  84212. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84213. * It must define where the camera used to render the texture is set
  84214. */
  84215. boundingBoxPosition: Vector3;
  84216. private _boundingBoxSize;
  84217. /**
  84218. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84219. * When defined, the cubemap will switch to local mode
  84220. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84221. * @example https://www.babylonjs-playground.com/#RNASML
  84222. */
  84223. boundingBoxSize: Vector3;
  84224. /**
  84225. * In case the RTT has been created with a depth texture, get the associated
  84226. * depth texture.
  84227. * Otherwise, return null.
  84228. */
  84229. depthStencilTexture: Nullable<InternalTexture>;
  84230. /**
  84231. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84232. * or used a shadow, depth texture...
  84233. * @param name The friendly name of the texture
  84234. * @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)
  84235. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84236. * @param generateMipMaps True if mip maps need to be generated after render.
  84237. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84238. * @param type The type of the buffer in the RTT (int, half float, float...)
  84239. * @param isCube True if a cube texture needs to be created
  84240. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84241. * @param generateDepthBuffer True to generate a depth buffer
  84242. * @param generateStencilBuffer True to generate a stencil buffer
  84243. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84244. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84245. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84246. */
  84247. constructor(name: string, size: number | {
  84248. width: number;
  84249. height: number;
  84250. } | {
  84251. ratio: number;
  84252. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84253. /**
  84254. * Creates a depth stencil texture.
  84255. * This is only available in WebGL 2 or with the depth texture extension available.
  84256. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84257. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84258. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84259. */
  84260. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84261. private _processSizeParameter;
  84262. /**
  84263. * Define the number of samples to use in case of MSAA.
  84264. * It defaults to one meaning no MSAA has been enabled.
  84265. */
  84266. samples: number;
  84267. /**
  84268. * Resets the refresh counter of the texture and start bak from scratch.
  84269. * Could be useful to regenerate the texture if it is setup to render only once.
  84270. */
  84271. resetRefreshCounter(): void;
  84272. /**
  84273. * Define the refresh rate of the texture or the rendering frequency.
  84274. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84275. */
  84276. refreshRate: number;
  84277. /**
  84278. * Adds a post process to the render target rendering passes.
  84279. * @param postProcess define the post process to add
  84280. */
  84281. addPostProcess(postProcess: PostProcess): void;
  84282. /**
  84283. * Clear all the post processes attached to the render target
  84284. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84285. */
  84286. clearPostProcesses(dispose?: boolean): void;
  84287. /**
  84288. * Remove one of the post process from the list of attached post processes to the texture
  84289. * @param postProcess define the post process to remove from the list
  84290. */
  84291. removePostProcess(postProcess: PostProcess): void;
  84292. /** @hidden */
  84293. _shouldRender(): boolean;
  84294. /**
  84295. * Gets the actual render size of the texture.
  84296. * @returns the width of the render size
  84297. */
  84298. getRenderSize(): number;
  84299. /**
  84300. * Gets the actual render width of the texture.
  84301. * @returns the width of the render size
  84302. */
  84303. getRenderWidth(): number;
  84304. /**
  84305. * Gets the actual render height of the texture.
  84306. * @returns the height of the render size
  84307. */
  84308. getRenderHeight(): number;
  84309. /**
  84310. * Get if the texture can be rescaled or not.
  84311. */
  84312. readonly canRescale: boolean;
  84313. /**
  84314. * Resize the texture using a ratio.
  84315. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84316. */
  84317. scale(ratio: number): void;
  84318. /**
  84319. * Get the texture reflection matrix used to rotate/transform the reflection.
  84320. * @returns the reflection matrix
  84321. */
  84322. getReflectionTextureMatrix(): Matrix;
  84323. /**
  84324. * Resize the texture to a new desired size.
  84325. * Be carrefull as it will recreate all the data in the new texture.
  84326. * @param size Define the new size. It can be:
  84327. * - a number for squared texture,
  84328. * - an object containing { width: number, height: number }
  84329. * - or an object containing a ratio { ratio: number }
  84330. */
  84331. resize(size: number | {
  84332. width: number;
  84333. height: number;
  84334. } | {
  84335. ratio: number;
  84336. }): void;
  84337. /**
  84338. * Renders all the objects from the render list into the texture.
  84339. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84340. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84341. */
  84342. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84343. private _bestReflectionRenderTargetDimension;
  84344. /**
  84345. * @hidden
  84346. * @param faceIndex face index to bind to if this is a cubetexture
  84347. */
  84348. _bindFrameBuffer(faceIndex?: number): void;
  84349. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84350. private renderToTarget;
  84351. /**
  84352. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84353. * This allowed control for front to back rendering or reversly depending of the special needs.
  84354. *
  84355. * @param renderingGroupId The rendering group id corresponding to its index
  84356. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84357. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84358. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84359. */
  84360. 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;
  84361. /**
  84362. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84363. *
  84364. * @param renderingGroupId The rendering group id corresponding to its index
  84365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84366. */
  84367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84368. /**
  84369. * Clones the texture.
  84370. * @returns the cloned texture
  84371. */
  84372. clone(): RenderTargetTexture;
  84373. /**
  84374. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84375. * @returns The JSON representation of the texture
  84376. */
  84377. serialize(): any;
  84378. /**
  84379. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84380. */
  84381. disposeFramebufferObjects(): void;
  84382. /**
  84383. * Dispose the texture and release its associated resources.
  84384. */
  84385. dispose(): void;
  84386. /** @hidden */
  84387. _rebuild(): void;
  84388. /**
  84389. * Clear the info related to rendering groups preventing retention point in material dispose.
  84390. */
  84391. freeRenderingGroups(): void;
  84392. /**
  84393. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84394. * @returns the view count
  84395. */
  84396. getViewCount(): number;
  84397. }
  84398. }
  84399. declare module BABYLON {
  84400. /**
  84401. * Base class for the main features of a material in Babylon.js
  84402. */
  84403. export class Material implements IAnimatable {
  84404. /**
  84405. * Returns the triangle fill mode
  84406. */
  84407. static readonly TriangleFillMode: number;
  84408. /**
  84409. * Returns the wireframe mode
  84410. */
  84411. static readonly WireFrameFillMode: number;
  84412. /**
  84413. * Returns the point fill mode
  84414. */
  84415. static readonly PointFillMode: number;
  84416. /**
  84417. * Returns the point list draw mode
  84418. */
  84419. static readonly PointListDrawMode: number;
  84420. /**
  84421. * Returns the line list draw mode
  84422. */
  84423. static readonly LineListDrawMode: number;
  84424. /**
  84425. * Returns the line loop draw mode
  84426. */
  84427. static readonly LineLoopDrawMode: number;
  84428. /**
  84429. * Returns the line strip draw mode
  84430. */
  84431. static readonly LineStripDrawMode: number;
  84432. /**
  84433. * Returns the triangle strip draw mode
  84434. */
  84435. static readonly TriangleStripDrawMode: number;
  84436. /**
  84437. * Returns the triangle fan draw mode
  84438. */
  84439. static readonly TriangleFanDrawMode: number;
  84440. /**
  84441. * Stores the clock-wise side orientation
  84442. */
  84443. static readonly ClockWiseSideOrientation: number;
  84444. /**
  84445. * Stores the counter clock-wise side orientation
  84446. */
  84447. static readonly CounterClockWiseSideOrientation: number;
  84448. /**
  84449. * The dirty texture flag value
  84450. */
  84451. static readonly TextureDirtyFlag: number;
  84452. /**
  84453. * The dirty light flag value
  84454. */
  84455. static readonly LightDirtyFlag: number;
  84456. /**
  84457. * The dirty fresnel flag value
  84458. */
  84459. static readonly FresnelDirtyFlag: number;
  84460. /**
  84461. * The dirty attribute flag value
  84462. */
  84463. static readonly AttributesDirtyFlag: number;
  84464. /**
  84465. * The dirty misc flag value
  84466. */
  84467. static readonly MiscDirtyFlag: number;
  84468. /**
  84469. * The all dirty flag value
  84470. */
  84471. static readonly AllDirtyFlag: number;
  84472. /**
  84473. * The ID of the material
  84474. */
  84475. id: string;
  84476. /**
  84477. * Gets or sets the unique id of the material
  84478. */
  84479. uniqueId: number;
  84480. /**
  84481. * The name of the material
  84482. */
  84483. name: string;
  84484. /**
  84485. * Gets or sets user defined metadata
  84486. */
  84487. metadata: any;
  84488. /**
  84489. * For internal use only. Please do not use.
  84490. */
  84491. reservedDataStore: any;
  84492. /**
  84493. * Specifies if the ready state should be checked on each call
  84494. */
  84495. checkReadyOnEveryCall: boolean;
  84496. /**
  84497. * Specifies if the ready state should be checked once
  84498. */
  84499. checkReadyOnlyOnce: boolean;
  84500. /**
  84501. * The state of the material
  84502. */
  84503. state: string;
  84504. /**
  84505. * The alpha value of the material
  84506. */
  84507. protected _alpha: number;
  84508. /**
  84509. * List of inspectable custom properties (used by the Inspector)
  84510. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84511. */
  84512. inspectableCustomProperties: IInspectable[];
  84513. /**
  84514. * Sets the alpha value of the material
  84515. */
  84516. /**
  84517. * Gets the alpha value of the material
  84518. */
  84519. alpha: number;
  84520. /**
  84521. * Specifies if back face culling is enabled
  84522. */
  84523. protected _backFaceCulling: boolean;
  84524. /**
  84525. * Sets the back-face culling state
  84526. */
  84527. /**
  84528. * Gets the back-face culling state
  84529. */
  84530. backFaceCulling: boolean;
  84531. /**
  84532. * Stores the value for side orientation
  84533. */
  84534. sideOrientation: number;
  84535. /**
  84536. * Callback triggered when the material is compiled
  84537. */
  84538. onCompiled: Nullable<(effect: Effect) => void>;
  84539. /**
  84540. * Callback triggered when an error occurs
  84541. */
  84542. onError: Nullable<(effect: Effect, errors: string) => void>;
  84543. /**
  84544. * Callback triggered to get the render target textures
  84545. */
  84546. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84547. /**
  84548. * Gets a boolean indicating that current material needs to register RTT
  84549. */
  84550. readonly hasRenderTargetTextures: boolean;
  84551. /**
  84552. * Specifies if the material should be serialized
  84553. */
  84554. doNotSerialize: boolean;
  84555. /**
  84556. * @hidden
  84557. */
  84558. _storeEffectOnSubMeshes: boolean;
  84559. /**
  84560. * Stores the animations for the material
  84561. */
  84562. animations: Nullable<Array<Animation>>;
  84563. /**
  84564. * An event triggered when the material is disposed
  84565. */
  84566. onDisposeObservable: Observable<Material>;
  84567. /**
  84568. * An observer which watches for dispose events
  84569. */
  84570. private _onDisposeObserver;
  84571. private _onUnBindObservable;
  84572. /**
  84573. * Called during a dispose event
  84574. */
  84575. onDispose: () => void;
  84576. private _onBindObservable;
  84577. /**
  84578. * An event triggered when the material is bound
  84579. */
  84580. readonly onBindObservable: Observable<AbstractMesh>;
  84581. /**
  84582. * An observer which watches for bind events
  84583. */
  84584. private _onBindObserver;
  84585. /**
  84586. * Called during a bind event
  84587. */
  84588. onBind: (Mesh: AbstractMesh) => void;
  84589. /**
  84590. * An event triggered when the material is unbound
  84591. */
  84592. readonly onUnBindObservable: Observable<Material>;
  84593. /**
  84594. * Stores the value of the alpha mode
  84595. */
  84596. private _alphaMode;
  84597. /**
  84598. * Sets the value of the alpha mode.
  84599. *
  84600. * | Value | Type | Description |
  84601. * | --- | --- | --- |
  84602. * | 0 | ALPHA_DISABLE | |
  84603. * | 1 | ALPHA_ADD | |
  84604. * | 2 | ALPHA_COMBINE | |
  84605. * | 3 | ALPHA_SUBTRACT | |
  84606. * | 4 | ALPHA_MULTIPLY | |
  84607. * | 5 | ALPHA_MAXIMIZED | |
  84608. * | 6 | ALPHA_ONEONE | |
  84609. * | 7 | ALPHA_PREMULTIPLIED | |
  84610. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84611. * | 9 | ALPHA_INTERPOLATE | |
  84612. * | 10 | ALPHA_SCREENMODE | |
  84613. *
  84614. */
  84615. /**
  84616. * Gets the value of the alpha mode
  84617. */
  84618. alphaMode: number;
  84619. /**
  84620. * Stores the state of the need depth pre-pass value
  84621. */
  84622. private _needDepthPrePass;
  84623. /**
  84624. * Sets the need depth pre-pass value
  84625. */
  84626. /**
  84627. * Gets the depth pre-pass value
  84628. */
  84629. needDepthPrePass: boolean;
  84630. /**
  84631. * Specifies if depth writing should be disabled
  84632. */
  84633. disableDepthWrite: boolean;
  84634. /**
  84635. * Specifies if depth writing should be forced
  84636. */
  84637. forceDepthWrite: boolean;
  84638. /**
  84639. * Specifies if there should be a separate pass for culling
  84640. */
  84641. separateCullingPass: boolean;
  84642. /**
  84643. * Stores the state specifing if fog should be enabled
  84644. */
  84645. private _fogEnabled;
  84646. /**
  84647. * Sets the state for enabling fog
  84648. */
  84649. /**
  84650. * Gets the value of the fog enabled state
  84651. */
  84652. fogEnabled: boolean;
  84653. /**
  84654. * Stores the size of points
  84655. */
  84656. pointSize: number;
  84657. /**
  84658. * Stores the z offset value
  84659. */
  84660. zOffset: number;
  84661. /**
  84662. * Gets a value specifying if wireframe mode is enabled
  84663. */
  84664. /**
  84665. * Sets the state of wireframe mode
  84666. */
  84667. wireframe: boolean;
  84668. /**
  84669. * Gets the value specifying if point clouds are enabled
  84670. */
  84671. /**
  84672. * Sets the state of point cloud mode
  84673. */
  84674. pointsCloud: boolean;
  84675. /**
  84676. * Gets the material fill mode
  84677. */
  84678. /**
  84679. * Sets the material fill mode
  84680. */
  84681. fillMode: number;
  84682. /**
  84683. * @hidden
  84684. * Stores the effects for the material
  84685. */
  84686. _effect: Nullable<Effect>;
  84687. /**
  84688. * @hidden
  84689. * Specifies if the material was previously ready
  84690. */
  84691. _wasPreviouslyReady: boolean;
  84692. /**
  84693. * Specifies if uniform buffers should be used
  84694. */
  84695. private _useUBO;
  84696. /**
  84697. * Stores a reference to the scene
  84698. */
  84699. private _scene;
  84700. /**
  84701. * Stores the fill mode state
  84702. */
  84703. private _fillMode;
  84704. /**
  84705. * Specifies if the depth write state should be cached
  84706. */
  84707. private _cachedDepthWriteState;
  84708. /**
  84709. * Stores the uniform buffer
  84710. */
  84711. protected _uniformBuffer: UniformBuffer;
  84712. /** @hidden */
  84713. _indexInSceneMaterialArray: number;
  84714. /** @hidden */
  84715. meshMap: Nullable<{
  84716. [id: string]: AbstractMesh | undefined;
  84717. }>;
  84718. /**
  84719. * Creates a material instance
  84720. * @param name defines the name of the material
  84721. * @param scene defines the scene to reference
  84722. * @param doNotAdd specifies if the material should be added to the scene
  84723. */
  84724. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84725. /**
  84726. * Returns a string representation of the current material
  84727. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84728. * @returns a string with material information
  84729. */
  84730. toString(fullDetails?: boolean): string;
  84731. /**
  84732. * Gets the class name of the material
  84733. * @returns a string with the class name of the material
  84734. */
  84735. getClassName(): string;
  84736. /**
  84737. * Specifies if updates for the material been locked
  84738. */
  84739. readonly isFrozen: boolean;
  84740. /**
  84741. * Locks updates for the material
  84742. */
  84743. freeze(): void;
  84744. /**
  84745. * Unlocks updates for the material
  84746. */
  84747. unfreeze(): void;
  84748. /**
  84749. * Specifies if the material is ready to be used
  84750. * @param mesh defines the mesh to check
  84751. * @param useInstances specifies if instances should be used
  84752. * @returns a boolean indicating if the material is ready to be used
  84753. */
  84754. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84755. /**
  84756. * Specifies that the submesh is ready to be used
  84757. * @param mesh defines the mesh to check
  84758. * @param subMesh defines which submesh to check
  84759. * @param useInstances specifies that instances should be used
  84760. * @returns a boolean indicating that the submesh is ready or not
  84761. */
  84762. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84763. /**
  84764. * Returns the material effect
  84765. * @returns the effect associated with the material
  84766. */
  84767. getEffect(): Nullable<Effect>;
  84768. /**
  84769. * Returns the current scene
  84770. * @returns a Scene
  84771. */
  84772. getScene(): Scene;
  84773. /**
  84774. * Specifies if the material will require alpha blending
  84775. * @returns a boolean specifying if alpha blending is needed
  84776. */
  84777. needAlphaBlending(): boolean;
  84778. /**
  84779. * Specifies if the mesh will require alpha blending
  84780. * @param mesh defines the mesh to check
  84781. * @returns a boolean specifying if alpha blending is needed for the mesh
  84782. */
  84783. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84784. /**
  84785. * Specifies if this material should be rendered in alpha test mode
  84786. * @returns a boolean specifying if an alpha test is needed.
  84787. */
  84788. needAlphaTesting(): boolean;
  84789. /**
  84790. * Gets the texture used for the alpha test
  84791. * @returns the texture to use for alpha testing
  84792. */
  84793. getAlphaTestTexture(): Nullable<BaseTexture>;
  84794. /**
  84795. * Marks the material to indicate that it needs to be re-calculated
  84796. */
  84797. markDirty(): void;
  84798. /** @hidden */
  84799. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84800. /**
  84801. * Binds the material to the mesh
  84802. * @param world defines the world transformation matrix
  84803. * @param mesh defines the mesh to bind the material to
  84804. */
  84805. bind(world: Matrix, mesh?: Mesh): void;
  84806. /**
  84807. * Binds the submesh to the material
  84808. * @param world defines the world transformation matrix
  84809. * @param mesh defines the mesh containing the submesh
  84810. * @param subMesh defines the submesh to bind the material to
  84811. */
  84812. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84813. /**
  84814. * Binds the world matrix to the material
  84815. * @param world defines the world transformation matrix
  84816. */
  84817. bindOnlyWorldMatrix(world: Matrix): void;
  84818. /**
  84819. * Binds the scene's uniform buffer to the effect.
  84820. * @param effect defines the effect to bind to the scene uniform buffer
  84821. * @param sceneUbo defines the uniform buffer storing scene data
  84822. */
  84823. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84824. /**
  84825. * Binds the view matrix to the effect
  84826. * @param effect defines the effect to bind the view matrix to
  84827. */
  84828. bindView(effect: Effect): void;
  84829. /**
  84830. * Binds the view projection matrix to the effect
  84831. * @param effect defines the effect to bind the view projection matrix to
  84832. */
  84833. bindViewProjection(effect: Effect): void;
  84834. /**
  84835. * Specifies if material alpha testing should be turned on for the mesh
  84836. * @param mesh defines the mesh to check
  84837. */
  84838. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84839. /**
  84840. * Processes to execute after binding the material to a mesh
  84841. * @param mesh defines the rendered mesh
  84842. */
  84843. protected _afterBind(mesh?: Mesh): void;
  84844. /**
  84845. * Unbinds the material from the mesh
  84846. */
  84847. unbind(): void;
  84848. /**
  84849. * Gets the active textures from the material
  84850. * @returns an array of textures
  84851. */
  84852. getActiveTextures(): BaseTexture[];
  84853. /**
  84854. * Specifies if the material uses a texture
  84855. * @param texture defines the texture to check against the material
  84856. * @returns a boolean specifying if the material uses the texture
  84857. */
  84858. hasTexture(texture: BaseTexture): boolean;
  84859. /**
  84860. * Makes a duplicate of the material, and gives it a new name
  84861. * @param name defines the new name for the duplicated material
  84862. * @returns the cloned material
  84863. */
  84864. clone(name: string): Nullable<Material>;
  84865. /**
  84866. * Gets the meshes bound to the material
  84867. * @returns an array of meshes bound to the material
  84868. */
  84869. getBindedMeshes(): AbstractMesh[];
  84870. /**
  84871. * Force shader compilation
  84872. * @param mesh defines the mesh associated with this material
  84873. * @param onCompiled defines a function to execute once the material is compiled
  84874. * @param options defines the options to configure the compilation
  84875. */
  84876. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84877. clipPlane: boolean;
  84878. }>): void;
  84879. /**
  84880. * Force shader compilation
  84881. * @param mesh defines the mesh that will use this material
  84882. * @param options defines additional options for compiling the shaders
  84883. * @returns a promise that resolves when the compilation completes
  84884. */
  84885. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84886. clipPlane: boolean;
  84887. }>): Promise<void>;
  84888. private static readonly _AllDirtyCallBack;
  84889. private static readonly _ImageProcessingDirtyCallBack;
  84890. private static readonly _TextureDirtyCallBack;
  84891. private static readonly _FresnelDirtyCallBack;
  84892. private static readonly _MiscDirtyCallBack;
  84893. private static readonly _LightsDirtyCallBack;
  84894. private static readonly _AttributeDirtyCallBack;
  84895. private static _FresnelAndMiscDirtyCallBack;
  84896. private static _TextureAndMiscDirtyCallBack;
  84897. private static readonly _DirtyCallbackArray;
  84898. private static readonly _RunDirtyCallBacks;
  84899. /**
  84900. * Marks a define in the material to indicate that it needs to be re-computed
  84901. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84902. */
  84903. markAsDirty(flag: number): void;
  84904. /**
  84905. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84906. * @param func defines a function which checks material defines against the submeshes
  84907. */
  84908. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84909. /**
  84910. * Indicates that we need to re-calculated for all submeshes
  84911. */
  84912. protected _markAllSubMeshesAsAllDirty(): void;
  84913. /**
  84914. * Indicates that image processing needs to be re-calculated for all submeshes
  84915. */
  84916. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84917. /**
  84918. * Indicates that textures need to be re-calculated for all submeshes
  84919. */
  84920. protected _markAllSubMeshesAsTexturesDirty(): void;
  84921. /**
  84922. * Indicates that fresnel needs to be re-calculated for all submeshes
  84923. */
  84924. protected _markAllSubMeshesAsFresnelDirty(): void;
  84925. /**
  84926. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84927. */
  84928. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84929. /**
  84930. * Indicates that lights need to be re-calculated for all submeshes
  84931. */
  84932. protected _markAllSubMeshesAsLightsDirty(): void;
  84933. /**
  84934. * Indicates that attributes need to be re-calculated for all submeshes
  84935. */
  84936. protected _markAllSubMeshesAsAttributesDirty(): void;
  84937. /**
  84938. * Indicates that misc needs to be re-calculated for all submeshes
  84939. */
  84940. protected _markAllSubMeshesAsMiscDirty(): void;
  84941. /**
  84942. * Indicates that textures and misc need to be re-calculated for all submeshes
  84943. */
  84944. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84945. /**
  84946. * Disposes the material
  84947. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84948. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84949. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84950. */
  84951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84952. /** @hidden */
  84953. private releaseVertexArrayObject;
  84954. /**
  84955. * Serializes this material
  84956. * @returns the serialized material object
  84957. */
  84958. serialize(): any;
  84959. /**
  84960. * Creates a material from parsed material data
  84961. * @param parsedMaterial defines parsed material data
  84962. * @param scene defines the hosting scene
  84963. * @param rootUrl defines the root URL to use to load textures
  84964. * @returns a new material
  84965. */
  84966. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84967. }
  84968. }
  84969. declare module BABYLON {
  84970. /**
  84971. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84972. * separate meshes. This can be use to improve performances.
  84973. * @see http://doc.babylonjs.com/how_to/multi_materials
  84974. */
  84975. export class MultiMaterial extends Material {
  84976. private _subMaterials;
  84977. /**
  84978. * Gets or Sets the list of Materials used within the multi material.
  84979. * They need to be ordered according to the submeshes order in the associated mesh
  84980. */
  84981. subMaterials: Nullable<Material>[];
  84982. /**
  84983. * Function used to align with Node.getChildren()
  84984. * @returns the list of Materials used within the multi material
  84985. */
  84986. getChildren(): Nullable<Material>[];
  84987. /**
  84988. * Instantiates a new Multi Material
  84989. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84990. * separate meshes. This can be use to improve performances.
  84991. * @see http://doc.babylonjs.com/how_to/multi_materials
  84992. * @param name Define the name in the scene
  84993. * @param scene Define the scene the material belongs to
  84994. */
  84995. constructor(name: string, scene: Scene);
  84996. private _hookArray;
  84997. /**
  84998. * Get one of the submaterial by its index in the submaterials array
  84999. * @param index The index to look the sub material at
  85000. * @returns The Material if the index has been defined
  85001. */
  85002. getSubMaterial(index: number): Nullable<Material>;
  85003. /**
  85004. * Get the list of active textures for the whole sub materials list.
  85005. * @returns All the textures that will be used during the rendering
  85006. */
  85007. getActiveTextures(): BaseTexture[];
  85008. /**
  85009. * Gets the current class name of the material e.g. "MultiMaterial"
  85010. * Mainly use in serialization.
  85011. * @returns the class name
  85012. */
  85013. getClassName(): string;
  85014. /**
  85015. * Checks if the material is ready to render the requested sub mesh
  85016. * @param mesh Define the mesh the submesh belongs to
  85017. * @param subMesh Define the sub mesh to look readyness for
  85018. * @param useInstances Define whether or not the material is used with instances
  85019. * @returns true if ready, otherwise false
  85020. */
  85021. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85022. /**
  85023. * Clones the current material and its related sub materials
  85024. * @param name Define the name of the newly cloned material
  85025. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85026. * @returns the cloned material
  85027. */
  85028. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85029. /**
  85030. * Serializes the materials into a JSON representation.
  85031. * @returns the JSON representation
  85032. */
  85033. serialize(): any;
  85034. /**
  85035. * Dispose the material and release its associated resources
  85036. * @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)
  85037. * @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)
  85038. * @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)
  85039. */
  85040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85041. /**
  85042. * Creates a MultiMaterial from parsed MultiMaterial data.
  85043. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85044. * @param scene defines the hosting scene
  85045. * @returns a new MultiMaterial
  85046. */
  85047. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85048. }
  85049. }
  85050. declare module BABYLON {
  85051. /**
  85052. * Base class for submeshes
  85053. */
  85054. export class BaseSubMesh {
  85055. /** @hidden */
  85056. _materialDefines: Nullable<MaterialDefines>;
  85057. /** @hidden */
  85058. _materialEffect: Nullable<Effect>;
  85059. /**
  85060. * Gets associated effect
  85061. */
  85062. readonly effect: Nullable<Effect>;
  85063. /**
  85064. * Sets associated effect (effect used to render this submesh)
  85065. * @param effect defines the effect to associate with
  85066. * @param defines defines the set of defines used to compile this effect
  85067. */
  85068. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85069. }
  85070. /**
  85071. * Defines a subdivision inside a mesh
  85072. */
  85073. export class SubMesh extends BaseSubMesh implements ICullable {
  85074. /** the material index to use */
  85075. materialIndex: number;
  85076. /** vertex index start */
  85077. verticesStart: number;
  85078. /** vertices count */
  85079. verticesCount: number;
  85080. /** index start */
  85081. indexStart: number;
  85082. /** indices count */
  85083. indexCount: number;
  85084. /** @hidden */
  85085. _linesIndexCount: number;
  85086. private _mesh;
  85087. private _renderingMesh;
  85088. private _boundingInfo;
  85089. private _linesIndexBuffer;
  85090. /** @hidden */
  85091. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85092. /** @hidden */
  85093. _trianglePlanes: Plane[];
  85094. /** @hidden */
  85095. _lastColliderTransformMatrix: Nullable<Matrix>;
  85096. /** @hidden */
  85097. _renderId: number;
  85098. /** @hidden */
  85099. _alphaIndex: number;
  85100. /** @hidden */
  85101. _distanceToCamera: number;
  85102. /** @hidden */
  85103. _id: number;
  85104. private _currentMaterial;
  85105. /**
  85106. * Add a new submesh to a mesh
  85107. * @param materialIndex defines the material index to use
  85108. * @param verticesStart defines vertex index start
  85109. * @param verticesCount defines vertices count
  85110. * @param indexStart defines index start
  85111. * @param indexCount defines indices count
  85112. * @param mesh defines the parent mesh
  85113. * @param renderingMesh defines an optional rendering mesh
  85114. * @param createBoundingBox defines if bounding box should be created for this submesh
  85115. * @returns the new submesh
  85116. */
  85117. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85118. /**
  85119. * Creates a new submesh
  85120. * @param materialIndex defines the material index to use
  85121. * @param verticesStart defines vertex index start
  85122. * @param verticesCount defines vertices count
  85123. * @param indexStart defines index start
  85124. * @param indexCount defines indices count
  85125. * @param mesh defines the parent mesh
  85126. * @param renderingMesh defines an optional rendering mesh
  85127. * @param createBoundingBox defines if bounding box should be created for this submesh
  85128. */
  85129. constructor(
  85130. /** the material index to use */
  85131. materialIndex: number,
  85132. /** vertex index start */
  85133. verticesStart: number,
  85134. /** vertices count */
  85135. verticesCount: number,
  85136. /** index start */
  85137. indexStart: number,
  85138. /** indices count */
  85139. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85140. /**
  85141. * Returns true if this submesh covers the entire parent mesh
  85142. * @ignorenaming
  85143. */
  85144. readonly IsGlobal: boolean;
  85145. /**
  85146. * Returns the submesh BoudingInfo object
  85147. * @returns current bounding info (or mesh's one if the submesh is global)
  85148. */
  85149. getBoundingInfo(): BoundingInfo;
  85150. /**
  85151. * Sets the submesh BoundingInfo
  85152. * @param boundingInfo defines the new bounding info to use
  85153. * @returns the SubMesh
  85154. */
  85155. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85156. /**
  85157. * Returns the mesh of the current submesh
  85158. * @return the parent mesh
  85159. */
  85160. getMesh(): AbstractMesh;
  85161. /**
  85162. * Returns the rendering mesh of the submesh
  85163. * @returns the rendering mesh (could be different from parent mesh)
  85164. */
  85165. getRenderingMesh(): Mesh;
  85166. /**
  85167. * Returns the submesh material
  85168. * @returns null or the current material
  85169. */
  85170. getMaterial(): Nullable<Material>;
  85171. /**
  85172. * Sets a new updated BoundingInfo object to the submesh
  85173. * @param data defines an optional position array to use to determine the bounding info
  85174. * @returns the SubMesh
  85175. */
  85176. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85177. /** @hidden */
  85178. _checkCollision(collider: Collider): boolean;
  85179. /**
  85180. * Updates the submesh BoundingInfo
  85181. * @param world defines the world matrix to use to update the bounding info
  85182. * @returns the submesh
  85183. */
  85184. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85185. /**
  85186. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85187. * @param frustumPlanes defines the frustum planes
  85188. * @returns true if the submesh is intersecting with the frustum
  85189. */
  85190. isInFrustum(frustumPlanes: Plane[]): boolean;
  85191. /**
  85192. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85193. * @param frustumPlanes defines the frustum planes
  85194. * @returns true if the submesh is inside the frustum
  85195. */
  85196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85197. /**
  85198. * Renders the submesh
  85199. * @param enableAlphaMode defines if alpha needs to be used
  85200. * @returns the submesh
  85201. */
  85202. render(enableAlphaMode: boolean): SubMesh;
  85203. /**
  85204. * @hidden
  85205. */
  85206. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85207. /**
  85208. * Checks if the submesh intersects with a ray
  85209. * @param ray defines the ray to test
  85210. * @returns true is the passed ray intersects the submesh bounding box
  85211. */
  85212. canIntersects(ray: Ray): boolean;
  85213. /**
  85214. * Intersects current submesh with a ray
  85215. * @param ray defines the ray to test
  85216. * @param positions defines mesh's positions array
  85217. * @param indices defines mesh's indices array
  85218. * @param fastCheck defines if only bounding info should be used
  85219. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85220. * @returns intersection info or null if no intersection
  85221. */
  85222. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85223. /** @hidden */
  85224. private _intersectLines;
  85225. /** @hidden */
  85226. private _intersectUnIndexedLines;
  85227. /** @hidden */
  85228. private _intersectTriangles;
  85229. /** @hidden */
  85230. private _intersectUnIndexedTriangles;
  85231. /** @hidden */
  85232. _rebuild(): void;
  85233. /**
  85234. * Creates a new submesh from the passed mesh
  85235. * @param newMesh defines the new hosting mesh
  85236. * @param newRenderingMesh defines an optional rendering mesh
  85237. * @returns the new submesh
  85238. */
  85239. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85240. /**
  85241. * Release associated resources
  85242. */
  85243. dispose(): void;
  85244. /**
  85245. * Gets the class name
  85246. * @returns the string "SubMesh".
  85247. */
  85248. getClassName(): string;
  85249. /**
  85250. * Creates a new submesh from indices data
  85251. * @param materialIndex the index of the main mesh material
  85252. * @param startIndex the index where to start the copy in the mesh indices array
  85253. * @param indexCount the number of indices to copy then from the startIndex
  85254. * @param mesh the main mesh to create the submesh from
  85255. * @param renderingMesh the optional rendering mesh
  85256. * @returns a new submesh
  85257. */
  85258. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85259. }
  85260. }
  85261. declare module BABYLON {
  85262. /**
  85263. * Class used to represent data loading progression
  85264. */
  85265. export class SceneLoaderFlags {
  85266. private static _ForceFullSceneLoadingForIncremental;
  85267. private static _ShowLoadingScreen;
  85268. private static _CleanBoneMatrixWeights;
  85269. private static _loggingLevel;
  85270. /**
  85271. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85272. */
  85273. static ForceFullSceneLoadingForIncremental: boolean;
  85274. /**
  85275. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85276. */
  85277. static ShowLoadingScreen: boolean;
  85278. /**
  85279. * Defines the current logging level (while loading the scene)
  85280. * @ignorenaming
  85281. */
  85282. static loggingLevel: number;
  85283. /**
  85284. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85285. */
  85286. static CleanBoneMatrixWeights: boolean;
  85287. }
  85288. }
  85289. declare module BABYLON {
  85290. /**
  85291. * Class used to store geometry data (vertex buffers + index buffer)
  85292. */
  85293. export class Geometry implements IGetSetVerticesData {
  85294. /**
  85295. * Gets or sets the ID of the geometry
  85296. */
  85297. id: string;
  85298. /**
  85299. * Gets or sets the unique ID of the geometry
  85300. */
  85301. uniqueId: number;
  85302. /**
  85303. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85304. */
  85305. delayLoadState: number;
  85306. /**
  85307. * Gets the file containing the data to load when running in delay load state
  85308. */
  85309. delayLoadingFile: Nullable<string>;
  85310. /**
  85311. * Callback called when the geometry is updated
  85312. */
  85313. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85314. private _scene;
  85315. private _engine;
  85316. private _meshes;
  85317. private _totalVertices;
  85318. /** @hidden */
  85319. _indices: IndicesArray;
  85320. /** @hidden */
  85321. _vertexBuffers: {
  85322. [key: string]: VertexBuffer;
  85323. };
  85324. private _isDisposed;
  85325. private _extend;
  85326. private _boundingBias;
  85327. /** @hidden */
  85328. _delayInfo: Array<string>;
  85329. private _indexBuffer;
  85330. private _indexBufferIsUpdatable;
  85331. /** @hidden */
  85332. _boundingInfo: Nullable<BoundingInfo>;
  85333. /** @hidden */
  85334. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85335. /** @hidden */
  85336. _softwareSkinningFrameId: number;
  85337. private _vertexArrayObjects;
  85338. private _updatable;
  85339. /** @hidden */
  85340. _positions: Nullable<Vector3[]>;
  85341. /**
  85342. * 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
  85343. */
  85344. /**
  85345. * 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
  85346. */
  85347. boundingBias: Vector2;
  85348. /**
  85349. * Static function used to attach a new empty geometry to a mesh
  85350. * @param mesh defines the mesh to attach the geometry to
  85351. * @returns the new Geometry
  85352. */
  85353. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85354. /**
  85355. * Creates a new geometry
  85356. * @param id defines the unique ID
  85357. * @param scene defines the hosting scene
  85358. * @param vertexData defines the VertexData used to get geometry data
  85359. * @param updatable defines if geometry must be updatable (false by default)
  85360. * @param mesh defines the mesh that will be associated with the geometry
  85361. */
  85362. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85363. /**
  85364. * Gets the current extend of the geometry
  85365. */
  85366. readonly extend: {
  85367. minimum: Vector3;
  85368. maximum: Vector3;
  85369. };
  85370. /**
  85371. * Gets the hosting scene
  85372. * @returns the hosting Scene
  85373. */
  85374. getScene(): Scene;
  85375. /**
  85376. * Gets the hosting engine
  85377. * @returns the hosting Engine
  85378. */
  85379. getEngine(): Engine;
  85380. /**
  85381. * Defines if the geometry is ready to use
  85382. * @returns true if the geometry is ready to be used
  85383. */
  85384. isReady(): boolean;
  85385. /**
  85386. * Gets a value indicating that the geometry should not be serialized
  85387. */
  85388. readonly doNotSerialize: boolean;
  85389. /** @hidden */
  85390. _rebuild(): void;
  85391. /**
  85392. * Affects all geometry data in one call
  85393. * @param vertexData defines the geometry data
  85394. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85395. */
  85396. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85397. /**
  85398. * Set specific vertex data
  85399. * @param kind defines the data kind (Position, normal, etc...)
  85400. * @param data defines the vertex data to use
  85401. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85402. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85403. */
  85404. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85405. /**
  85406. * Removes a specific vertex data
  85407. * @param kind defines the data kind (Position, normal, etc...)
  85408. */
  85409. removeVerticesData(kind: string): void;
  85410. /**
  85411. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85412. * @param buffer defines the vertex buffer to use
  85413. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85414. */
  85415. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85416. /**
  85417. * Update a specific vertex buffer
  85418. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85419. * It will do nothing if the buffer is not updatable
  85420. * @param kind defines the data kind (Position, normal, etc...)
  85421. * @param data defines the data to use
  85422. * @param offset defines the offset in the target buffer where to store the data
  85423. * @param useBytes set to true if the offset is in bytes
  85424. */
  85425. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85426. /**
  85427. * Update a specific vertex buffer
  85428. * This function will create a new buffer if the current one is not updatable
  85429. * @param kind defines the data kind (Position, normal, etc...)
  85430. * @param data defines the data to use
  85431. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85432. */
  85433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85434. private _updateBoundingInfo;
  85435. /** @hidden */
  85436. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85437. /**
  85438. * Gets total number of vertices
  85439. * @returns the total number of vertices
  85440. */
  85441. getTotalVertices(): number;
  85442. /**
  85443. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85444. * @param kind defines the data kind (Position, normal, etc...)
  85445. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85446. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85447. * @returns a float array containing vertex data
  85448. */
  85449. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85450. /**
  85451. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85452. * @param kind defines the data kind (Position, normal, etc...)
  85453. * @returns true if the vertex buffer with the specified kind is updatable
  85454. */
  85455. isVertexBufferUpdatable(kind: string): boolean;
  85456. /**
  85457. * Gets a specific vertex buffer
  85458. * @param kind defines the data kind (Position, normal, etc...)
  85459. * @returns a VertexBuffer
  85460. */
  85461. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85462. /**
  85463. * Returns all vertex buffers
  85464. * @return an object holding all vertex buffers indexed by kind
  85465. */
  85466. getVertexBuffers(): Nullable<{
  85467. [key: string]: VertexBuffer;
  85468. }>;
  85469. /**
  85470. * Gets a boolean indicating if specific vertex buffer is present
  85471. * @param kind defines the data kind (Position, normal, etc...)
  85472. * @returns true if data is present
  85473. */
  85474. isVerticesDataPresent(kind: string): boolean;
  85475. /**
  85476. * Gets a list of all attached data kinds (Position, normal, etc...)
  85477. * @returns a list of string containing all kinds
  85478. */
  85479. getVerticesDataKinds(): string[];
  85480. /**
  85481. * Update index buffer
  85482. * @param indices defines the indices to store in the index buffer
  85483. * @param offset defines the offset in the target buffer where to store the data
  85484. * @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)
  85485. */
  85486. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85487. /**
  85488. * Creates a new index buffer
  85489. * @param indices defines the indices to store in the index buffer
  85490. * @param totalVertices defines the total number of vertices (could be null)
  85491. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85492. */
  85493. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85494. /**
  85495. * Return the total number of indices
  85496. * @returns the total number of indices
  85497. */
  85498. getTotalIndices(): number;
  85499. /**
  85500. * Gets the index buffer array
  85501. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85502. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85503. * @returns the index buffer array
  85504. */
  85505. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85506. /**
  85507. * Gets the index buffer
  85508. * @return the index buffer
  85509. */
  85510. getIndexBuffer(): Nullable<DataBuffer>;
  85511. /** @hidden */
  85512. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85513. /**
  85514. * Release the associated resources for a specific mesh
  85515. * @param mesh defines the source mesh
  85516. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85517. */
  85518. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85519. /**
  85520. * Apply current geometry to a given mesh
  85521. * @param mesh defines the mesh to apply geometry to
  85522. */
  85523. applyToMesh(mesh: Mesh): void;
  85524. private _updateExtend;
  85525. private _applyToMesh;
  85526. private notifyUpdate;
  85527. /**
  85528. * Load the geometry if it was flagged as delay loaded
  85529. * @param scene defines the hosting scene
  85530. * @param onLoaded defines a callback called when the geometry is loaded
  85531. */
  85532. load(scene: Scene, onLoaded?: () => void): void;
  85533. private _queueLoad;
  85534. /**
  85535. * Invert the geometry to move from a right handed system to a left handed one.
  85536. */
  85537. toLeftHanded(): void;
  85538. /** @hidden */
  85539. _resetPointsArrayCache(): void;
  85540. /** @hidden */
  85541. _generatePointsArray(): boolean;
  85542. /**
  85543. * Gets a value indicating if the geometry is disposed
  85544. * @returns true if the geometry was disposed
  85545. */
  85546. isDisposed(): boolean;
  85547. private _disposeVertexArrayObjects;
  85548. /**
  85549. * Free all associated resources
  85550. */
  85551. dispose(): void;
  85552. /**
  85553. * Clone the current geometry into a new geometry
  85554. * @param id defines the unique ID of the new geometry
  85555. * @returns a new geometry object
  85556. */
  85557. copy(id: string): Geometry;
  85558. /**
  85559. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85560. * @return a JSON representation of the current geometry data (without the vertices data)
  85561. */
  85562. serialize(): any;
  85563. private toNumberArray;
  85564. /**
  85565. * Serialize all vertices data into a JSON oject
  85566. * @returns a JSON representation of the current geometry data
  85567. */
  85568. serializeVerticeData(): any;
  85569. /**
  85570. * Extracts a clone of a mesh geometry
  85571. * @param mesh defines the source mesh
  85572. * @param id defines the unique ID of the new geometry object
  85573. * @returns the new geometry object
  85574. */
  85575. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85576. /**
  85577. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85578. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85579. * Be aware Math.random() could cause collisions, but:
  85580. * "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"
  85581. * @returns a string containing a new GUID
  85582. */
  85583. static RandomId(): string;
  85584. /** @hidden */
  85585. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85586. private static _CleanMatricesWeights;
  85587. /**
  85588. * Create a new geometry from persisted data (Using .babylon file format)
  85589. * @param parsedVertexData defines the persisted data
  85590. * @param scene defines the hosting scene
  85591. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85592. * @returns the new geometry object
  85593. */
  85594. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85595. }
  85596. }
  85597. declare module BABYLON {
  85598. /**
  85599. * Define an interface for all classes that will get and set the data on vertices
  85600. */
  85601. export interface IGetSetVerticesData {
  85602. /**
  85603. * Gets a boolean indicating if specific vertex data is present
  85604. * @param kind defines the vertex data kind to use
  85605. * @returns true is data kind is present
  85606. */
  85607. isVerticesDataPresent(kind: string): boolean;
  85608. /**
  85609. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85610. * @param kind defines the data kind (Position, normal, etc...)
  85611. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85613. * @returns a float array containing vertex data
  85614. */
  85615. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85616. /**
  85617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85618. * @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.
  85619. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85620. * @returns the indices array or an empty array if the mesh has no geometry
  85621. */
  85622. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85623. /**
  85624. * Set specific vertex data
  85625. * @param kind defines the data kind (Position, normal, etc...)
  85626. * @param data defines the vertex data to use
  85627. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85628. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85629. */
  85630. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85631. /**
  85632. * Update a specific associated vertex buffer
  85633. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85634. * - VertexBuffer.PositionKind
  85635. * - VertexBuffer.UVKind
  85636. * - VertexBuffer.UV2Kind
  85637. * - VertexBuffer.UV3Kind
  85638. * - VertexBuffer.UV4Kind
  85639. * - VertexBuffer.UV5Kind
  85640. * - VertexBuffer.UV6Kind
  85641. * - VertexBuffer.ColorKind
  85642. * - VertexBuffer.MatricesIndicesKind
  85643. * - VertexBuffer.MatricesIndicesExtraKind
  85644. * - VertexBuffer.MatricesWeightsKind
  85645. * - VertexBuffer.MatricesWeightsExtraKind
  85646. * @param data defines the data source
  85647. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85648. * @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)
  85649. */
  85650. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85651. /**
  85652. * Creates a new index buffer
  85653. * @param indices defines the indices to store in the index buffer
  85654. * @param totalVertices defines the total number of vertices (could be null)
  85655. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85656. */
  85657. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85658. }
  85659. /**
  85660. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85661. */
  85662. export class VertexData {
  85663. /**
  85664. * Mesh side orientation : usually the external or front surface
  85665. */
  85666. static readonly FRONTSIDE: number;
  85667. /**
  85668. * Mesh side orientation : usually the internal or back surface
  85669. */
  85670. static readonly BACKSIDE: number;
  85671. /**
  85672. * Mesh side orientation : both internal and external or front and back surfaces
  85673. */
  85674. static readonly DOUBLESIDE: number;
  85675. /**
  85676. * Mesh side orientation : by default, `FRONTSIDE`
  85677. */
  85678. static readonly DEFAULTSIDE: number;
  85679. /**
  85680. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85681. */
  85682. positions: Nullable<FloatArray>;
  85683. /**
  85684. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85685. */
  85686. normals: Nullable<FloatArray>;
  85687. /**
  85688. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85689. */
  85690. tangents: Nullable<FloatArray>;
  85691. /**
  85692. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85693. */
  85694. uvs: Nullable<FloatArray>;
  85695. /**
  85696. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85697. */
  85698. uvs2: Nullable<FloatArray>;
  85699. /**
  85700. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85701. */
  85702. uvs3: Nullable<FloatArray>;
  85703. /**
  85704. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85705. */
  85706. uvs4: Nullable<FloatArray>;
  85707. /**
  85708. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85709. */
  85710. uvs5: Nullable<FloatArray>;
  85711. /**
  85712. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85713. */
  85714. uvs6: Nullable<FloatArray>;
  85715. /**
  85716. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85717. */
  85718. colors: Nullable<FloatArray>;
  85719. /**
  85720. * 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).
  85721. */
  85722. matricesIndices: Nullable<FloatArray>;
  85723. /**
  85724. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85725. */
  85726. matricesWeights: Nullable<FloatArray>;
  85727. /**
  85728. * An array extending the number of possible indices
  85729. */
  85730. matricesIndicesExtra: Nullable<FloatArray>;
  85731. /**
  85732. * An array extending the number of possible weights when the number of indices is extended
  85733. */
  85734. matricesWeightsExtra: Nullable<FloatArray>;
  85735. /**
  85736. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85737. */
  85738. indices: Nullable<IndicesArray>;
  85739. /**
  85740. * Uses the passed data array to set the set the values for the specified kind of data
  85741. * @param data a linear array of floating numbers
  85742. * @param kind the type of data that is being set, eg positions, colors etc
  85743. */
  85744. set(data: FloatArray, kind: string): void;
  85745. /**
  85746. * Associates the vertexData to the passed Mesh.
  85747. * Sets it as updatable or not (default `false`)
  85748. * @param mesh the mesh the vertexData is applied to
  85749. * @param updatable when used and having the value true allows new data to update the vertexData
  85750. * @returns the VertexData
  85751. */
  85752. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85753. /**
  85754. * Associates the vertexData to the passed Geometry.
  85755. * Sets it as updatable or not (default `false`)
  85756. * @param geometry the geometry the vertexData is applied to
  85757. * @param updatable when used and having the value true allows new data to update the vertexData
  85758. * @returns VertexData
  85759. */
  85760. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85761. /**
  85762. * Updates the associated mesh
  85763. * @param mesh the mesh to be updated
  85764. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85765. * @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
  85766. * @returns VertexData
  85767. */
  85768. updateMesh(mesh: Mesh): VertexData;
  85769. /**
  85770. * Updates the associated geometry
  85771. * @param geometry the geometry to be updated
  85772. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85773. * @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
  85774. * @returns VertexData.
  85775. */
  85776. updateGeometry(geometry: Geometry): VertexData;
  85777. private _applyTo;
  85778. private _update;
  85779. /**
  85780. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85781. * @param matrix the transforming matrix
  85782. * @returns the VertexData
  85783. */
  85784. transform(matrix: Matrix): VertexData;
  85785. /**
  85786. * Merges the passed VertexData into the current one
  85787. * @param other the VertexData to be merged into the current one
  85788. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85789. * @returns the modified VertexData
  85790. */
  85791. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85792. private _mergeElement;
  85793. private _validate;
  85794. /**
  85795. * Serializes the VertexData
  85796. * @returns a serialized object
  85797. */
  85798. serialize(): any;
  85799. /**
  85800. * Extracts the vertexData from a mesh
  85801. * @param mesh the mesh from which to extract the VertexData
  85802. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85803. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85804. * @returns the object VertexData associated to the passed mesh
  85805. */
  85806. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85807. /**
  85808. * Extracts the vertexData from the geometry
  85809. * @param geometry the geometry from which to extract the VertexData
  85810. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85811. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85812. * @returns the object VertexData associated to the passed mesh
  85813. */
  85814. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85815. private static _ExtractFrom;
  85816. /**
  85817. * Creates the VertexData for a Ribbon
  85818. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85819. * * pathArray array of paths, each of which an array of successive Vector3
  85820. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85821. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85822. * * 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
  85823. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85824. * * 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)
  85825. * * 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)
  85826. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85827. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85828. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85829. * @returns the VertexData of the ribbon
  85830. */
  85831. static CreateRibbon(options: {
  85832. pathArray: Vector3[][];
  85833. closeArray?: boolean;
  85834. closePath?: boolean;
  85835. offset?: number;
  85836. sideOrientation?: number;
  85837. frontUVs?: Vector4;
  85838. backUVs?: Vector4;
  85839. invertUV?: boolean;
  85840. uvs?: Vector2[];
  85841. colors?: Color4[];
  85842. }): VertexData;
  85843. /**
  85844. * Creates the VertexData for a box
  85845. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85846. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85847. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85848. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85849. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85850. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85851. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85853. * * 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)
  85854. * * 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)
  85855. * @returns the VertexData of the box
  85856. */
  85857. static CreateBox(options: {
  85858. size?: number;
  85859. width?: number;
  85860. height?: number;
  85861. depth?: number;
  85862. faceUV?: Vector4[];
  85863. faceColors?: Color4[];
  85864. sideOrientation?: number;
  85865. frontUVs?: Vector4;
  85866. backUVs?: Vector4;
  85867. }): VertexData;
  85868. /**
  85869. * Creates the VertexData for a tiled box
  85870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85871. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85872. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85873. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85875. * @returns the VertexData of the box
  85876. */
  85877. static CreateTiledBox(options: {
  85878. pattern?: number;
  85879. width?: number;
  85880. height?: number;
  85881. depth?: number;
  85882. tileSize?: number;
  85883. tileWidth?: number;
  85884. tileHeight?: number;
  85885. alignHorizontal?: number;
  85886. alignVertical?: number;
  85887. faceUV?: Vector4[];
  85888. faceColors?: Color4[];
  85889. sideOrientation?: number;
  85890. }): VertexData;
  85891. /**
  85892. * Creates the VertexData for a tiled plane
  85893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85894. * * pattern a limited pattern arrangement depending on the number
  85895. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85896. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85897. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85899. * * 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)
  85900. * * 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)
  85901. * @returns the VertexData of the tiled plane
  85902. */
  85903. static CreateTiledPlane(options: {
  85904. pattern?: number;
  85905. tileSize?: number;
  85906. tileWidth?: number;
  85907. tileHeight?: number;
  85908. size?: number;
  85909. width?: number;
  85910. height?: number;
  85911. alignHorizontal?: number;
  85912. alignVertical?: number;
  85913. sideOrientation?: number;
  85914. frontUVs?: Vector4;
  85915. backUVs?: Vector4;
  85916. }): VertexData;
  85917. /**
  85918. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85919. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85920. * * segments sets the number of horizontal strips optional, default 32
  85921. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85922. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85923. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85924. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85925. * * 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
  85926. * * 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
  85927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85928. * * 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)
  85929. * * 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)
  85930. * @returns the VertexData of the ellipsoid
  85931. */
  85932. static CreateSphere(options: {
  85933. segments?: number;
  85934. diameter?: number;
  85935. diameterX?: number;
  85936. diameterY?: number;
  85937. diameterZ?: number;
  85938. arc?: number;
  85939. slice?: number;
  85940. sideOrientation?: number;
  85941. frontUVs?: Vector4;
  85942. backUVs?: Vector4;
  85943. }): VertexData;
  85944. /**
  85945. * Creates the VertexData for a cylinder, cone or prism
  85946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85947. * * height sets the height (y direction) of the cylinder, optional, default 2
  85948. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85949. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85950. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85951. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85952. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85953. * * 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
  85954. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85955. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85956. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85957. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85959. * * 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)
  85960. * * 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)
  85961. * @returns the VertexData of the cylinder, cone or prism
  85962. */
  85963. static CreateCylinder(options: {
  85964. height?: number;
  85965. diameterTop?: number;
  85966. diameterBottom?: number;
  85967. diameter?: number;
  85968. tessellation?: number;
  85969. subdivisions?: number;
  85970. arc?: number;
  85971. faceColors?: Color4[];
  85972. faceUV?: Vector4[];
  85973. hasRings?: boolean;
  85974. enclose?: boolean;
  85975. sideOrientation?: number;
  85976. frontUVs?: Vector4;
  85977. backUVs?: Vector4;
  85978. }): VertexData;
  85979. /**
  85980. * Creates the VertexData for a torus
  85981. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85982. * * diameter the diameter of the torus, optional default 1
  85983. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85984. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85986. * * 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)
  85987. * * 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)
  85988. * @returns the VertexData of the torus
  85989. */
  85990. static CreateTorus(options: {
  85991. diameter?: number;
  85992. thickness?: number;
  85993. tessellation?: number;
  85994. sideOrientation?: number;
  85995. frontUVs?: Vector4;
  85996. backUVs?: Vector4;
  85997. }): VertexData;
  85998. /**
  85999. * Creates the VertexData of the LineSystem
  86000. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86001. * - lines an array of lines, each line being an array of successive Vector3
  86002. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86003. * @returns the VertexData of the LineSystem
  86004. */
  86005. static CreateLineSystem(options: {
  86006. lines: Vector3[][];
  86007. colors?: Nullable<Color4[][]>;
  86008. }): VertexData;
  86009. /**
  86010. * Create the VertexData for a DashedLines
  86011. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86012. * - points an array successive Vector3
  86013. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86014. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86015. * - dashNb the intended total number of dashes, optional, default 200
  86016. * @returns the VertexData for the DashedLines
  86017. */
  86018. static CreateDashedLines(options: {
  86019. points: Vector3[];
  86020. dashSize?: number;
  86021. gapSize?: number;
  86022. dashNb?: number;
  86023. }): VertexData;
  86024. /**
  86025. * Creates the VertexData for a Ground
  86026. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86027. * - width the width (x direction) of the ground, optional, default 1
  86028. * - height the height (z direction) of the ground, optional, default 1
  86029. * - subdivisions the number of subdivisions per side, optional, default 1
  86030. * @returns the VertexData of the Ground
  86031. */
  86032. static CreateGround(options: {
  86033. width?: number;
  86034. height?: number;
  86035. subdivisions?: number;
  86036. subdivisionsX?: number;
  86037. subdivisionsY?: number;
  86038. }): VertexData;
  86039. /**
  86040. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86041. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86042. * * xmin the ground minimum X coordinate, optional, default -1
  86043. * * zmin the ground minimum Z coordinate, optional, default -1
  86044. * * xmax the ground maximum X coordinate, optional, default 1
  86045. * * zmax the ground maximum Z coordinate, optional, default 1
  86046. * * 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}
  86047. * * 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}
  86048. * @returns the VertexData of the TiledGround
  86049. */
  86050. static CreateTiledGround(options: {
  86051. xmin: number;
  86052. zmin: number;
  86053. xmax: number;
  86054. zmax: number;
  86055. subdivisions?: {
  86056. w: number;
  86057. h: number;
  86058. };
  86059. precision?: {
  86060. w: number;
  86061. h: number;
  86062. };
  86063. }): VertexData;
  86064. /**
  86065. * Creates the VertexData of the Ground designed from a heightmap
  86066. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86067. * * width the width (x direction) of the ground
  86068. * * height the height (z direction) of the ground
  86069. * * subdivisions the number of subdivisions per side
  86070. * * minHeight the minimum altitude on the ground, optional, default 0
  86071. * * maxHeight the maximum altitude on the ground, optional default 1
  86072. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86073. * * buffer the array holding the image color data
  86074. * * bufferWidth the width of image
  86075. * * bufferHeight the height of image
  86076. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86077. * @returns the VertexData of the Ground designed from a heightmap
  86078. */
  86079. static CreateGroundFromHeightMap(options: {
  86080. width: number;
  86081. height: number;
  86082. subdivisions: number;
  86083. minHeight: number;
  86084. maxHeight: number;
  86085. colorFilter: Color3;
  86086. buffer: Uint8Array;
  86087. bufferWidth: number;
  86088. bufferHeight: number;
  86089. alphaFilter: number;
  86090. }): VertexData;
  86091. /**
  86092. * Creates the VertexData for a Plane
  86093. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86094. * * size sets the width and height of the plane to the value of size, optional default 1
  86095. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86096. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86098. * * 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)
  86099. * * 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)
  86100. * @returns the VertexData of the box
  86101. */
  86102. static CreatePlane(options: {
  86103. size?: number;
  86104. width?: number;
  86105. height?: number;
  86106. sideOrientation?: number;
  86107. frontUVs?: Vector4;
  86108. backUVs?: Vector4;
  86109. }): VertexData;
  86110. /**
  86111. * Creates the VertexData of the Disc or regular Polygon
  86112. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86113. * * radius the radius of the disc, optional default 0.5
  86114. * * tessellation the number of polygon sides, optional, default 64
  86115. * * 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
  86116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86117. * * 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)
  86118. * * 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)
  86119. * @returns the VertexData of the box
  86120. */
  86121. static CreateDisc(options: {
  86122. radius?: number;
  86123. tessellation?: number;
  86124. arc?: number;
  86125. sideOrientation?: number;
  86126. frontUVs?: Vector4;
  86127. backUVs?: Vector4;
  86128. }): VertexData;
  86129. /**
  86130. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86131. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86132. * @param polygon a mesh built from polygonTriangulation.build()
  86133. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86134. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86135. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86136. * @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)
  86137. * @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)
  86138. * @returns the VertexData of the Polygon
  86139. */
  86140. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86141. /**
  86142. * Creates the VertexData of the IcoSphere
  86143. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86144. * * radius the radius of the IcoSphere, optional default 1
  86145. * * radiusX allows stretching in the x direction, optional, default radius
  86146. * * radiusY allows stretching in the y direction, optional, default radius
  86147. * * radiusZ allows stretching in the z direction, optional, default radius
  86148. * * flat when true creates a flat shaded mesh, optional, default true
  86149. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86151. * * 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)
  86152. * * 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)
  86153. * @returns the VertexData of the IcoSphere
  86154. */
  86155. static CreateIcoSphere(options: {
  86156. radius?: number;
  86157. radiusX?: number;
  86158. radiusY?: number;
  86159. radiusZ?: number;
  86160. flat?: boolean;
  86161. subdivisions?: number;
  86162. sideOrientation?: number;
  86163. frontUVs?: Vector4;
  86164. backUVs?: Vector4;
  86165. }): VertexData;
  86166. /**
  86167. * Creates the VertexData for a Polyhedron
  86168. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86169. * * type provided types are:
  86170. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86171. * * 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)
  86172. * * size the size of the IcoSphere, optional default 1
  86173. * * sizeX allows stretching in the x direction, optional, default size
  86174. * * sizeY allows stretching in the y direction, optional, default size
  86175. * * sizeZ allows stretching in the z direction, optional, default size
  86176. * * 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
  86177. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86178. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86179. * * flat when true creates a flat shaded mesh, optional, default true
  86180. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86182. * * 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)
  86183. * * 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)
  86184. * @returns the VertexData of the Polyhedron
  86185. */
  86186. static CreatePolyhedron(options: {
  86187. type?: number;
  86188. size?: number;
  86189. sizeX?: number;
  86190. sizeY?: number;
  86191. sizeZ?: number;
  86192. custom?: any;
  86193. faceUV?: Vector4[];
  86194. faceColors?: Color4[];
  86195. flat?: boolean;
  86196. sideOrientation?: number;
  86197. frontUVs?: Vector4;
  86198. backUVs?: Vector4;
  86199. }): VertexData;
  86200. /**
  86201. * Creates the VertexData for a TorusKnot
  86202. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86203. * * radius the radius of the torus knot, optional, default 2
  86204. * * tube the thickness of the tube, optional, default 0.5
  86205. * * radialSegments the number of sides on each tube segments, optional, default 32
  86206. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86207. * * p the number of windings around the z axis, optional, default 2
  86208. * * q the number of windings around the x axis, optional, default 3
  86209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86210. * * 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)
  86211. * * 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)
  86212. * @returns the VertexData of the Torus Knot
  86213. */
  86214. static CreateTorusKnot(options: {
  86215. radius?: number;
  86216. tube?: number;
  86217. radialSegments?: number;
  86218. tubularSegments?: number;
  86219. p?: number;
  86220. q?: number;
  86221. sideOrientation?: number;
  86222. frontUVs?: Vector4;
  86223. backUVs?: Vector4;
  86224. }): VertexData;
  86225. /**
  86226. * Compute normals for given positions and indices
  86227. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86228. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86229. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86230. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86231. * * facetNormals : optional array of facet normals (vector3)
  86232. * * facetPositions : optional array of facet positions (vector3)
  86233. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86234. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86235. * * bInfo : optional bounding info, required for facetPartitioning computation
  86236. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86237. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86238. * * useRightHandedSystem: optional boolean to for right handed system computation
  86239. * * depthSort : optional boolean to enable the facet depth sort computation
  86240. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86241. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86242. */
  86243. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86244. facetNormals?: any;
  86245. facetPositions?: any;
  86246. facetPartitioning?: any;
  86247. ratio?: number;
  86248. bInfo?: any;
  86249. bbSize?: Vector3;
  86250. subDiv?: any;
  86251. useRightHandedSystem?: boolean;
  86252. depthSort?: boolean;
  86253. distanceTo?: Vector3;
  86254. depthSortedFacets?: any;
  86255. }): void;
  86256. /** @hidden */
  86257. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86258. /**
  86259. * Applies VertexData created from the imported parameters to the geometry
  86260. * @param parsedVertexData the parsed data from an imported file
  86261. * @param geometry the geometry to apply the VertexData to
  86262. */
  86263. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86264. }
  86265. }
  86266. declare module BABYLON {
  86267. /**
  86268. * Defines a target to use with MorphTargetManager
  86269. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86270. */
  86271. export class MorphTarget implements IAnimatable {
  86272. /** defines the name of the target */
  86273. name: string;
  86274. /**
  86275. * Gets or sets the list of animations
  86276. */
  86277. animations: Animation[];
  86278. private _scene;
  86279. private _positions;
  86280. private _normals;
  86281. private _tangents;
  86282. private _uvs;
  86283. private _influence;
  86284. /**
  86285. * Observable raised when the influence changes
  86286. */
  86287. onInfluenceChanged: Observable<boolean>;
  86288. /** @hidden */
  86289. _onDataLayoutChanged: Observable<void>;
  86290. /**
  86291. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86292. */
  86293. influence: number;
  86294. /**
  86295. * Gets or sets the id of the morph Target
  86296. */
  86297. id: string;
  86298. private _animationPropertiesOverride;
  86299. /**
  86300. * Gets or sets the animation properties override
  86301. */
  86302. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86303. /**
  86304. * Creates a new MorphTarget
  86305. * @param name defines the name of the target
  86306. * @param influence defines the influence to use
  86307. * @param scene defines the scene the morphtarget belongs to
  86308. */
  86309. constructor(
  86310. /** defines the name of the target */
  86311. name: string, influence?: number, scene?: Nullable<Scene>);
  86312. /**
  86313. * Gets a boolean defining if the target contains position data
  86314. */
  86315. readonly hasPositions: boolean;
  86316. /**
  86317. * Gets a boolean defining if the target contains normal data
  86318. */
  86319. readonly hasNormals: boolean;
  86320. /**
  86321. * Gets a boolean defining if the target contains tangent data
  86322. */
  86323. readonly hasTangents: boolean;
  86324. /**
  86325. * Gets a boolean defining if the target contains texture coordinates data
  86326. */
  86327. readonly hasUVs: boolean;
  86328. /**
  86329. * Affects position data to this target
  86330. * @param data defines the position data to use
  86331. */
  86332. setPositions(data: Nullable<FloatArray>): void;
  86333. /**
  86334. * Gets the position data stored in this target
  86335. * @returns a FloatArray containing the position data (or null if not present)
  86336. */
  86337. getPositions(): Nullable<FloatArray>;
  86338. /**
  86339. * Affects normal data to this target
  86340. * @param data defines the normal data to use
  86341. */
  86342. setNormals(data: Nullable<FloatArray>): void;
  86343. /**
  86344. * Gets the normal data stored in this target
  86345. * @returns a FloatArray containing the normal data (or null if not present)
  86346. */
  86347. getNormals(): Nullable<FloatArray>;
  86348. /**
  86349. * Affects tangent data to this target
  86350. * @param data defines the tangent data to use
  86351. */
  86352. setTangents(data: Nullable<FloatArray>): void;
  86353. /**
  86354. * Gets the tangent data stored in this target
  86355. * @returns a FloatArray containing the tangent data (or null if not present)
  86356. */
  86357. getTangents(): Nullable<FloatArray>;
  86358. /**
  86359. * Affects texture coordinates data to this target
  86360. * @param data defines the texture coordinates data to use
  86361. */
  86362. setUVs(data: Nullable<FloatArray>): void;
  86363. /**
  86364. * Gets the texture coordinates data stored in this target
  86365. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86366. */
  86367. getUVs(): Nullable<FloatArray>;
  86368. /**
  86369. * Serializes the current target into a Serialization object
  86370. * @returns the serialized object
  86371. */
  86372. serialize(): any;
  86373. /**
  86374. * Returns the string "MorphTarget"
  86375. * @returns "MorphTarget"
  86376. */
  86377. getClassName(): string;
  86378. /**
  86379. * Creates a new target from serialized data
  86380. * @param serializationObject defines the serialized data to use
  86381. * @returns a new MorphTarget
  86382. */
  86383. static Parse(serializationObject: any): MorphTarget;
  86384. /**
  86385. * Creates a MorphTarget from mesh data
  86386. * @param mesh defines the source mesh
  86387. * @param name defines the name to use for the new target
  86388. * @param influence defines the influence to attach to the target
  86389. * @returns a new MorphTarget
  86390. */
  86391. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. /**
  86396. * This class is used to deform meshes using morphing between different targets
  86397. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86398. */
  86399. export class MorphTargetManager {
  86400. private _targets;
  86401. private _targetInfluenceChangedObservers;
  86402. private _targetDataLayoutChangedObservers;
  86403. private _activeTargets;
  86404. private _scene;
  86405. private _influences;
  86406. private _supportsNormals;
  86407. private _supportsTangents;
  86408. private _supportsUVs;
  86409. private _vertexCount;
  86410. private _uniqueId;
  86411. private _tempInfluences;
  86412. /**
  86413. * Gets or sets a boolean indicating if normals must be morphed
  86414. */
  86415. enableNormalMorphing: boolean;
  86416. /**
  86417. * Gets or sets a boolean indicating if tangents must be morphed
  86418. */
  86419. enableTangentMorphing: boolean;
  86420. /**
  86421. * Gets or sets a boolean indicating if UV must be morphed
  86422. */
  86423. enableUVMorphing: boolean;
  86424. /**
  86425. * Creates a new MorphTargetManager
  86426. * @param scene defines the current scene
  86427. */
  86428. constructor(scene?: Nullable<Scene>);
  86429. /**
  86430. * Gets the unique ID of this manager
  86431. */
  86432. readonly uniqueId: number;
  86433. /**
  86434. * Gets the number of vertices handled by this manager
  86435. */
  86436. readonly vertexCount: number;
  86437. /**
  86438. * Gets a boolean indicating if this manager supports morphing of normals
  86439. */
  86440. readonly supportsNormals: boolean;
  86441. /**
  86442. * Gets a boolean indicating if this manager supports morphing of tangents
  86443. */
  86444. readonly supportsTangents: boolean;
  86445. /**
  86446. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86447. */
  86448. readonly supportsUVs: boolean;
  86449. /**
  86450. * Gets the number of targets stored in this manager
  86451. */
  86452. readonly numTargets: number;
  86453. /**
  86454. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86455. */
  86456. readonly numInfluencers: number;
  86457. /**
  86458. * Gets the list of influences (one per target)
  86459. */
  86460. readonly influences: Float32Array;
  86461. /**
  86462. * Gets the active target at specified index. An active target is a target with an influence > 0
  86463. * @param index defines the index to check
  86464. * @returns the requested target
  86465. */
  86466. getActiveTarget(index: number): MorphTarget;
  86467. /**
  86468. * Gets the target at specified index
  86469. * @param index defines the index to check
  86470. * @returns the requested target
  86471. */
  86472. getTarget(index: number): MorphTarget;
  86473. /**
  86474. * Add a new target to this manager
  86475. * @param target defines the target to add
  86476. */
  86477. addTarget(target: MorphTarget): void;
  86478. /**
  86479. * Removes a target from the manager
  86480. * @param target defines the target to remove
  86481. */
  86482. removeTarget(target: MorphTarget): void;
  86483. /**
  86484. * Serializes the current manager into a Serialization object
  86485. * @returns the serialized object
  86486. */
  86487. serialize(): any;
  86488. private _syncActiveTargets;
  86489. /**
  86490. * Syncrhonize the targets with all the meshes using this morph target manager
  86491. */
  86492. synchronize(): void;
  86493. /**
  86494. * Creates a new MorphTargetManager from serialized data
  86495. * @param serializationObject defines the serialized data
  86496. * @param scene defines the hosting scene
  86497. * @returns the new MorphTargetManager
  86498. */
  86499. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86500. }
  86501. }
  86502. declare module BABYLON {
  86503. /**
  86504. * Class used to represent a specific level of detail of a mesh
  86505. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86506. */
  86507. export class MeshLODLevel {
  86508. /** Defines the distance where this level should star being displayed */
  86509. distance: number;
  86510. /** Defines the mesh to use to render this level */
  86511. mesh: Nullable<Mesh>;
  86512. /**
  86513. * Creates a new LOD level
  86514. * @param distance defines the distance where this level should star being displayed
  86515. * @param mesh defines the mesh to use to render this level
  86516. */
  86517. constructor(
  86518. /** Defines the distance where this level should star being displayed */
  86519. distance: number,
  86520. /** Defines the mesh to use to render this level */
  86521. mesh: Nullable<Mesh>);
  86522. }
  86523. }
  86524. declare module BABYLON {
  86525. /**
  86526. * Mesh representing the gorund
  86527. */
  86528. export class GroundMesh extends Mesh {
  86529. /** If octree should be generated */
  86530. generateOctree: boolean;
  86531. private _heightQuads;
  86532. /** @hidden */
  86533. _subdivisionsX: number;
  86534. /** @hidden */
  86535. _subdivisionsY: number;
  86536. /** @hidden */
  86537. _width: number;
  86538. /** @hidden */
  86539. _height: number;
  86540. /** @hidden */
  86541. _minX: number;
  86542. /** @hidden */
  86543. _maxX: number;
  86544. /** @hidden */
  86545. _minZ: number;
  86546. /** @hidden */
  86547. _maxZ: number;
  86548. constructor(name: string, scene: Scene);
  86549. /**
  86550. * "GroundMesh"
  86551. * @returns "GroundMesh"
  86552. */
  86553. getClassName(): string;
  86554. /**
  86555. * The minimum of x and y subdivisions
  86556. */
  86557. readonly subdivisions: number;
  86558. /**
  86559. * X subdivisions
  86560. */
  86561. readonly subdivisionsX: number;
  86562. /**
  86563. * Y subdivisions
  86564. */
  86565. readonly subdivisionsY: number;
  86566. /**
  86567. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86568. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86569. * @param chunksCount the number of subdivisions for x and y
  86570. * @param octreeBlocksSize (Default: 32)
  86571. */
  86572. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86573. /**
  86574. * Returns a height (y) value in the Worl system :
  86575. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86576. * @param x x coordinate
  86577. * @param z z coordinate
  86578. * @returns the ground y position if (x, z) are outside the ground surface.
  86579. */
  86580. getHeightAtCoordinates(x: number, z: number): number;
  86581. /**
  86582. * Returns a normalized vector (Vector3) orthogonal to the ground
  86583. * at the ground coordinates (x, z) expressed in the World system.
  86584. * @param x x coordinate
  86585. * @param z z coordinate
  86586. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86587. */
  86588. getNormalAtCoordinates(x: number, z: number): Vector3;
  86589. /**
  86590. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86591. * at the ground coordinates (x, z) expressed in the World system.
  86592. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86593. * @param x x coordinate
  86594. * @param z z coordinate
  86595. * @param ref vector to store the result
  86596. * @returns the GroundMesh.
  86597. */
  86598. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86599. /**
  86600. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86601. * if the ground has been updated.
  86602. * This can be used in the render loop.
  86603. * @returns the GroundMesh.
  86604. */
  86605. updateCoordinateHeights(): GroundMesh;
  86606. private _getFacetAt;
  86607. private _initHeightQuads;
  86608. private _computeHeightQuads;
  86609. /**
  86610. * Serializes this ground mesh
  86611. * @param serializationObject object to write serialization to
  86612. */
  86613. serialize(serializationObject: any): void;
  86614. /**
  86615. * Parses a serialized ground mesh
  86616. * @param parsedMesh the serialized mesh
  86617. * @param scene the scene to create the ground mesh in
  86618. * @returns the created ground mesh
  86619. */
  86620. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86621. }
  86622. }
  86623. declare module BABYLON {
  86624. /**
  86625. * Interface for Physics-Joint data
  86626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86627. */
  86628. export interface PhysicsJointData {
  86629. /**
  86630. * The main pivot of the joint
  86631. */
  86632. mainPivot?: Vector3;
  86633. /**
  86634. * The connected pivot of the joint
  86635. */
  86636. connectedPivot?: Vector3;
  86637. /**
  86638. * The main axis of the joint
  86639. */
  86640. mainAxis?: Vector3;
  86641. /**
  86642. * The connected axis of the joint
  86643. */
  86644. connectedAxis?: Vector3;
  86645. /**
  86646. * The collision of the joint
  86647. */
  86648. collision?: boolean;
  86649. /**
  86650. * Native Oimo/Cannon/Energy data
  86651. */
  86652. nativeParams?: any;
  86653. }
  86654. /**
  86655. * This is a holder class for the physics joint created by the physics plugin
  86656. * It holds a set of functions to control the underlying joint
  86657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86658. */
  86659. export class PhysicsJoint {
  86660. /**
  86661. * The type of the physics joint
  86662. */
  86663. type: number;
  86664. /**
  86665. * The data for the physics joint
  86666. */
  86667. jointData: PhysicsJointData;
  86668. private _physicsJoint;
  86669. protected _physicsPlugin: IPhysicsEnginePlugin;
  86670. /**
  86671. * Initializes the physics joint
  86672. * @param type The type of the physics joint
  86673. * @param jointData The data for the physics joint
  86674. */
  86675. constructor(
  86676. /**
  86677. * The type of the physics joint
  86678. */
  86679. type: number,
  86680. /**
  86681. * The data for the physics joint
  86682. */
  86683. jointData: PhysicsJointData);
  86684. /**
  86685. * Gets the physics joint
  86686. */
  86687. /**
  86688. * Sets the physics joint
  86689. */
  86690. physicsJoint: any;
  86691. /**
  86692. * Sets the physics plugin
  86693. */
  86694. physicsPlugin: IPhysicsEnginePlugin;
  86695. /**
  86696. * Execute a function that is physics-plugin specific.
  86697. * @param {Function} func the function that will be executed.
  86698. * It accepts two parameters: the physics world and the physics joint
  86699. */
  86700. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86701. /**
  86702. * Distance-Joint type
  86703. */
  86704. static DistanceJoint: number;
  86705. /**
  86706. * Hinge-Joint type
  86707. */
  86708. static HingeJoint: number;
  86709. /**
  86710. * Ball-and-Socket joint type
  86711. */
  86712. static BallAndSocketJoint: number;
  86713. /**
  86714. * Wheel-Joint type
  86715. */
  86716. static WheelJoint: number;
  86717. /**
  86718. * Slider-Joint type
  86719. */
  86720. static SliderJoint: number;
  86721. /**
  86722. * Prismatic-Joint type
  86723. */
  86724. static PrismaticJoint: number;
  86725. /**
  86726. * Universal-Joint type
  86727. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86728. */
  86729. static UniversalJoint: number;
  86730. /**
  86731. * Hinge-Joint 2 type
  86732. */
  86733. static Hinge2Joint: number;
  86734. /**
  86735. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86736. */
  86737. static PointToPointJoint: number;
  86738. /**
  86739. * Spring-Joint type
  86740. */
  86741. static SpringJoint: number;
  86742. /**
  86743. * Lock-Joint type
  86744. */
  86745. static LockJoint: number;
  86746. }
  86747. /**
  86748. * A class representing a physics distance joint
  86749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86750. */
  86751. export class DistanceJoint extends PhysicsJoint {
  86752. /**
  86753. *
  86754. * @param jointData The data for the Distance-Joint
  86755. */
  86756. constructor(jointData: DistanceJointData);
  86757. /**
  86758. * Update the predefined distance.
  86759. * @param maxDistance The maximum preferred distance
  86760. * @param minDistance The minimum preferred distance
  86761. */
  86762. updateDistance(maxDistance: number, minDistance?: number): void;
  86763. }
  86764. /**
  86765. * Represents a Motor-Enabled Joint
  86766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86767. */
  86768. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86769. /**
  86770. * Initializes the Motor-Enabled Joint
  86771. * @param type The type of the joint
  86772. * @param jointData The physica joint data for the joint
  86773. */
  86774. constructor(type: number, jointData: PhysicsJointData);
  86775. /**
  86776. * Set the motor values.
  86777. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86778. * @param force the force to apply
  86779. * @param maxForce max force for this motor.
  86780. */
  86781. setMotor(force?: number, maxForce?: number): void;
  86782. /**
  86783. * Set the motor's limits.
  86784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86785. * @param upperLimit The upper limit of the motor
  86786. * @param lowerLimit The lower limit of the motor
  86787. */
  86788. setLimit(upperLimit: number, lowerLimit?: number): void;
  86789. }
  86790. /**
  86791. * This class represents a single physics Hinge-Joint
  86792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86793. */
  86794. export class HingeJoint extends MotorEnabledJoint {
  86795. /**
  86796. * Initializes the Hinge-Joint
  86797. * @param jointData The joint data for the Hinge-Joint
  86798. */
  86799. constructor(jointData: PhysicsJointData);
  86800. /**
  86801. * Set the motor values.
  86802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86803. * @param {number} force the force to apply
  86804. * @param {number} maxForce max force for this motor.
  86805. */
  86806. setMotor(force?: number, maxForce?: number): void;
  86807. /**
  86808. * Set the motor's limits.
  86809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86810. * @param upperLimit The upper limit of the motor
  86811. * @param lowerLimit The lower limit of the motor
  86812. */
  86813. setLimit(upperLimit: number, lowerLimit?: number): void;
  86814. }
  86815. /**
  86816. * This class represents a dual hinge physics joint (same as wheel joint)
  86817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86818. */
  86819. export class Hinge2Joint extends MotorEnabledJoint {
  86820. /**
  86821. * Initializes the Hinge2-Joint
  86822. * @param jointData The joint data for the Hinge2-Joint
  86823. */
  86824. constructor(jointData: PhysicsJointData);
  86825. /**
  86826. * Set the motor values.
  86827. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86828. * @param {number} targetSpeed the speed the motor is to reach
  86829. * @param {number} maxForce max force for this motor.
  86830. * @param {motorIndex} the motor's index, 0 or 1.
  86831. */
  86832. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86833. /**
  86834. * Set the motor limits.
  86835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86836. * @param {number} upperLimit the upper limit
  86837. * @param {number} lowerLimit lower limit
  86838. * @param {motorIndex} the motor's index, 0 or 1.
  86839. */
  86840. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86841. }
  86842. /**
  86843. * Interface for a motor enabled joint
  86844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86845. */
  86846. export interface IMotorEnabledJoint {
  86847. /**
  86848. * Physics joint
  86849. */
  86850. physicsJoint: any;
  86851. /**
  86852. * Sets the motor of the motor-enabled joint
  86853. * @param force The force of the motor
  86854. * @param maxForce The maximum force of the motor
  86855. * @param motorIndex The index of the motor
  86856. */
  86857. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86858. /**
  86859. * Sets the limit of the motor
  86860. * @param upperLimit The upper limit of the motor
  86861. * @param lowerLimit The lower limit of the motor
  86862. * @param motorIndex The index of the motor
  86863. */
  86864. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86865. }
  86866. /**
  86867. * Joint data for a Distance-Joint
  86868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86869. */
  86870. export interface DistanceJointData extends PhysicsJointData {
  86871. /**
  86872. * Max distance the 2 joint objects can be apart
  86873. */
  86874. maxDistance: number;
  86875. }
  86876. /**
  86877. * Joint data from a spring joint
  86878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86879. */
  86880. export interface SpringJointData extends PhysicsJointData {
  86881. /**
  86882. * Length of the spring
  86883. */
  86884. length: number;
  86885. /**
  86886. * Stiffness of the spring
  86887. */
  86888. stiffness: number;
  86889. /**
  86890. * Damping of the spring
  86891. */
  86892. damping: number;
  86893. /** this callback will be called when applying the force to the impostors. */
  86894. forceApplicationCallback: () => void;
  86895. }
  86896. }
  86897. declare module BABYLON {
  86898. /**
  86899. * Holds the data for the raycast result
  86900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86901. */
  86902. export class PhysicsRaycastResult {
  86903. private _hasHit;
  86904. private _hitDistance;
  86905. private _hitNormalWorld;
  86906. private _hitPointWorld;
  86907. private _rayFromWorld;
  86908. private _rayToWorld;
  86909. /**
  86910. * Gets if there was a hit
  86911. */
  86912. readonly hasHit: boolean;
  86913. /**
  86914. * Gets the distance from the hit
  86915. */
  86916. readonly hitDistance: number;
  86917. /**
  86918. * Gets the hit normal/direction in the world
  86919. */
  86920. readonly hitNormalWorld: Vector3;
  86921. /**
  86922. * Gets the hit point in the world
  86923. */
  86924. readonly hitPointWorld: Vector3;
  86925. /**
  86926. * Gets the ray "start point" of the ray in the world
  86927. */
  86928. readonly rayFromWorld: Vector3;
  86929. /**
  86930. * Gets the ray "end point" of the ray in the world
  86931. */
  86932. readonly rayToWorld: Vector3;
  86933. /**
  86934. * Sets the hit data (normal & point in world space)
  86935. * @param hitNormalWorld defines the normal in world space
  86936. * @param hitPointWorld defines the point in world space
  86937. */
  86938. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86939. /**
  86940. * Sets the distance from the start point to the hit point
  86941. * @param distance
  86942. */
  86943. setHitDistance(distance: number): void;
  86944. /**
  86945. * Calculates the distance manually
  86946. */
  86947. calculateHitDistance(): void;
  86948. /**
  86949. * Resets all the values to default
  86950. * @param from The from point on world space
  86951. * @param to The to point on world space
  86952. */
  86953. reset(from?: Vector3, to?: Vector3): void;
  86954. }
  86955. /**
  86956. * Interface for the size containing width and height
  86957. */
  86958. interface IXYZ {
  86959. /**
  86960. * X
  86961. */
  86962. x: number;
  86963. /**
  86964. * Y
  86965. */
  86966. y: number;
  86967. /**
  86968. * Z
  86969. */
  86970. z: number;
  86971. }
  86972. }
  86973. declare module BABYLON {
  86974. /**
  86975. * Interface used to describe a physics joint
  86976. */
  86977. export interface PhysicsImpostorJoint {
  86978. /** Defines the main impostor to which the joint is linked */
  86979. mainImpostor: PhysicsImpostor;
  86980. /** Defines the impostor that is connected to the main impostor using this joint */
  86981. connectedImpostor: PhysicsImpostor;
  86982. /** Defines the joint itself */
  86983. joint: PhysicsJoint;
  86984. }
  86985. /** @hidden */
  86986. export interface IPhysicsEnginePlugin {
  86987. world: any;
  86988. name: string;
  86989. setGravity(gravity: Vector3): void;
  86990. setTimeStep(timeStep: number): void;
  86991. getTimeStep(): number;
  86992. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86993. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86994. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86995. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86996. removePhysicsBody(impostor: PhysicsImpostor): void;
  86997. generateJoint(joint: PhysicsImpostorJoint): void;
  86998. removeJoint(joint: PhysicsImpostorJoint): void;
  86999. isSupported(): boolean;
  87000. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87001. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87002. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87003. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87004. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87005. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87006. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87007. getBodyMass(impostor: PhysicsImpostor): number;
  87008. getBodyFriction(impostor: PhysicsImpostor): number;
  87009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87010. getBodyRestitution(impostor: PhysicsImpostor): number;
  87011. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87012. getBodyPressure?(impostor: PhysicsImpostor): number;
  87013. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87014. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87015. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87016. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87017. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87018. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87019. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87020. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87021. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87022. sleepBody(impostor: PhysicsImpostor): void;
  87023. wakeUpBody(impostor: PhysicsImpostor): void;
  87024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87026. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87027. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87028. getRadius(impostor: PhysicsImpostor): number;
  87029. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87030. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87031. dispose(): void;
  87032. }
  87033. /**
  87034. * Interface used to define a physics engine
  87035. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87036. */
  87037. export interface IPhysicsEngine {
  87038. /**
  87039. * Gets the gravity vector used by the simulation
  87040. */
  87041. gravity: Vector3;
  87042. /**
  87043. * Sets the gravity vector used by the simulation
  87044. * @param gravity defines the gravity vector to use
  87045. */
  87046. setGravity(gravity: Vector3): void;
  87047. /**
  87048. * Set the time step of the physics engine.
  87049. * Default is 1/60.
  87050. * To slow it down, enter 1/600 for example.
  87051. * To speed it up, 1/30
  87052. * @param newTimeStep the new timestep to apply to this world.
  87053. */
  87054. setTimeStep(newTimeStep: number): void;
  87055. /**
  87056. * Get the time step of the physics engine.
  87057. * @returns the current time step
  87058. */
  87059. getTimeStep(): number;
  87060. /**
  87061. * Release all resources
  87062. */
  87063. dispose(): void;
  87064. /**
  87065. * Gets the name of the current physics plugin
  87066. * @returns the name of the plugin
  87067. */
  87068. getPhysicsPluginName(): string;
  87069. /**
  87070. * Adding a new impostor for the impostor tracking.
  87071. * This will be done by the impostor itself.
  87072. * @param impostor the impostor to add
  87073. */
  87074. addImpostor(impostor: PhysicsImpostor): void;
  87075. /**
  87076. * Remove an impostor from the engine.
  87077. * This impostor and its mesh will not longer be updated by the physics engine.
  87078. * @param impostor the impostor to remove
  87079. */
  87080. removeImpostor(impostor: PhysicsImpostor): void;
  87081. /**
  87082. * Add a joint to the physics engine
  87083. * @param mainImpostor defines the main impostor to which the joint is added.
  87084. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87085. * @param joint defines the joint that will connect both impostors.
  87086. */
  87087. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87088. /**
  87089. * Removes a joint from the simulation
  87090. * @param mainImpostor defines the impostor used with the joint
  87091. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87092. * @param joint defines the joint to remove
  87093. */
  87094. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87095. /**
  87096. * Gets the current plugin used to run the simulation
  87097. * @returns current plugin
  87098. */
  87099. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87100. /**
  87101. * Gets the list of physic impostors
  87102. * @returns an array of PhysicsImpostor
  87103. */
  87104. getImpostors(): Array<PhysicsImpostor>;
  87105. /**
  87106. * Gets the impostor for a physics enabled object
  87107. * @param object defines the object impersonated by the impostor
  87108. * @returns the PhysicsImpostor or null if not found
  87109. */
  87110. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87111. /**
  87112. * Gets the impostor for a physics body object
  87113. * @param body defines physics body used by the impostor
  87114. * @returns the PhysicsImpostor or null if not found
  87115. */
  87116. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87117. /**
  87118. * Does a raycast in the physics world
  87119. * @param from when should the ray start?
  87120. * @param to when should the ray end?
  87121. * @returns PhysicsRaycastResult
  87122. */
  87123. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87124. /**
  87125. * Called by the scene. No need to call it.
  87126. * @param delta defines the timespam between frames
  87127. */
  87128. _step(delta: number): void;
  87129. }
  87130. }
  87131. declare module BABYLON {
  87132. /**
  87133. * The interface for the physics imposter parameters
  87134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87135. */
  87136. export interface PhysicsImpostorParameters {
  87137. /**
  87138. * The mass of the physics imposter
  87139. */
  87140. mass: number;
  87141. /**
  87142. * The friction of the physics imposter
  87143. */
  87144. friction?: number;
  87145. /**
  87146. * The coefficient of restitution of the physics imposter
  87147. */
  87148. restitution?: number;
  87149. /**
  87150. * The native options of the physics imposter
  87151. */
  87152. nativeOptions?: any;
  87153. /**
  87154. * Specifies if the parent should be ignored
  87155. */
  87156. ignoreParent?: boolean;
  87157. /**
  87158. * Specifies if bi-directional transformations should be disabled
  87159. */
  87160. disableBidirectionalTransformation?: boolean;
  87161. /**
  87162. * The pressure inside the physics imposter, soft object only
  87163. */
  87164. pressure?: number;
  87165. /**
  87166. * The stiffness the physics imposter, soft object only
  87167. */
  87168. stiffness?: number;
  87169. /**
  87170. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87171. */
  87172. velocityIterations?: number;
  87173. /**
  87174. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87175. */
  87176. positionIterations?: number;
  87177. /**
  87178. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87179. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87180. * Add to fix multiple points
  87181. */
  87182. fixedPoints?: number;
  87183. /**
  87184. * The collision margin around a soft object
  87185. */
  87186. margin?: number;
  87187. /**
  87188. * The collision margin around a soft object
  87189. */
  87190. damping?: number;
  87191. /**
  87192. * The path for a rope based on an extrusion
  87193. */
  87194. path?: any;
  87195. /**
  87196. * The shape of an extrusion used for a rope based on an extrusion
  87197. */
  87198. shape?: any;
  87199. }
  87200. /**
  87201. * Interface for a physics-enabled object
  87202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87203. */
  87204. export interface IPhysicsEnabledObject {
  87205. /**
  87206. * The position of the physics-enabled object
  87207. */
  87208. position: Vector3;
  87209. /**
  87210. * The rotation of the physics-enabled object
  87211. */
  87212. rotationQuaternion: Nullable<Quaternion>;
  87213. /**
  87214. * The scale of the physics-enabled object
  87215. */
  87216. scaling: Vector3;
  87217. /**
  87218. * The rotation of the physics-enabled object
  87219. */
  87220. rotation?: Vector3;
  87221. /**
  87222. * The parent of the physics-enabled object
  87223. */
  87224. parent?: any;
  87225. /**
  87226. * The bounding info of the physics-enabled object
  87227. * @returns The bounding info of the physics-enabled object
  87228. */
  87229. getBoundingInfo(): BoundingInfo;
  87230. /**
  87231. * Computes the world matrix
  87232. * @param force Specifies if the world matrix should be computed by force
  87233. * @returns A world matrix
  87234. */
  87235. computeWorldMatrix(force: boolean): Matrix;
  87236. /**
  87237. * Gets the world matrix
  87238. * @returns A world matrix
  87239. */
  87240. getWorldMatrix?(): Matrix;
  87241. /**
  87242. * Gets the child meshes
  87243. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87244. * @returns An array of abstract meshes
  87245. */
  87246. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87247. /**
  87248. * Gets the vertex data
  87249. * @param kind The type of vertex data
  87250. * @returns A nullable array of numbers, or a float32 array
  87251. */
  87252. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87253. /**
  87254. * Gets the indices from the mesh
  87255. * @returns A nullable array of index arrays
  87256. */
  87257. getIndices?(): Nullable<IndicesArray>;
  87258. /**
  87259. * Gets the scene from the mesh
  87260. * @returns the indices array or null
  87261. */
  87262. getScene?(): Scene;
  87263. /**
  87264. * Gets the absolute position from the mesh
  87265. * @returns the absolute position
  87266. */
  87267. getAbsolutePosition(): Vector3;
  87268. /**
  87269. * Gets the absolute pivot point from the mesh
  87270. * @returns the absolute pivot point
  87271. */
  87272. getAbsolutePivotPoint(): Vector3;
  87273. /**
  87274. * Rotates the mesh
  87275. * @param axis The axis of rotation
  87276. * @param amount The amount of rotation
  87277. * @param space The space of the rotation
  87278. * @returns The rotation transform node
  87279. */
  87280. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87281. /**
  87282. * Translates the mesh
  87283. * @param axis The axis of translation
  87284. * @param distance The distance of translation
  87285. * @param space The space of the translation
  87286. * @returns The transform node
  87287. */
  87288. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87289. /**
  87290. * Sets the absolute position of the mesh
  87291. * @param absolutePosition The absolute position of the mesh
  87292. * @returns The transform node
  87293. */
  87294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87295. /**
  87296. * Gets the class name of the mesh
  87297. * @returns The class name
  87298. */
  87299. getClassName(): string;
  87300. }
  87301. /**
  87302. * Represents a physics imposter
  87303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87304. */
  87305. export class PhysicsImpostor {
  87306. /**
  87307. * The physics-enabled object used as the physics imposter
  87308. */
  87309. object: IPhysicsEnabledObject;
  87310. /**
  87311. * The type of the physics imposter
  87312. */
  87313. type: number;
  87314. private _options;
  87315. private _scene?;
  87316. /**
  87317. * The default object size of the imposter
  87318. */
  87319. static DEFAULT_OBJECT_SIZE: Vector3;
  87320. /**
  87321. * The identity quaternion of the imposter
  87322. */
  87323. static IDENTITY_QUATERNION: Quaternion;
  87324. /** @hidden */
  87325. _pluginData: any;
  87326. private _physicsEngine;
  87327. private _physicsBody;
  87328. private _bodyUpdateRequired;
  87329. private _onBeforePhysicsStepCallbacks;
  87330. private _onAfterPhysicsStepCallbacks;
  87331. /** @hidden */
  87332. _onPhysicsCollideCallbacks: Array<{
  87333. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87334. otherImpostors: Array<PhysicsImpostor>;
  87335. }>;
  87336. private _deltaPosition;
  87337. private _deltaRotation;
  87338. private _deltaRotationConjugated;
  87339. /** @hidden */
  87340. _isFromLine: boolean;
  87341. private _parent;
  87342. private _isDisposed;
  87343. private static _tmpVecs;
  87344. private static _tmpQuat;
  87345. /**
  87346. * Specifies if the physics imposter is disposed
  87347. */
  87348. readonly isDisposed: boolean;
  87349. /**
  87350. * Gets the mass of the physics imposter
  87351. */
  87352. mass: number;
  87353. /**
  87354. * Gets the coefficient of friction
  87355. */
  87356. /**
  87357. * Sets the coefficient of friction
  87358. */
  87359. friction: number;
  87360. /**
  87361. * Gets the coefficient of restitution
  87362. */
  87363. /**
  87364. * Sets the coefficient of restitution
  87365. */
  87366. restitution: number;
  87367. /**
  87368. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87369. */
  87370. /**
  87371. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87372. */
  87373. pressure: number;
  87374. /**
  87375. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87376. */
  87377. /**
  87378. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87379. */
  87380. stiffness: number;
  87381. /**
  87382. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87383. */
  87384. /**
  87385. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87386. */
  87387. velocityIterations: number;
  87388. /**
  87389. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87390. */
  87391. /**
  87392. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87393. */
  87394. positionIterations: number;
  87395. /**
  87396. * The unique id of the physics imposter
  87397. * set by the physics engine when adding this impostor to the array
  87398. */
  87399. uniqueId: number;
  87400. /**
  87401. * @hidden
  87402. */
  87403. soft: boolean;
  87404. /**
  87405. * @hidden
  87406. */
  87407. segments: number;
  87408. private _joints;
  87409. /**
  87410. * Initializes the physics imposter
  87411. * @param object The physics-enabled object used as the physics imposter
  87412. * @param type The type of the physics imposter
  87413. * @param _options The options for the physics imposter
  87414. * @param _scene The Babylon scene
  87415. */
  87416. constructor(
  87417. /**
  87418. * The physics-enabled object used as the physics imposter
  87419. */
  87420. object: IPhysicsEnabledObject,
  87421. /**
  87422. * The type of the physics imposter
  87423. */
  87424. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87425. /**
  87426. * This function will completly initialize this impostor.
  87427. * It will create a new body - but only if this mesh has no parent.
  87428. * If it has, this impostor will not be used other than to define the impostor
  87429. * of the child mesh.
  87430. * @hidden
  87431. */
  87432. _init(): void;
  87433. private _getPhysicsParent;
  87434. /**
  87435. * Should a new body be generated.
  87436. * @returns boolean specifying if body initialization is required
  87437. */
  87438. isBodyInitRequired(): boolean;
  87439. /**
  87440. * Sets the updated scaling
  87441. * @param updated Specifies if the scaling is updated
  87442. */
  87443. setScalingUpdated(): void;
  87444. /**
  87445. * Force a regeneration of this or the parent's impostor's body.
  87446. * Use under cautious - This will remove all joints already implemented.
  87447. */
  87448. forceUpdate(): void;
  87449. /**
  87450. * Gets the body that holds this impostor. Either its own, or its parent.
  87451. */
  87452. /**
  87453. * Set the physics body. Used mainly by the physics engine/plugin
  87454. */
  87455. physicsBody: any;
  87456. /**
  87457. * Get the parent of the physics imposter
  87458. * @returns Physics imposter or null
  87459. */
  87460. /**
  87461. * Sets the parent of the physics imposter
  87462. */
  87463. parent: Nullable<PhysicsImpostor>;
  87464. /**
  87465. * Resets the update flags
  87466. */
  87467. resetUpdateFlags(): void;
  87468. /**
  87469. * Gets the object extend size
  87470. * @returns the object extend size
  87471. */
  87472. getObjectExtendSize(): Vector3;
  87473. /**
  87474. * Gets the object center
  87475. * @returns The object center
  87476. */
  87477. getObjectCenter(): Vector3;
  87478. /**
  87479. * Get a specific parametes from the options parameter
  87480. * @param paramName The object parameter name
  87481. * @returns The object parameter
  87482. */
  87483. getParam(paramName: string): any;
  87484. /**
  87485. * Sets a specific parameter in the options given to the physics plugin
  87486. * @param paramName The parameter name
  87487. * @param value The value of the parameter
  87488. */
  87489. setParam(paramName: string, value: number): void;
  87490. /**
  87491. * Specifically change the body's mass option. Won't recreate the physics body object
  87492. * @param mass The mass of the physics imposter
  87493. */
  87494. setMass(mass: number): void;
  87495. /**
  87496. * Gets the linear velocity
  87497. * @returns linear velocity or null
  87498. */
  87499. getLinearVelocity(): Nullable<Vector3>;
  87500. /**
  87501. * Sets the linear velocity
  87502. * @param velocity linear velocity or null
  87503. */
  87504. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87505. /**
  87506. * Gets the angular velocity
  87507. * @returns angular velocity or null
  87508. */
  87509. getAngularVelocity(): Nullable<Vector3>;
  87510. /**
  87511. * Sets the angular velocity
  87512. * @param velocity The velocity or null
  87513. */
  87514. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87515. /**
  87516. * Execute a function with the physics plugin native code
  87517. * Provide a function the will have two variables - the world object and the physics body object
  87518. * @param func The function to execute with the physics plugin native code
  87519. */
  87520. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87521. /**
  87522. * Register a function that will be executed before the physics world is stepping forward
  87523. * @param func The function to execute before the physics world is stepped forward
  87524. */
  87525. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87526. /**
  87527. * Unregister a function that will be executed before the physics world is stepping forward
  87528. * @param func The function to execute before the physics world is stepped forward
  87529. */
  87530. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87531. /**
  87532. * Register a function that will be executed after the physics step
  87533. * @param func The function to execute after physics step
  87534. */
  87535. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87536. /**
  87537. * Unregisters a function that will be executed after the physics step
  87538. * @param func The function to execute after physics step
  87539. */
  87540. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87541. /**
  87542. * register a function that will be executed when this impostor collides against a different body
  87543. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87544. * @param func Callback that is executed on collision
  87545. */
  87546. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87547. /**
  87548. * Unregisters the physics imposter on contact
  87549. * @param collideAgainst The physics object to collide against
  87550. * @param func Callback to execute on collision
  87551. */
  87552. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87553. private _tmpQuat;
  87554. private _tmpQuat2;
  87555. /**
  87556. * Get the parent rotation
  87557. * @returns The parent rotation
  87558. */
  87559. getParentsRotation(): Quaternion;
  87560. /**
  87561. * this function is executed by the physics engine.
  87562. */
  87563. beforeStep: () => void;
  87564. /**
  87565. * this function is executed by the physics engine
  87566. */
  87567. afterStep: () => void;
  87568. /**
  87569. * Legacy collision detection event support
  87570. */
  87571. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87572. /**
  87573. * event and body object due to cannon's event-based architecture.
  87574. */
  87575. onCollide: (e: {
  87576. body: any;
  87577. }) => void;
  87578. /**
  87579. * Apply a force
  87580. * @param force The force to apply
  87581. * @param contactPoint The contact point for the force
  87582. * @returns The physics imposter
  87583. */
  87584. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87585. /**
  87586. * Apply an impulse
  87587. * @param force The impulse force
  87588. * @param contactPoint The contact point for the impulse force
  87589. * @returns The physics imposter
  87590. */
  87591. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87592. /**
  87593. * A help function to create a joint
  87594. * @param otherImpostor A physics imposter used to create a joint
  87595. * @param jointType The type of joint
  87596. * @param jointData The data for the joint
  87597. * @returns The physics imposter
  87598. */
  87599. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87600. /**
  87601. * Add a joint to this impostor with a different impostor
  87602. * @param otherImpostor A physics imposter used to add a joint
  87603. * @param joint The joint to add
  87604. * @returns The physics imposter
  87605. */
  87606. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87607. /**
  87608. * Add an anchor to a cloth impostor
  87609. * @param otherImpostor rigid impostor to anchor to
  87610. * @param width ratio across width from 0 to 1
  87611. * @param height ratio up height from 0 to 1
  87612. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87613. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87614. * @returns impostor the soft imposter
  87615. */
  87616. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87617. /**
  87618. * Add a hook to a rope impostor
  87619. * @param otherImpostor rigid impostor to anchor to
  87620. * @param length ratio across rope from 0 to 1
  87621. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87622. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87623. * @returns impostor the rope imposter
  87624. */
  87625. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87626. /**
  87627. * Will keep this body still, in a sleep mode.
  87628. * @returns the physics imposter
  87629. */
  87630. sleep(): PhysicsImpostor;
  87631. /**
  87632. * Wake the body up.
  87633. * @returns The physics imposter
  87634. */
  87635. wakeUp(): PhysicsImpostor;
  87636. /**
  87637. * Clones the physics imposter
  87638. * @param newObject The physics imposter clones to this physics-enabled object
  87639. * @returns A nullable physics imposter
  87640. */
  87641. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87642. /**
  87643. * Disposes the physics imposter
  87644. */
  87645. dispose(): void;
  87646. /**
  87647. * Sets the delta position
  87648. * @param position The delta position amount
  87649. */
  87650. setDeltaPosition(position: Vector3): void;
  87651. /**
  87652. * Sets the delta rotation
  87653. * @param rotation The delta rotation amount
  87654. */
  87655. setDeltaRotation(rotation: Quaternion): void;
  87656. /**
  87657. * Gets the box size of the physics imposter and stores the result in the input parameter
  87658. * @param result Stores the box size
  87659. * @returns The physics imposter
  87660. */
  87661. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87662. /**
  87663. * Gets the radius of the physics imposter
  87664. * @returns Radius of the physics imposter
  87665. */
  87666. getRadius(): number;
  87667. /**
  87668. * Sync a bone with this impostor
  87669. * @param bone The bone to sync to the impostor.
  87670. * @param boneMesh The mesh that the bone is influencing.
  87671. * @param jointPivot The pivot of the joint / bone in local space.
  87672. * @param distToJoint Optional distance from the impostor to the joint.
  87673. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87674. */
  87675. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87676. /**
  87677. * Sync impostor to a bone
  87678. * @param bone The bone that the impostor will be synced to.
  87679. * @param boneMesh The mesh that the bone is influencing.
  87680. * @param jointPivot The pivot of the joint / bone in local space.
  87681. * @param distToJoint Optional distance from the impostor to the joint.
  87682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87683. * @param boneAxis Optional vector3 axis the bone is aligned with
  87684. */
  87685. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87686. /**
  87687. * No-Imposter type
  87688. */
  87689. static NoImpostor: number;
  87690. /**
  87691. * Sphere-Imposter type
  87692. */
  87693. static SphereImpostor: number;
  87694. /**
  87695. * Box-Imposter type
  87696. */
  87697. static BoxImpostor: number;
  87698. /**
  87699. * Plane-Imposter type
  87700. */
  87701. static PlaneImpostor: number;
  87702. /**
  87703. * Mesh-imposter type
  87704. */
  87705. static MeshImpostor: number;
  87706. /**
  87707. * Capsule-Impostor type (Ammo.js plugin only)
  87708. */
  87709. static CapsuleImpostor: number;
  87710. /**
  87711. * Cylinder-Imposter type
  87712. */
  87713. static CylinderImpostor: number;
  87714. /**
  87715. * Particle-Imposter type
  87716. */
  87717. static ParticleImpostor: number;
  87718. /**
  87719. * Heightmap-Imposter type
  87720. */
  87721. static HeightmapImpostor: number;
  87722. /**
  87723. * ConvexHull-Impostor type (Ammo.js plugin only)
  87724. */
  87725. static ConvexHullImpostor: number;
  87726. /**
  87727. * Rope-Imposter type
  87728. */
  87729. static RopeImpostor: number;
  87730. /**
  87731. * Cloth-Imposter type
  87732. */
  87733. static ClothImpostor: number;
  87734. /**
  87735. * Softbody-Imposter type
  87736. */
  87737. static SoftbodyImpostor: number;
  87738. }
  87739. }
  87740. declare module BABYLON {
  87741. /**
  87742. * @hidden
  87743. **/
  87744. export class _CreationDataStorage {
  87745. closePath?: boolean;
  87746. closeArray?: boolean;
  87747. idx: number[];
  87748. dashSize: number;
  87749. gapSize: number;
  87750. path3D: Path3D;
  87751. pathArray: Vector3[][];
  87752. arc: number;
  87753. radius: number;
  87754. cap: number;
  87755. tessellation: number;
  87756. }
  87757. /**
  87758. * @hidden
  87759. **/
  87760. class _InstanceDataStorage {
  87761. visibleInstances: any;
  87762. batchCache: _InstancesBatch;
  87763. instancesBufferSize: number;
  87764. instancesBuffer: Nullable<Buffer>;
  87765. instancesData: Float32Array;
  87766. overridenInstanceCount: number;
  87767. isFrozen: boolean;
  87768. previousBatch: Nullable<_InstancesBatch>;
  87769. hardwareInstancedRendering: boolean;
  87770. sideOrientation: number;
  87771. }
  87772. /**
  87773. * @hidden
  87774. **/
  87775. export class _InstancesBatch {
  87776. mustReturn: boolean;
  87777. visibleInstances: Nullable<InstancedMesh[]>[];
  87778. renderSelf: boolean[];
  87779. hardwareInstancedRendering: boolean[];
  87780. }
  87781. /**
  87782. * Class used to represent renderable models
  87783. */
  87784. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87785. /**
  87786. * Mesh side orientation : usually the external or front surface
  87787. */
  87788. static readonly FRONTSIDE: number;
  87789. /**
  87790. * Mesh side orientation : usually the internal or back surface
  87791. */
  87792. static readonly BACKSIDE: number;
  87793. /**
  87794. * Mesh side orientation : both internal and external or front and back surfaces
  87795. */
  87796. static readonly DOUBLESIDE: number;
  87797. /**
  87798. * Mesh side orientation : by default, `FRONTSIDE`
  87799. */
  87800. static readonly DEFAULTSIDE: number;
  87801. /**
  87802. * Mesh cap setting : no cap
  87803. */
  87804. static readonly NO_CAP: number;
  87805. /**
  87806. * Mesh cap setting : one cap at the beginning of the mesh
  87807. */
  87808. static readonly CAP_START: number;
  87809. /**
  87810. * Mesh cap setting : one cap at the end of the mesh
  87811. */
  87812. static readonly CAP_END: number;
  87813. /**
  87814. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87815. */
  87816. static readonly CAP_ALL: number;
  87817. /**
  87818. * Mesh pattern setting : no flip or rotate
  87819. */
  87820. static readonly NO_FLIP: number;
  87821. /**
  87822. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87823. */
  87824. static readonly FLIP_TILE: number;
  87825. /**
  87826. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87827. */
  87828. static readonly ROTATE_TILE: number;
  87829. /**
  87830. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87831. */
  87832. static readonly FLIP_ROW: number;
  87833. /**
  87834. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87835. */
  87836. static readonly ROTATE_ROW: number;
  87837. /**
  87838. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87839. */
  87840. static readonly FLIP_N_ROTATE_TILE: number;
  87841. /**
  87842. * Mesh pattern setting : rotate pattern and rotate
  87843. */
  87844. static readonly FLIP_N_ROTATE_ROW: number;
  87845. /**
  87846. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87847. */
  87848. static readonly CENTER: number;
  87849. /**
  87850. * Mesh tile positioning : part tiles on left
  87851. */
  87852. static readonly LEFT: number;
  87853. /**
  87854. * Mesh tile positioning : part tiles on right
  87855. */
  87856. static readonly RIGHT: number;
  87857. /**
  87858. * Mesh tile positioning : part tiles on top
  87859. */
  87860. static readonly TOP: number;
  87861. /**
  87862. * Mesh tile positioning : part tiles on bottom
  87863. */
  87864. static readonly BOTTOM: number;
  87865. /**
  87866. * Gets the default side orientation.
  87867. * @param orientation the orientation to value to attempt to get
  87868. * @returns the default orientation
  87869. * @hidden
  87870. */
  87871. static _GetDefaultSideOrientation(orientation?: number): number;
  87872. private _internalMeshDataInfo;
  87873. /**
  87874. * An event triggered before rendering the mesh
  87875. */
  87876. readonly onBeforeRenderObservable: Observable<Mesh>;
  87877. /**
  87878. * An event triggered before binding the mesh
  87879. */
  87880. readonly onBeforeBindObservable: Observable<Mesh>;
  87881. /**
  87882. * An event triggered after rendering the mesh
  87883. */
  87884. readonly onAfterRenderObservable: Observable<Mesh>;
  87885. /**
  87886. * An event triggered before drawing the mesh
  87887. */
  87888. readonly onBeforeDrawObservable: Observable<Mesh>;
  87889. private _onBeforeDrawObserver;
  87890. /**
  87891. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87892. */
  87893. onBeforeDraw: () => void;
  87894. /**
  87895. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87896. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87897. */
  87898. delayLoadState: number;
  87899. /**
  87900. * Gets the list of instances created from this mesh
  87901. * it is not supposed to be modified manually.
  87902. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87903. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87904. */
  87905. instances: InstancedMesh[];
  87906. /**
  87907. * Gets the file containing delay loading data for this mesh
  87908. */
  87909. delayLoadingFile: string;
  87910. /** @hidden */
  87911. _binaryInfo: any;
  87912. /**
  87913. * User defined function used to change how LOD level selection is done
  87914. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87915. */
  87916. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87917. /**
  87918. * Gets or sets the morph target manager
  87919. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87920. */
  87921. morphTargetManager: Nullable<MorphTargetManager>;
  87922. /** @hidden */
  87923. _creationDataStorage: Nullable<_CreationDataStorage>;
  87924. /** @hidden */
  87925. _geometry: Nullable<Geometry>;
  87926. /** @hidden */
  87927. _delayInfo: Array<string>;
  87928. /** @hidden */
  87929. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87930. /** @hidden */
  87931. _instanceDataStorage: _InstanceDataStorage;
  87932. private _effectiveMaterial;
  87933. /** @hidden */
  87934. _shouldGenerateFlatShading: boolean;
  87935. /** @hidden */
  87936. _originalBuilderSideOrientation: number;
  87937. /**
  87938. * Use this property to change the original side orientation defined at construction time
  87939. */
  87940. overrideMaterialSideOrientation: Nullable<number>;
  87941. /**
  87942. * Gets the source mesh (the one used to clone this one from)
  87943. */
  87944. readonly source: Nullable<Mesh>;
  87945. /**
  87946. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87947. */
  87948. isUnIndexed: boolean;
  87949. /**
  87950. * @constructor
  87951. * @param name The value used by scene.getMeshByName() to do a lookup.
  87952. * @param scene The scene to add this mesh to.
  87953. * @param parent The parent of this mesh, if it has one
  87954. * @param source An optional Mesh from which geometry is shared, cloned.
  87955. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87956. * When false, achieved by calling a clone(), also passing False.
  87957. * This will make creation of children, recursive.
  87958. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87959. */
  87960. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87961. /**
  87962. * Gets the class name
  87963. * @returns the string "Mesh".
  87964. */
  87965. getClassName(): string;
  87966. /** @hidden */
  87967. readonly _isMesh: boolean;
  87968. /**
  87969. * Returns a description of this mesh
  87970. * @param fullDetails define if full details about this mesh must be used
  87971. * @returns a descriptive string representing this mesh
  87972. */
  87973. toString(fullDetails?: boolean): string;
  87974. /** @hidden */
  87975. _unBindEffect(): void;
  87976. /**
  87977. * Gets a boolean indicating if this mesh has LOD
  87978. */
  87979. readonly hasLODLevels: boolean;
  87980. /**
  87981. * Gets the list of MeshLODLevel associated with the current mesh
  87982. * @returns an array of MeshLODLevel
  87983. */
  87984. getLODLevels(): MeshLODLevel[];
  87985. private _sortLODLevels;
  87986. /**
  87987. * Add a mesh as LOD level triggered at the given distance.
  87988. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87989. * @param distance The distance from the center of the object to show this level
  87990. * @param mesh The mesh to be added as LOD level (can be null)
  87991. * @return This mesh (for chaining)
  87992. */
  87993. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87994. /**
  87995. * Returns the LOD level mesh at the passed distance or null if not found.
  87996. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87997. * @param distance The distance from the center of the object to show this level
  87998. * @returns a Mesh or `null`
  87999. */
  88000. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88001. /**
  88002. * Remove a mesh from the LOD array
  88003. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88004. * @param mesh defines the mesh to be removed
  88005. * @return This mesh (for chaining)
  88006. */
  88007. removeLODLevel(mesh: Mesh): Mesh;
  88008. /**
  88009. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88010. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88011. * @param camera defines the camera to use to compute distance
  88012. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88013. * @return This mesh (for chaining)
  88014. */
  88015. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88016. /**
  88017. * Gets the mesh internal Geometry object
  88018. */
  88019. readonly geometry: Nullable<Geometry>;
  88020. /**
  88021. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88022. * @returns the total number of vertices
  88023. */
  88024. getTotalVertices(): number;
  88025. /**
  88026. * Returns the content of an associated vertex buffer
  88027. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88028. * - VertexBuffer.PositionKind
  88029. * - VertexBuffer.UVKind
  88030. * - VertexBuffer.UV2Kind
  88031. * - VertexBuffer.UV3Kind
  88032. * - VertexBuffer.UV4Kind
  88033. * - VertexBuffer.UV5Kind
  88034. * - VertexBuffer.UV6Kind
  88035. * - VertexBuffer.ColorKind
  88036. * - VertexBuffer.MatricesIndicesKind
  88037. * - VertexBuffer.MatricesIndicesExtraKind
  88038. * - VertexBuffer.MatricesWeightsKind
  88039. * - VertexBuffer.MatricesWeightsExtraKind
  88040. * @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
  88041. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88042. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88043. */
  88044. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88045. /**
  88046. * Returns the mesh VertexBuffer object from the requested `kind`
  88047. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88048. * - VertexBuffer.PositionKind
  88049. * - VertexBuffer.NormalKind
  88050. * - VertexBuffer.UVKind
  88051. * - VertexBuffer.UV2Kind
  88052. * - VertexBuffer.UV3Kind
  88053. * - VertexBuffer.UV4Kind
  88054. * - VertexBuffer.UV5Kind
  88055. * - VertexBuffer.UV6Kind
  88056. * - VertexBuffer.ColorKind
  88057. * - VertexBuffer.MatricesIndicesKind
  88058. * - VertexBuffer.MatricesIndicesExtraKind
  88059. * - VertexBuffer.MatricesWeightsKind
  88060. * - VertexBuffer.MatricesWeightsExtraKind
  88061. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88062. */
  88063. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88064. /**
  88065. * Tests if a specific vertex buffer is associated with this mesh
  88066. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88067. * - VertexBuffer.PositionKind
  88068. * - VertexBuffer.NormalKind
  88069. * - VertexBuffer.UVKind
  88070. * - VertexBuffer.UV2Kind
  88071. * - VertexBuffer.UV3Kind
  88072. * - VertexBuffer.UV4Kind
  88073. * - VertexBuffer.UV5Kind
  88074. * - VertexBuffer.UV6Kind
  88075. * - VertexBuffer.ColorKind
  88076. * - VertexBuffer.MatricesIndicesKind
  88077. * - VertexBuffer.MatricesIndicesExtraKind
  88078. * - VertexBuffer.MatricesWeightsKind
  88079. * - VertexBuffer.MatricesWeightsExtraKind
  88080. * @returns a boolean
  88081. */
  88082. isVerticesDataPresent(kind: string): boolean;
  88083. /**
  88084. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88085. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88086. * - VertexBuffer.PositionKind
  88087. * - VertexBuffer.UVKind
  88088. * - VertexBuffer.UV2Kind
  88089. * - VertexBuffer.UV3Kind
  88090. * - VertexBuffer.UV4Kind
  88091. * - VertexBuffer.UV5Kind
  88092. * - VertexBuffer.UV6Kind
  88093. * - VertexBuffer.ColorKind
  88094. * - VertexBuffer.MatricesIndicesKind
  88095. * - VertexBuffer.MatricesIndicesExtraKind
  88096. * - VertexBuffer.MatricesWeightsKind
  88097. * - VertexBuffer.MatricesWeightsExtraKind
  88098. * @returns a boolean
  88099. */
  88100. isVertexBufferUpdatable(kind: string): boolean;
  88101. /**
  88102. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88103. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88104. * - VertexBuffer.PositionKind
  88105. * - VertexBuffer.NormalKind
  88106. * - VertexBuffer.UVKind
  88107. * - VertexBuffer.UV2Kind
  88108. * - VertexBuffer.UV3Kind
  88109. * - VertexBuffer.UV4Kind
  88110. * - VertexBuffer.UV5Kind
  88111. * - VertexBuffer.UV6Kind
  88112. * - VertexBuffer.ColorKind
  88113. * - VertexBuffer.MatricesIndicesKind
  88114. * - VertexBuffer.MatricesIndicesExtraKind
  88115. * - VertexBuffer.MatricesWeightsKind
  88116. * - VertexBuffer.MatricesWeightsExtraKind
  88117. * @returns an array of strings
  88118. */
  88119. getVerticesDataKinds(): string[];
  88120. /**
  88121. * Returns a positive integer : the total number of indices in this mesh geometry.
  88122. * @returns the numner of indices or zero if the mesh has no geometry.
  88123. */
  88124. getTotalIndices(): number;
  88125. /**
  88126. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88127. * @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.
  88128. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88129. * @returns the indices array or an empty array if the mesh has no geometry
  88130. */
  88131. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88132. readonly isBlocked: boolean;
  88133. /**
  88134. * Determine if the current mesh is ready to be rendered
  88135. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88136. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88137. * @returns true if all associated assets are ready (material, textures, shaders)
  88138. */
  88139. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88140. /**
  88141. * 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.
  88142. */
  88143. readonly areNormalsFrozen: boolean;
  88144. /**
  88145. * 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.
  88146. * @returns the current mesh
  88147. */
  88148. freezeNormals(): Mesh;
  88149. /**
  88150. * 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
  88151. * @returns the current mesh
  88152. */
  88153. unfreezeNormals(): Mesh;
  88154. /**
  88155. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88156. */
  88157. overridenInstanceCount: number;
  88158. /** @hidden */
  88159. _preActivate(): Mesh;
  88160. /** @hidden */
  88161. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88162. /** @hidden */
  88163. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88164. /**
  88165. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88166. * This means the mesh underlying bounding box and sphere are recomputed.
  88167. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88168. * @returns the current mesh
  88169. */
  88170. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88171. /** @hidden */
  88172. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88173. /**
  88174. * This function will subdivide the mesh into multiple submeshes
  88175. * @param count defines the expected number of submeshes
  88176. */
  88177. subdivide(count: number): void;
  88178. /**
  88179. * Copy a FloatArray into a specific associated vertex buffer
  88180. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88181. * - VertexBuffer.PositionKind
  88182. * - VertexBuffer.UVKind
  88183. * - VertexBuffer.UV2Kind
  88184. * - VertexBuffer.UV3Kind
  88185. * - VertexBuffer.UV4Kind
  88186. * - VertexBuffer.UV5Kind
  88187. * - VertexBuffer.UV6Kind
  88188. * - VertexBuffer.ColorKind
  88189. * - VertexBuffer.MatricesIndicesKind
  88190. * - VertexBuffer.MatricesIndicesExtraKind
  88191. * - VertexBuffer.MatricesWeightsKind
  88192. * - VertexBuffer.MatricesWeightsExtraKind
  88193. * @param data defines the data source
  88194. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88195. * @param stride defines the data stride size (can be null)
  88196. * @returns the current mesh
  88197. */
  88198. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  88199. /**
  88200. * Flags an associated vertex buffer as updatable
  88201. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88202. * - VertexBuffer.PositionKind
  88203. * - VertexBuffer.UVKind
  88204. * - VertexBuffer.UV2Kind
  88205. * - VertexBuffer.UV3Kind
  88206. * - VertexBuffer.UV4Kind
  88207. * - VertexBuffer.UV5Kind
  88208. * - VertexBuffer.UV6Kind
  88209. * - VertexBuffer.ColorKind
  88210. * - VertexBuffer.MatricesIndicesKind
  88211. * - VertexBuffer.MatricesIndicesExtraKind
  88212. * - VertexBuffer.MatricesWeightsKind
  88213. * - VertexBuffer.MatricesWeightsExtraKind
  88214. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88215. */
  88216. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88217. /**
  88218. * Sets the mesh global Vertex Buffer
  88219. * @param buffer defines the buffer to use
  88220. * @returns the current mesh
  88221. */
  88222. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88223. /**
  88224. * Update a specific associated vertex buffer
  88225. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88226. * - VertexBuffer.PositionKind
  88227. * - VertexBuffer.UVKind
  88228. * - VertexBuffer.UV2Kind
  88229. * - VertexBuffer.UV3Kind
  88230. * - VertexBuffer.UV4Kind
  88231. * - VertexBuffer.UV5Kind
  88232. * - VertexBuffer.UV6Kind
  88233. * - VertexBuffer.ColorKind
  88234. * - VertexBuffer.MatricesIndicesKind
  88235. * - VertexBuffer.MatricesIndicesExtraKind
  88236. * - VertexBuffer.MatricesWeightsKind
  88237. * - VertexBuffer.MatricesWeightsExtraKind
  88238. * @param data defines the data source
  88239. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88240. * @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)
  88241. * @returns the current mesh
  88242. */
  88243. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88244. /**
  88245. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88246. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88247. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88248. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88249. * @returns the current mesh
  88250. */
  88251. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88252. /**
  88253. * Creates a un-shared specific occurence of the geometry for the mesh.
  88254. * @returns the current mesh
  88255. */
  88256. makeGeometryUnique(): Mesh;
  88257. /**
  88258. * Set the index buffer of this mesh
  88259. * @param indices defines the source data
  88260. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88261. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88262. * @returns the current mesh
  88263. */
  88264. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  88265. /**
  88266. * Update the current index buffer
  88267. * @param indices defines the source data
  88268. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88269. * @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)
  88270. * @returns the current mesh
  88271. */
  88272. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  88273. /**
  88274. * Invert the geometry to move from a right handed system to a left handed one.
  88275. * @returns the current mesh
  88276. */
  88277. toLeftHanded(): Mesh;
  88278. /** @hidden */
  88279. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88280. /** @hidden */
  88281. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88282. /**
  88283. * Registers for this mesh a javascript function called just before the rendering process
  88284. * @param func defines the function to call before rendering this mesh
  88285. * @returns the current mesh
  88286. */
  88287. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88288. /**
  88289. * Disposes a previously registered javascript function called before the rendering
  88290. * @param func defines the function to remove
  88291. * @returns the current mesh
  88292. */
  88293. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88294. /**
  88295. * Registers for this mesh a javascript function called just after the rendering is complete
  88296. * @param func defines the function to call after rendering this mesh
  88297. * @returns the current mesh
  88298. */
  88299. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88300. /**
  88301. * Disposes a previously registered javascript function called after the rendering.
  88302. * @param func defines the function to remove
  88303. * @returns the current mesh
  88304. */
  88305. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88306. /** @hidden */
  88307. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88308. /** @hidden */
  88309. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88310. /** @hidden */
  88311. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88312. /** @hidden */
  88313. _rebuild(): void;
  88314. /** @hidden */
  88315. _freeze(): void;
  88316. /** @hidden */
  88317. _unFreeze(): void;
  88318. /**
  88319. * 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
  88320. * @param subMesh defines the subMesh to render
  88321. * @param enableAlphaMode defines if alpha mode can be changed
  88322. * @returns the current mesh
  88323. */
  88324. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88325. private _onBeforeDraw;
  88326. /**
  88327. * Renormalize the mesh and patch it up if there are no weights
  88328. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88329. * However in the case of zero weights then we set just a single influence to 1.
  88330. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88331. */
  88332. cleanMatrixWeights(): void;
  88333. private normalizeSkinFourWeights;
  88334. private normalizeSkinWeightsAndExtra;
  88335. /**
  88336. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88337. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88338. * the user know there was an issue with importing the mesh
  88339. * @returns a validation object with skinned, valid and report string
  88340. */
  88341. validateSkinning(): {
  88342. skinned: boolean;
  88343. valid: boolean;
  88344. report: string;
  88345. };
  88346. /** @hidden */
  88347. _checkDelayState(): Mesh;
  88348. private _queueLoad;
  88349. /**
  88350. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88351. * A mesh is in the frustum if its bounding box intersects the frustum
  88352. * @param frustumPlanes defines the frustum to test
  88353. * @returns true if the mesh is in the frustum planes
  88354. */
  88355. isInFrustum(frustumPlanes: Plane[]): boolean;
  88356. /**
  88357. * Sets the mesh material by the material or multiMaterial `id` property
  88358. * @param id is a string identifying the material or the multiMaterial
  88359. * @returns the current mesh
  88360. */
  88361. setMaterialByID(id: string): Mesh;
  88362. /**
  88363. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88364. * @returns an array of IAnimatable
  88365. */
  88366. getAnimatables(): IAnimatable[];
  88367. /**
  88368. * Modifies the mesh geometry according to the passed transformation matrix.
  88369. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88370. * The mesh normals are modified using the same transformation.
  88371. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88372. * @param transform defines the transform matrix to use
  88373. * @see http://doc.babylonjs.com/resources/baking_transformations
  88374. * @returns the current mesh
  88375. */
  88376. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88377. /**
  88378. * Modifies the mesh geometry according to its own current World Matrix.
  88379. * The mesh World Matrix is then reset.
  88380. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88382. * @see http://doc.babylonjs.com/resources/baking_transformations
  88383. * @returns the current mesh
  88384. */
  88385. bakeCurrentTransformIntoVertices(): Mesh;
  88386. /** @hidden */
  88387. readonly _positions: Nullable<Vector3[]>;
  88388. /** @hidden */
  88389. _resetPointsArrayCache(): Mesh;
  88390. /** @hidden */
  88391. _generatePointsArray(): boolean;
  88392. /**
  88393. * Returns a new Mesh object generated from the current mesh properties.
  88394. * This method must not get confused with createInstance()
  88395. * @param name is a string, the name given to the new mesh
  88396. * @param newParent can be any Node object (default `null`)
  88397. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88398. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88399. * @returns a new mesh
  88400. */
  88401. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  88402. /**
  88403. * Releases resources associated with this mesh.
  88404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88406. */
  88407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88408. /**
  88409. * Modifies the mesh geometry according to a displacement map.
  88410. * 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.
  88411. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88412. * @param url is a string, the URL from the image file is to be downloaded.
  88413. * @param minHeight is the lower limit of the displacement.
  88414. * @param maxHeight is the upper limit of the displacement.
  88415. * @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.
  88416. * @param uvOffset is an optional vector2 used to offset UV.
  88417. * @param uvScale is an optional vector2 used to scale UV.
  88418. * @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.
  88419. * @returns the Mesh.
  88420. */
  88421. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88422. /**
  88423. * Modifies the mesh geometry according to a displacementMap buffer.
  88424. * 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.
  88425. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88426. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88427. * @param heightMapWidth is the width of the buffer image.
  88428. * @param heightMapHeight is the height of the buffer image.
  88429. * @param minHeight is the lower limit of the displacement.
  88430. * @param maxHeight is the upper limit of the displacement.
  88431. * @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.
  88432. * @param uvOffset is an optional vector2 used to offset UV.
  88433. * @param uvScale is an optional vector2 used to scale UV.
  88434. * @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.
  88435. * @returns the Mesh.
  88436. */
  88437. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88438. /**
  88439. * Modify the mesh to get a flat shading rendering.
  88440. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88441. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88442. * @returns current mesh
  88443. */
  88444. convertToFlatShadedMesh(): Mesh;
  88445. /**
  88446. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88447. * In other words, more vertices, no more indices and a single bigger VBO.
  88448. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88449. * @returns current mesh
  88450. */
  88451. convertToUnIndexedMesh(): Mesh;
  88452. /**
  88453. * Inverses facet orientations.
  88454. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88455. * @param flipNormals will also inverts the normals
  88456. * @returns current mesh
  88457. */
  88458. flipFaces(flipNormals?: boolean): Mesh;
  88459. /**
  88460. * Increase the number of facets and hence vertices in a mesh
  88461. * Vertex normals are interpolated from existing vertex normals
  88462. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88463. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88464. */
  88465. increaseVertices(numberPerEdge: number): void;
  88466. /**
  88467. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88468. * This will undo any application of covertToFlatShadedMesh
  88469. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88470. */
  88471. forceSharedVertices(): void;
  88472. /** @hidden */
  88473. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88474. /** @hidden */
  88475. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88476. /**
  88477. * Creates a new InstancedMesh object from the mesh model.
  88478. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88479. * @param name defines the name of the new instance
  88480. * @returns a new InstancedMesh
  88481. */
  88482. createInstance(name: string): InstancedMesh;
  88483. /**
  88484. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88485. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88486. * @returns the current mesh
  88487. */
  88488. synchronizeInstances(): Mesh;
  88489. /**
  88490. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88491. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88492. * This should be used together with the simplification to avoid disappearing triangles.
  88493. * @param successCallback an optional success callback to be called after the optimization finished.
  88494. * @returns the current mesh
  88495. */
  88496. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88497. /**
  88498. * Serialize current mesh
  88499. * @param serializationObject defines the object which will receive the serialization data
  88500. */
  88501. serialize(serializationObject: any): void;
  88502. /** @hidden */
  88503. _syncGeometryWithMorphTargetManager(): void;
  88504. /** @hidden */
  88505. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88506. /**
  88507. * Returns a new Mesh object parsed from the source provided.
  88508. * @param parsedMesh is the source
  88509. * @param scene defines the hosting scene
  88510. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88511. * @returns a new Mesh
  88512. */
  88513. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88514. /**
  88515. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88516. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88517. * @param name defines the name of the mesh to create
  88518. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88519. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88520. * @param closePath creates a seam between the first and the last points of each path of the path array
  88521. * @param offset is taken in account only if the `pathArray` is containing a single path
  88522. * @param scene defines the hosting scene
  88523. * @param updatable defines if the mesh must be flagged as updatable
  88524. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88525. * @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)
  88526. * @returns a new Mesh
  88527. */
  88528. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88529. /**
  88530. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88531. * @param name defines the name of the mesh to create
  88532. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88533. * @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
  88534. * @param scene defines the hosting scene
  88535. * @param updatable defines if the mesh must be flagged as updatable
  88536. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88537. * @returns a new Mesh
  88538. */
  88539. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88540. /**
  88541. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88542. * @param name defines the name of the mesh to create
  88543. * @param size sets the size (float) of each box side (default 1)
  88544. * @param scene defines the hosting scene
  88545. * @param updatable defines if the mesh must be flagged as updatable
  88546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88547. * @returns a new Mesh
  88548. */
  88549. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88550. /**
  88551. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88552. * @param name defines the name of the mesh to create
  88553. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88554. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88555. * @param scene defines the hosting scene
  88556. * @param updatable defines if the mesh must be flagged as updatable
  88557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88558. * @returns a new Mesh
  88559. */
  88560. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88561. /**
  88562. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88563. * @param name defines the name of the mesh to create
  88564. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88565. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88566. * @param scene defines the hosting scene
  88567. * @returns a new Mesh
  88568. */
  88569. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88570. /**
  88571. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88572. * @param name defines the name of the mesh to create
  88573. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88574. * @param diameterTop set the top cap diameter (floats, default 1)
  88575. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88576. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88577. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88578. * @param scene defines the hosting scene
  88579. * @param updatable defines if the mesh must be flagged as updatable
  88580. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88581. * @returns a new Mesh
  88582. */
  88583. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88584. /**
  88585. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88586. * @param name defines the name of the mesh to create
  88587. * @param diameter sets the diameter size (float) of the torus (default 1)
  88588. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88589. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88590. * @param scene defines the hosting scene
  88591. * @param updatable defines if the mesh must be flagged as updatable
  88592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88593. * @returns a new Mesh
  88594. */
  88595. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88596. /**
  88597. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88598. * @param name defines the name of the mesh to create
  88599. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88600. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88601. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88602. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88603. * @param p the number of windings on X axis (positive integers, default 2)
  88604. * @param q the number of windings on Y axis (positive integers, default 3)
  88605. * @param scene defines the hosting scene
  88606. * @param updatable defines if the mesh must be flagged as updatable
  88607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88608. * @returns a new Mesh
  88609. */
  88610. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88611. /**
  88612. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88613. * @param name defines the name of the mesh to create
  88614. * @param points is an array successive Vector3
  88615. * @param scene defines the hosting scene
  88616. * @param updatable defines if the mesh must be flagged as updatable
  88617. * @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).
  88618. * @returns a new Mesh
  88619. */
  88620. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88621. /**
  88622. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88623. * @param name defines the name of the mesh to create
  88624. * @param points is an array successive Vector3
  88625. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88626. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88627. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88628. * @param scene defines the hosting scene
  88629. * @param updatable defines if the mesh must be flagged as updatable
  88630. * @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)
  88631. * @returns a new Mesh
  88632. */
  88633. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88634. /**
  88635. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88636. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88637. * 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.
  88638. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88639. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88640. * Remember you can only change the shape positions, not their number when updating a polygon.
  88641. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88642. * @param name defines the name of the mesh to create
  88643. * @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
  88644. * @param scene defines the hosting scene
  88645. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88646. * @param updatable defines if the mesh must be flagged as updatable
  88647. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88648. * @param earcutInjection can be used to inject your own earcut reference
  88649. * @returns a new Mesh
  88650. */
  88651. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88652. /**
  88653. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88654. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88655. * @param name defines the name of the mesh to create
  88656. * @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
  88657. * @param depth defines the height of extrusion
  88658. * @param scene defines the hosting scene
  88659. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88660. * @param updatable defines if the mesh must be flagged as updatable
  88661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88662. * @param earcutInjection can be used to inject your own earcut reference
  88663. * @returns a new Mesh
  88664. */
  88665. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88666. /**
  88667. * Creates an extruded shape mesh.
  88668. * 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
  88669. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88671. * @param name defines the name of the mesh to create
  88672. * @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
  88673. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88674. * @param scale is the value to scale the shape
  88675. * @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
  88676. * @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
  88677. * @param scene defines the hosting scene
  88678. * @param updatable defines if the mesh must be flagged as updatable
  88679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88680. * @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)
  88681. * @returns a new Mesh
  88682. */
  88683. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88684. /**
  88685. * Creates an custom extruded shape mesh.
  88686. * The custom extrusion is a parametric shape.
  88687. * It has no predefined shape. Its final shape will depend on the input parameters.
  88688. * Please consider using the same method from the MeshBuilder class instead
  88689. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88690. * @param name defines the name of the mesh to create
  88691. * @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
  88692. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88693. * @param scaleFunction is a custom Javascript function called on each path point
  88694. * @param rotationFunction is a custom Javascript function called on each path point
  88695. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88696. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88697. * @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
  88698. * @param scene defines the hosting scene
  88699. * @param updatable defines if the mesh must be flagged as updatable
  88700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88701. * @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)
  88702. * @returns a new Mesh
  88703. */
  88704. 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;
  88705. /**
  88706. * Creates lathe mesh.
  88707. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88708. * Please consider using the same method from the MeshBuilder class instead
  88709. * @param name defines the name of the mesh to create
  88710. * @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
  88711. * @param radius is the radius value of the lathe
  88712. * @param tessellation is the side number of the lathe.
  88713. * @param scene defines the hosting scene
  88714. * @param updatable defines if the mesh must be flagged as updatable
  88715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88716. * @returns a new Mesh
  88717. */
  88718. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88719. /**
  88720. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88721. * @param name defines the name of the mesh to create
  88722. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88723. * @param scene defines the hosting scene
  88724. * @param updatable defines if the mesh must be flagged as updatable
  88725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88726. * @returns a new Mesh
  88727. */
  88728. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88729. /**
  88730. * Creates a ground mesh.
  88731. * Please consider using the same method from the MeshBuilder class instead
  88732. * @param name defines the name of the mesh to create
  88733. * @param width set the width of the ground
  88734. * @param height set the height of the ground
  88735. * @param subdivisions sets the number of subdivisions per side
  88736. * @param scene defines the hosting scene
  88737. * @param updatable defines if the mesh must be flagged as updatable
  88738. * @returns a new Mesh
  88739. */
  88740. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88741. /**
  88742. * Creates a tiled ground mesh.
  88743. * Please consider using the same method from the MeshBuilder class instead
  88744. * @param name defines the name of the mesh to create
  88745. * @param xmin set the ground minimum X coordinate
  88746. * @param zmin set the ground minimum Y coordinate
  88747. * @param xmax set the ground maximum X coordinate
  88748. * @param zmax set the ground maximum Z coordinate
  88749. * @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
  88750. * @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
  88751. * @param scene defines the hosting scene
  88752. * @param updatable defines if the mesh must be flagged as updatable
  88753. * @returns a new Mesh
  88754. */
  88755. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88756. w: number;
  88757. h: number;
  88758. }, precision: {
  88759. w: number;
  88760. h: number;
  88761. }, scene: Scene, updatable?: boolean): Mesh;
  88762. /**
  88763. * Creates a ground mesh from a height map.
  88764. * Please consider using the same method from the MeshBuilder class instead
  88765. * @see http://doc.babylonjs.com/babylon101/height_map
  88766. * @param name defines the name of the mesh to create
  88767. * @param url sets the URL of the height map image resource
  88768. * @param width set the ground width size
  88769. * @param height set the ground height size
  88770. * @param subdivisions sets the number of subdivision per side
  88771. * @param minHeight is the minimum altitude on the ground
  88772. * @param maxHeight is the maximum altitude on the ground
  88773. * @param scene defines the hosting scene
  88774. * @param updatable defines if the mesh must be flagged as updatable
  88775. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88776. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88777. * @returns a new Mesh
  88778. */
  88779. 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;
  88780. /**
  88781. * Creates a tube mesh.
  88782. * The tube is a parametric shape.
  88783. * It has no predefined shape. Its final shape will depend on the input parameters.
  88784. * Please consider using the same method from the MeshBuilder class instead
  88785. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88786. * @param name defines the name of the mesh to create
  88787. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88788. * @param radius sets the tube radius size
  88789. * @param tessellation is the number of sides on the tubular surface
  88790. * @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
  88791. * @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
  88792. * @param scene defines the hosting scene
  88793. * @param updatable defines if the mesh must be flagged as updatable
  88794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88795. * @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)
  88796. * @returns a new Mesh
  88797. */
  88798. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88799. (i: number, distance: number): number;
  88800. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88801. /**
  88802. * Creates a polyhedron mesh.
  88803. * Please consider using the same method from the MeshBuilder class instead.
  88804. * * 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
  88805. * * The parameter `size` (positive float, default 1) sets the polygon size
  88806. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88807. * * 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`
  88808. * * 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
  88809. * * 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)`)
  88810. * * 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
  88811. * * 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
  88812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88813. * * If you create a double-sided mesh, you can choose what parts of 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
  88814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88815. * @param name defines the name of the mesh to create
  88816. * @param options defines the options used to create the mesh
  88817. * @param scene defines the hosting scene
  88818. * @returns a new Mesh
  88819. */
  88820. static CreatePolyhedron(name: string, options: {
  88821. type?: number;
  88822. size?: number;
  88823. sizeX?: number;
  88824. sizeY?: number;
  88825. sizeZ?: number;
  88826. custom?: any;
  88827. faceUV?: Vector4[];
  88828. faceColors?: Color4[];
  88829. updatable?: boolean;
  88830. sideOrientation?: number;
  88831. }, scene: Scene): Mesh;
  88832. /**
  88833. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88834. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88835. * * 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`)
  88836. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88837. * * 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
  88838. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88839. * * If you create a double-sided mesh, you can choose what parts of 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
  88840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88841. * @param name defines the name of the mesh
  88842. * @param options defines the options used to create the mesh
  88843. * @param scene defines the hosting scene
  88844. * @returns a new Mesh
  88845. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88846. */
  88847. static CreateIcoSphere(name: string, options: {
  88848. radius?: number;
  88849. flat?: boolean;
  88850. subdivisions?: number;
  88851. sideOrientation?: number;
  88852. updatable?: boolean;
  88853. }, scene: Scene): Mesh;
  88854. /**
  88855. * Creates a decal mesh.
  88856. * Please consider using the same method from the MeshBuilder class instead.
  88857. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88858. * @param name defines the name of the mesh
  88859. * @param sourceMesh defines the mesh receiving the decal
  88860. * @param position sets the position of the decal in world coordinates
  88861. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88862. * @param size sets the decal scaling
  88863. * @param angle sets the angle to rotate the decal
  88864. * @returns a new Mesh
  88865. */
  88866. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88867. /**
  88868. * Prepare internal position array for software CPU skinning
  88869. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88870. */
  88871. setPositionsForCPUSkinning(): Float32Array;
  88872. /**
  88873. * Prepare internal normal array for software CPU skinning
  88874. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88875. */
  88876. setNormalsForCPUSkinning(): Float32Array;
  88877. /**
  88878. * Updates the vertex buffer by applying transformation from the bones
  88879. * @param skeleton defines the skeleton to apply to current mesh
  88880. * @returns the current mesh
  88881. */
  88882. applySkeleton(skeleton: Skeleton): Mesh;
  88883. /**
  88884. * 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
  88885. * @param meshes defines the list of meshes to scan
  88886. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88887. */
  88888. static MinMax(meshes: AbstractMesh[]): {
  88889. min: Vector3;
  88890. max: Vector3;
  88891. };
  88892. /**
  88893. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88894. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88895. * @returns a vector3
  88896. */
  88897. static Center(meshesOrMinMaxVector: {
  88898. min: Vector3;
  88899. max: Vector3;
  88900. } | AbstractMesh[]): Vector3;
  88901. /**
  88902. * Merge the array of meshes into a single mesh for performance reasons.
  88903. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88904. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88905. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88906. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88907. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88908. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88909. * @returns a new mesh
  88910. */
  88911. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88912. /** @hidden */
  88913. addInstance(instance: InstancedMesh): void;
  88914. /** @hidden */
  88915. removeInstance(instance: InstancedMesh): void;
  88916. }
  88917. }
  88918. declare module BABYLON {
  88919. /**
  88920. * This is the base class of all the camera used in the application.
  88921. * @see http://doc.babylonjs.com/features/cameras
  88922. */
  88923. export class Camera extends Node {
  88924. /** @hidden */
  88925. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88926. /**
  88927. * This is the default projection mode used by the cameras.
  88928. * It helps recreating a feeling of perspective and better appreciate depth.
  88929. * This is the best way to simulate real life cameras.
  88930. */
  88931. static readonly PERSPECTIVE_CAMERA: number;
  88932. /**
  88933. * This helps creating camera with an orthographic mode.
  88934. * 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.
  88935. */
  88936. static readonly ORTHOGRAPHIC_CAMERA: number;
  88937. /**
  88938. * This is the default FOV mode for perspective cameras.
  88939. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88940. */
  88941. static readonly FOVMODE_VERTICAL_FIXED: number;
  88942. /**
  88943. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88944. */
  88945. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88946. /**
  88947. * This specifies ther is no need for a camera rig.
  88948. * Basically only one eye is rendered corresponding to the camera.
  88949. */
  88950. static readonly RIG_MODE_NONE: number;
  88951. /**
  88952. * Simulates a camera Rig with one blue eye and one red eye.
  88953. * This can be use with 3d blue and red glasses.
  88954. */
  88955. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88956. /**
  88957. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88958. */
  88959. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88960. /**
  88961. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88962. */
  88963. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88964. /**
  88965. * Defines that both eyes of the camera will be rendered over under each other.
  88966. */
  88967. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88968. /**
  88969. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88970. */
  88971. static readonly RIG_MODE_VR: number;
  88972. /**
  88973. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88974. */
  88975. static readonly RIG_MODE_WEBVR: number;
  88976. /**
  88977. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88978. */
  88979. static readonly RIG_MODE_CUSTOM: number;
  88980. /**
  88981. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88982. */
  88983. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88984. /**
  88985. * Define the input manager associated with the camera.
  88986. */
  88987. inputs: CameraInputsManager<Camera>;
  88988. /** @hidden */
  88989. _position: Vector3;
  88990. /**
  88991. * Define the current local position of the camera in the scene
  88992. */
  88993. position: Vector3;
  88994. /**
  88995. * The vector the camera should consider as up.
  88996. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88997. */
  88998. upVector: Vector3;
  88999. /**
  89000. * Define the current limit on the left side for an orthographic camera
  89001. * In scene unit
  89002. */
  89003. orthoLeft: Nullable<number>;
  89004. /**
  89005. * Define the current limit on the right side for an orthographic camera
  89006. * In scene unit
  89007. */
  89008. orthoRight: Nullable<number>;
  89009. /**
  89010. * Define the current limit on the bottom side for an orthographic camera
  89011. * In scene unit
  89012. */
  89013. orthoBottom: Nullable<number>;
  89014. /**
  89015. * Define the current limit on the top side for an orthographic camera
  89016. * In scene unit
  89017. */
  89018. orthoTop: Nullable<number>;
  89019. /**
  89020. * Field Of View is set in Radians. (default is 0.8)
  89021. */
  89022. fov: number;
  89023. /**
  89024. * Define the minimum distance the camera can see from.
  89025. * This is important to note that the depth buffer are not infinite and the closer it starts
  89026. * the more your scene might encounter depth fighting issue.
  89027. */
  89028. minZ: number;
  89029. /**
  89030. * Define the maximum distance the camera can see to.
  89031. * This is important to note that the depth buffer are not infinite and the further it end
  89032. * the more your scene might encounter depth fighting issue.
  89033. */
  89034. maxZ: number;
  89035. /**
  89036. * Define the default inertia of the camera.
  89037. * This helps giving a smooth feeling to the camera movement.
  89038. */
  89039. inertia: number;
  89040. /**
  89041. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89042. */
  89043. mode: number;
  89044. /**
  89045. * Define wether the camera is intermediate.
  89046. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89047. */
  89048. isIntermediate: boolean;
  89049. /**
  89050. * Define the viewport of the camera.
  89051. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89052. */
  89053. viewport: Viewport;
  89054. /**
  89055. * Restricts the camera to viewing objects with the same layerMask.
  89056. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89057. */
  89058. layerMask: number;
  89059. /**
  89060. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89061. */
  89062. fovMode: number;
  89063. /**
  89064. * Rig mode of the camera.
  89065. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89066. * This is normally controlled byt the camera themselves as internal use.
  89067. */
  89068. cameraRigMode: number;
  89069. /**
  89070. * Defines the distance between both "eyes" in case of a RIG
  89071. */
  89072. interaxialDistance: number;
  89073. /**
  89074. * Defines if stereoscopic rendering is done side by side or over under.
  89075. */
  89076. isStereoscopicSideBySide: boolean;
  89077. /**
  89078. * 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
  89079. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89080. * else in the scene. (Eg. security camera)
  89081. *
  89082. * 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)
  89083. */
  89084. customRenderTargets: RenderTargetTexture[];
  89085. /**
  89086. * When set, the camera will render to this render target instead of the default canvas
  89087. *
  89088. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89089. */
  89090. outputRenderTarget: Nullable<RenderTargetTexture>;
  89091. /**
  89092. * Observable triggered when the camera view matrix has changed.
  89093. */
  89094. onViewMatrixChangedObservable: Observable<Camera>;
  89095. /**
  89096. * Observable triggered when the camera Projection matrix has changed.
  89097. */
  89098. onProjectionMatrixChangedObservable: Observable<Camera>;
  89099. /**
  89100. * Observable triggered when the inputs have been processed.
  89101. */
  89102. onAfterCheckInputsObservable: Observable<Camera>;
  89103. /**
  89104. * Observable triggered when reset has been called and applied to the camera.
  89105. */
  89106. onRestoreStateObservable: Observable<Camera>;
  89107. /** @hidden */
  89108. _cameraRigParams: any;
  89109. /** @hidden */
  89110. _rigCameras: Camera[];
  89111. /** @hidden */
  89112. _rigPostProcess: Nullable<PostProcess>;
  89113. protected _webvrViewMatrix: Matrix;
  89114. /** @hidden */
  89115. _skipRendering: boolean;
  89116. /** @hidden */
  89117. _projectionMatrix: Matrix;
  89118. /** @hidden */
  89119. _postProcesses: Nullable<PostProcess>[];
  89120. /** @hidden */
  89121. _activeMeshes: SmartArray<AbstractMesh>;
  89122. protected _globalPosition: Vector3;
  89123. /** @hidden */
  89124. _computedViewMatrix: Matrix;
  89125. private _doNotComputeProjectionMatrix;
  89126. private _transformMatrix;
  89127. private _frustumPlanes;
  89128. private _refreshFrustumPlanes;
  89129. private _storedFov;
  89130. private _stateStored;
  89131. /**
  89132. * Instantiates a new camera object.
  89133. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89134. * @see http://doc.babylonjs.com/features/cameras
  89135. * @param name Defines the name of the camera in the scene
  89136. * @param position Defines the position of the camera
  89137. * @param scene Defines the scene the camera belongs too
  89138. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89139. */
  89140. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89141. /**
  89142. * Store current camera state (fov, position, etc..)
  89143. * @returns the camera
  89144. */
  89145. storeState(): Camera;
  89146. /**
  89147. * Restores the camera state values if it has been stored. You must call storeState() first
  89148. */
  89149. protected _restoreStateValues(): boolean;
  89150. /**
  89151. * Restored camera state. You must call storeState() first.
  89152. * @returns true if restored and false otherwise
  89153. */
  89154. restoreState(): boolean;
  89155. /**
  89156. * Gets the class name of the camera.
  89157. * @returns the class name
  89158. */
  89159. getClassName(): string;
  89160. /** @hidden */
  89161. readonly _isCamera: boolean;
  89162. /**
  89163. * Gets a string representation of the camera useful for debug purpose.
  89164. * @param fullDetails Defines that a more verboe level of logging is required
  89165. * @returns the string representation
  89166. */
  89167. toString(fullDetails?: boolean): string;
  89168. /**
  89169. * Gets the current world space position of the camera.
  89170. */
  89171. readonly globalPosition: Vector3;
  89172. /**
  89173. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89174. * @returns the active meshe list
  89175. */
  89176. getActiveMeshes(): SmartArray<AbstractMesh>;
  89177. /**
  89178. * Check wether a mesh is part of the current active mesh list of the camera
  89179. * @param mesh Defines the mesh to check
  89180. * @returns true if active, false otherwise
  89181. */
  89182. isActiveMesh(mesh: Mesh): boolean;
  89183. /**
  89184. * Is this camera ready to be used/rendered
  89185. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89186. * @return true if the camera is ready
  89187. */
  89188. isReady(completeCheck?: boolean): boolean;
  89189. /** @hidden */
  89190. _initCache(): void;
  89191. /** @hidden */
  89192. _updateCache(ignoreParentClass?: boolean): void;
  89193. /** @hidden */
  89194. _isSynchronized(): boolean;
  89195. /** @hidden */
  89196. _isSynchronizedViewMatrix(): boolean;
  89197. /** @hidden */
  89198. _isSynchronizedProjectionMatrix(): boolean;
  89199. /**
  89200. * Attach the input controls to a specific dom element to get the input from.
  89201. * @param element Defines the element the controls should be listened from
  89202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89203. */
  89204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89205. /**
  89206. * Detach the current controls from the specified dom element.
  89207. * @param element Defines the element to stop listening the inputs from
  89208. */
  89209. detachControl(element: HTMLElement): void;
  89210. /**
  89211. * Update the camera state according to the different inputs gathered during the frame.
  89212. */
  89213. update(): void;
  89214. /** @hidden */
  89215. _checkInputs(): void;
  89216. /** @hidden */
  89217. readonly rigCameras: Camera[];
  89218. /**
  89219. * Gets the post process used by the rig cameras
  89220. */
  89221. readonly rigPostProcess: Nullable<PostProcess>;
  89222. /**
  89223. * Internal, gets the first post proces.
  89224. * @returns the first post process to be run on this camera.
  89225. */
  89226. _getFirstPostProcess(): Nullable<PostProcess>;
  89227. private _cascadePostProcessesToRigCams;
  89228. /**
  89229. * Attach a post process to the camera.
  89230. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89231. * @param postProcess The post process to attach to the camera
  89232. * @param insertAt The position of the post process in case several of them are in use in the scene
  89233. * @returns the position the post process has been inserted at
  89234. */
  89235. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89236. /**
  89237. * Detach a post process to the camera.
  89238. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89239. * @param postProcess The post process to detach from the camera
  89240. */
  89241. detachPostProcess(postProcess: PostProcess): void;
  89242. /**
  89243. * Gets the current world matrix of the camera
  89244. */
  89245. getWorldMatrix(): Matrix;
  89246. /** @hidden */
  89247. _getViewMatrix(): Matrix;
  89248. /**
  89249. * Gets the current view matrix of the camera.
  89250. * @param force forces the camera to recompute the matrix without looking at the cached state
  89251. * @returns the view matrix
  89252. */
  89253. getViewMatrix(force?: boolean): Matrix;
  89254. /**
  89255. * Freeze the projection matrix.
  89256. * It will prevent the cache check of the camera projection compute and can speed up perf
  89257. * if no parameter of the camera are meant to change
  89258. * @param projection Defines manually a projection if necessary
  89259. */
  89260. freezeProjectionMatrix(projection?: Matrix): void;
  89261. /**
  89262. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89263. */
  89264. unfreezeProjectionMatrix(): void;
  89265. /**
  89266. * Gets the current projection matrix of the camera.
  89267. * @param force forces the camera to recompute the matrix without looking at the cached state
  89268. * @returns the projection matrix
  89269. */
  89270. getProjectionMatrix(force?: boolean): Matrix;
  89271. /**
  89272. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89273. * @returns a Matrix
  89274. */
  89275. getTransformationMatrix(): Matrix;
  89276. private _updateFrustumPlanes;
  89277. /**
  89278. * Checks if a cullable object (mesh...) is in the camera frustum
  89279. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89280. * @param target The object to check
  89281. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89282. * @returns true if the object is in frustum otherwise false
  89283. */
  89284. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89285. /**
  89286. * Checks if a cullable object (mesh...) is in the camera frustum
  89287. * Unlike isInFrustum this cheks the full bounding box
  89288. * @param target The object to check
  89289. * @returns true if the object is in frustum otherwise false
  89290. */
  89291. isCompletelyInFrustum(target: ICullable): boolean;
  89292. /**
  89293. * Gets a ray in the forward direction from the camera.
  89294. * @param length Defines the length of the ray to create
  89295. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89296. * @param origin Defines the start point of the ray which defaults to the camera position
  89297. * @returns the forward ray
  89298. */
  89299. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89300. /**
  89301. * Releases resources associated with this node.
  89302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89304. */
  89305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89306. /** @hidden */
  89307. _isLeftCamera: boolean;
  89308. /**
  89309. * Gets the left camera of a rig setup in case of Rigged Camera
  89310. */
  89311. readonly isLeftCamera: boolean;
  89312. /** @hidden */
  89313. _isRightCamera: boolean;
  89314. /**
  89315. * Gets the right camera of a rig setup in case of Rigged Camera
  89316. */
  89317. readonly isRightCamera: boolean;
  89318. /**
  89319. * Gets the left camera of a rig setup in case of Rigged Camera
  89320. */
  89321. readonly leftCamera: Nullable<FreeCamera>;
  89322. /**
  89323. * Gets the right camera of a rig setup in case of Rigged Camera
  89324. */
  89325. readonly rightCamera: Nullable<FreeCamera>;
  89326. /**
  89327. * Gets the left camera target of a rig setup in case of Rigged Camera
  89328. * @returns the target position
  89329. */
  89330. getLeftTarget(): Nullable<Vector3>;
  89331. /**
  89332. * Gets the right camera target of a rig setup in case of Rigged Camera
  89333. * @returns the target position
  89334. */
  89335. getRightTarget(): Nullable<Vector3>;
  89336. /**
  89337. * @hidden
  89338. */
  89339. setCameraRigMode(mode: number, rigParams: any): void;
  89340. /** @hidden */
  89341. static _setStereoscopicRigMode(camera: Camera): void;
  89342. /** @hidden */
  89343. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89344. /** @hidden */
  89345. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89346. /** @hidden */
  89347. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89348. /** @hidden */
  89349. _getVRProjectionMatrix(): Matrix;
  89350. protected _updateCameraRotationMatrix(): void;
  89351. protected _updateWebVRCameraRotationMatrix(): void;
  89352. /**
  89353. * This function MUST be overwritten by the different WebVR cameras available.
  89354. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89355. * @hidden
  89356. */
  89357. _getWebVRProjectionMatrix(): Matrix;
  89358. /**
  89359. * This function MUST be overwritten by the different WebVR cameras available.
  89360. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89361. * @hidden
  89362. */
  89363. _getWebVRViewMatrix(): Matrix;
  89364. /** @hidden */
  89365. setCameraRigParameter(name: string, value: any): void;
  89366. /**
  89367. * needs to be overridden by children so sub has required properties to be copied
  89368. * @hidden
  89369. */
  89370. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89371. /**
  89372. * May need to be overridden by children
  89373. * @hidden
  89374. */
  89375. _updateRigCameras(): void;
  89376. /** @hidden */
  89377. _setupInputs(): void;
  89378. /**
  89379. * Serialiaze the camera setup to a json represention
  89380. * @returns the JSON representation
  89381. */
  89382. serialize(): any;
  89383. /**
  89384. * Clones the current camera.
  89385. * @param name The cloned camera name
  89386. * @returns the cloned camera
  89387. */
  89388. clone(name: string): Camera;
  89389. /**
  89390. * Gets the direction of the camera relative to a given local axis.
  89391. * @param localAxis Defines the reference axis to provide a relative direction.
  89392. * @return the direction
  89393. */
  89394. getDirection(localAxis: Vector3): Vector3;
  89395. /**
  89396. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89397. * @param localAxis Defines the reference axis to provide a relative direction.
  89398. * @param result Defines the vector to store the result in
  89399. */
  89400. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89401. /**
  89402. * Gets a camera constructor for a given camera type
  89403. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89404. * @param name The name of the camera the result will be able to instantiate
  89405. * @param scene The scene the result will construct the camera in
  89406. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89407. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89408. * @returns a factory method to construc the camera
  89409. */
  89410. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89411. /**
  89412. * Compute the world matrix of the camera.
  89413. * @returns the camera workd matrix
  89414. */
  89415. computeWorldMatrix(): Matrix;
  89416. /**
  89417. * Parse a JSON and creates the camera from the parsed information
  89418. * @param parsedCamera The JSON to parse
  89419. * @param scene The scene to instantiate the camera in
  89420. * @returns the newly constructed camera
  89421. */
  89422. static Parse(parsedCamera: any, scene: Scene): Camera;
  89423. }
  89424. }
  89425. declare module BABYLON {
  89426. /**
  89427. * Class containing static functions to help procedurally build meshes
  89428. */
  89429. export class DiscBuilder {
  89430. /**
  89431. * Creates a plane polygonal mesh. By default, this is a disc
  89432. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89433. * * 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
  89434. * * 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
  89435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89438. * @param name defines the name of the mesh
  89439. * @param options defines the options used to create the mesh
  89440. * @param scene defines the hosting scene
  89441. * @returns the plane polygonal mesh
  89442. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89443. */
  89444. static CreateDisc(name: string, options: {
  89445. radius?: number;
  89446. tessellation?: number;
  89447. arc?: number;
  89448. updatable?: boolean;
  89449. sideOrientation?: number;
  89450. frontUVs?: Vector4;
  89451. backUVs?: Vector4;
  89452. }, scene?: Nullable<Scene>): Mesh;
  89453. }
  89454. }
  89455. declare module BABYLON {
  89456. /**
  89457. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89458. *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.
  89459. * The SPS is also a particle system. It provides some methods to manage the particles.
  89460. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89461. *
  89462. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89463. */
  89464. export class SolidParticleSystem implements IDisposable {
  89465. /**
  89466. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89467. * Example : var p = SPS.particles[i];
  89468. */
  89469. particles: SolidParticle[];
  89470. /**
  89471. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89472. */
  89473. nbParticles: number;
  89474. /**
  89475. * If the particles must ever face the camera (default false). Useful for planar particles.
  89476. */
  89477. billboard: boolean;
  89478. /**
  89479. * Recompute normals when adding a shape
  89480. */
  89481. recomputeNormals: boolean;
  89482. /**
  89483. * This a counter ofr your own usage. It's not set by any SPS functions.
  89484. */
  89485. counter: number;
  89486. /**
  89487. * The SPS name. This name is also given to the underlying mesh.
  89488. */
  89489. name: string;
  89490. /**
  89491. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89492. */
  89493. mesh: Mesh;
  89494. /**
  89495. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89496. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89497. */
  89498. vars: any;
  89499. /**
  89500. * This array is populated when the SPS is set as 'pickable'.
  89501. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89502. * Each element of this array is an object `{idx: int, faceId: int}`.
  89503. * `idx` is the picked particle index in the `SPS.particles` array
  89504. * `faceId` is the picked face index counted within this particle.
  89505. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89506. */
  89507. pickedParticles: {
  89508. idx: number;
  89509. faceId: number;
  89510. }[];
  89511. /**
  89512. * This array is populated when `enableDepthSort` is set to true.
  89513. * Each element of this array is an instance of the class DepthSortedParticle.
  89514. */
  89515. depthSortedParticles: DepthSortedParticle[];
  89516. /**
  89517. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89518. * @hidden
  89519. */
  89520. _bSphereOnly: boolean;
  89521. /**
  89522. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89523. * @hidden
  89524. */
  89525. _bSphereRadiusFactor: number;
  89526. private _scene;
  89527. private _positions;
  89528. private _indices;
  89529. private _normals;
  89530. private _colors;
  89531. private _uvs;
  89532. private _indices32;
  89533. private _positions32;
  89534. private _normals32;
  89535. private _fixedNormal32;
  89536. private _colors32;
  89537. private _uvs32;
  89538. private _index;
  89539. private _updatable;
  89540. private _pickable;
  89541. private _isVisibilityBoxLocked;
  89542. private _alwaysVisible;
  89543. private _depthSort;
  89544. private _shapeCounter;
  89545. private _copy;
  89546. private _color;
  89547. private _computeParticleColor;
  89548. private _computeParticleTexture;
  89549. private _computeParticleRotation;
  89550. private _computeParticleVertex;
  89551. private _computeBoundingBox;
  89552. private _depthSortParticles;
  89553. private _camera;
  89554. private _mustUnrotateFixedNormals;
  89555. private _particlesIntersect;
  89556. private _needs32Bits;
  89557. /**
  89558. * Creates a SPS (Solid Particle System) object.
  89559. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89560. * @param scene (Scene) is the scene in which the SPS is added.
  89561. * @param options defines the options of the sps e.g.
  89562. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89563. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89564. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89565. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89566. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89567. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89568. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89569. */
  89570. constructor(name: string, scene: Scene, options?: {
  89571. updatable?: boolean;
  89572. isPickable?: boolean;
  89573. enableDepthSort?: boolean;
  89574. particleIntersection?: boolean;
  89575. boundingSphereOnly?: boolean;
  89576. bSphereRadiusFactor?: number;
  89577. });
  89578. /**
  89579. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89580. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89581. * @returns the created mesh
  89582. */
  89583. buildMesh(): Mesh;
  89584. /**
  89585. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89586. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89587. * Thus the particles generated from `digest()` have their property `position` set yet.
  89588. * @param mesh ( Mesh ) is the mesh to be digested
  89589. * @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
  89590. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89591. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89592. * @returns the current SPS
  89593. */
  89594. digest(mesh: Mesh, options?: {
  89595. facetNb?: number;
  89596. number?: number;
  89597. delta?: number;
  89598. }): SolidParticleSystem;
  89599. private _unrotateFixedNormals;
  89600. private _resetCopy;
  89601. private _meshBuilder;
  89602. private _posToShape;
  89603. private _uvsToShapeUV;
  89604. private _addParticle;
  89605. /**
  89606. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89607. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89608. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89609. * @param nb (positive integer) the number of particles to be created from this model
  89610. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89611. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89612. * @returns the number of shapes in the system
  89613. */
  89614. addShape(mesh: Mesh, nb: number, options?: {
  89615. positionFunction?: any;
  89616. vertexFunction?: any;
  89617. }): number;
  89618. private _rebuildParticle;
  89619. /**
  89620. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89621. * @returns the SPS.
  89622. */
  89623. rebuildMesh(): SolidParticleSystem;
  89624. /**
  89625. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89626. * This method calls `updateParticle()` for each particle of the SPS.
  89627. * For an animated SPS, it is usually called within the render loop.
  89628. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89629. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89630. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89631. * @returns the SPS.
  89632. */
  89633. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89634. /**
  89635. * Disposes the SPS.
  89636. */
  89637. dispose(): void;
  89638. /**
  89639. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89640. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89641. * @returns the SPS.
  89642. */
  89643. refreshVisibleSize(): SolidParticleSystem;
  89644. /**
  89645. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89646. * @param size the size (float) of the visibility box
  89647. * note : this doesn't lock the SPS mesh bounding box.
  89648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89649. */
  89650. setVisibilityBox(size: number): void;
  89651. /**
  89652. * Gets whether the SPS as always visible or not
  89653. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89654. */
  89655. /**
  89656. * Sets the SPS as always visible or not
  89657. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89658. */
  89659. isAlwaysVisible: boolean;
  89660. /**
  89661. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89662. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89663. */
  89664. /**
  89665. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89666. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89667. */
  89668. isVisibilityBoxLocked: boolean;
  89669. /**
  89670. * Tells to `setParticles()` to compute the particle rotations or not.
  89671. * Default value : true. The SPS is faster when it's set to false.
  89672. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89673. */
  89674. /**
  89675. * Gets if `setParticles()` computes the particle rotations or not.
  89676. * Default value : true. The SPS is faster when it's set to false.
  89677. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89678. */
  89679. computeParticleRotation: boolean;
  89680. /**
  89681. * Tells to `setParticles()` to compute the particle colors or not.
  89682. * Default value : true. The SPS is faster when it's set to false.
  89683. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89684. */
  89685. /**
  89686. * Gets if `setParticles()` computes the particle colors or not.
  89687. * Default value : true. The SPS is faster when it's set to false.
  89688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89689. */
  89690. computeParticleColor: boolean;
  89691. /**
  89692. * Gets if `setParticles()` computes the particle textures or not.
  89693. * Default value : true. The SPS is faster when it's set to false.
  89694. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89695. */
  89696. computeParticleTexture: boolean;
  89697. /**
  89698. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89699. * Default value : false. The SPS is faster when it's set to false.
  89700. * Note : the particle custom vertex positions aren't stored values.
  89701. */
  89702. /**
  89703. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89704. * Default value : false. The SPS is faster when it's set to false.
  89705. * Note : the particle custom vertex positions aren't stored values.
  89706. */
  89707. computeParticleVertex: boolean;
  89708. /**
  89709. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89710. */
  89711. /**
  89712. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89713. */
  89714. computeBoundingBox: boolean;
  89715. /**
  89716. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89717. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89718. * Default : `true`
  89719. */
  89720. /**
  89721. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89722. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89723. * Default : `true`
  89724. */
  89725. depthSortParticles: boolean;
  89726. /**
  89727. * This function does nothing. It may be overwritten to set all the particle first values.
  89728. * The SPS doesn't call this function, you may have to call it by your own.
  89729. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89730. */
  89731. initParticles(): void;
  89732. /**
  89733. * This function does nothing. It may be overwritten to recycle a particle.
  89734. * The SPS doesn't call this function, you may have to call it by your own.
  89735. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89736. * @param particle The particle to recycle
  89737. * @returns the recycled particle
  89738. */
  89739. recycleParticle(particle: SolidParticle): SolidParticle;
  89740. /**
  89741. * Updates a particle : this function should be overwritten by the user.
  89742. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89744. * @example : just set a particle position or velocity and recycle conditions
  89745. * @param particle The particle to update
  89746. * @returns the updated particle
  89747. */
  89748. updateParticle(particle: SolidParticle): SolidParticle;
  89749. /**
  89750. * Updates a vertex of a particle : it can be overwritten by the user.
  89751. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89752. * @param particle the current particle
  89753. * @param vertex the current index of the current particle
  89754. * @param pt the index of the current vertex in the particle shape
  89755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89756. * @example : just set a vertex particle position
  89757. * @returns the updated vertex
  89758. */
  89759. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89760. /**
  89761. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89762. * This does nothing and may be overwritten by the user.
  89763. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89764. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89765. * @param update the boolean update value actually passed to setParticles()
  89766. */
  89767. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89768. /**
  89769. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89770. * This will be passed three parameters.
  89771. * This does nothing and may be overwritten by the user.
  89772. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89773. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89774. * @param update the boolean update value actually passed to setParticles()
  89775. */
  89776. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89777. }
  89778. }
  89779. declare module BABYLON {
  89780. /**
  89781. * Represents one particle of a solid particle system.
  89782. */
  89783. export class SolidParticle {
  89784. /**
  89785. * particle global index
  89786. */
  89787. idx: number;
  89788. /**
  89789. * The color of the particle
  89790. */
  89791. color: Nullable<Color4>;
  89792. /**
  89793. * The world space position of the particle.
  89794. */
  89795. position: Vector3;
  89796. /**
  89797. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89798. */
  89799. rotation: Vector3;
  89800. /**
  89801. * The world space rotation quaternion of the particle.
  89802. */
  89803. rotationQuaternion: Nullable<Quaternion>;
  89804. /**
  89805. * The scaling of the particle.
  89806. */
  89807. scaling: Vector3;
  89808. /**
  89809. * The uvs of the particle.
  89810. */
  89811. uvs: Vector4;
  89812. /**
  89813. * The current speed of the particle.
  89814. */
  89815. velocity: Vector3;
  89816. /**
  89817. * The pivot point in the particle local space.
  89818. */
  89819. pivot: Vector3;
  89820. /**
  89821. * Must the particle be translated from its pivot point in its local space ?
  89822. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89823. * Default : false
  89824. */
  89825. translateFromPivot: boolean;
  89826. /**
  89827. * Is the particle active or not ?
  89828. */
  89829. alive: boolean;
  89830. /**
  89831. * Is the particle visible or not ?
  89832. */
  89833. isVisible: boolean;
  89834. /**
  89835. * Index of this particle in the global "positions" array (Internal use)
  89836. * @hidden
  89837. */
  89838. _pos: number;
  89839. /**
  89840. * @hidden Index of this particle in the global "indices" array (Internal use)
  89841. */
  89842. _ind: number;
  89843. /**
  89844. * @hidden ModelShape of this particle (Internal use)
  89845. */
  89846. _model: ModelShape;
  89847. /**
  89848. * ModelShape id of this particle
  89849. */
  89850. shapeId: number;
  89851. /**
  89852. * Index of the particle in its shape id (Internal use)
  89853. */
  89854. idxInShape: number;
  89855. /**
  89856. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89857. */
  89858. _modelBoundingInfo: BoundingInfo;
  89859. /**
  89860. * @hidden Particle BoundingInfo object (Internal use)
  89861. */
  89862. _boundingInfo: BoundingInfo;
  89863. /**
  89864. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89865. */
  89866. _sps: SolidParticleSystem;
  89867. /**
  89868. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89869. */
  89870. _stillInvisible: boolean;
  89871. /**
  89872. * @hidden Last computed particle rotation matrix
  89873. */
  89874. _rotationMatrix: number[];
  89875. /**
  89876. * Parent particle Id, if any.
  89877. * Default null.
  89878. */
  89879. parentId: Nullable<number>;
  89880. /**
  89881. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89882. * The possible values are :
  89883. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89884. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89887. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89888. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89889. * */
  89890. cullingStrategy: number;
  89891. /**
  89892. * @hidden Internal global position in the SPS.
  89893. */
  89894. _globalPosition: Vector3;
  89895. /**
  89896. * Creates a Solid Particle object.
  89897. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89898. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89899. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89900. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89901. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89902. * @param shapeId (integer) is the model shape identifier in the SPS.
  89903. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89904. * @param sps defines the sps it is associated to
  89905. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89906. */
  89907. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89908. /**
  89909. * Legacy support, changed scale to scaling
  89910. */
  89911. /**
  89912. * Legacy support, changed scale to scaling
  89913. */
  89914. scale: Vector3;
  89915. /**
  89916. * Legacy support, changed quaternion to rotationQuaternion
  89917. */
  89918. /**
  89919. * Legacy support, changed quaternion to rotationQuaternion
  89920. */
  89921. quaternion: Nullable<Quaternion>;
  89922. /**
  89923. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89924. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89925. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89926. * @returns true if it intersects
  89927. */
  89928. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89929. /**
  89930. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89931. * A particle is in the frustum if its bounding box intersects the frustum
  89932. * @param frustumPlanes defines the frustum to test
  89933. * @returns true if the particle is in the frustum planes
  89934. */
  89935. isInFrustum(frustumPlanes: Plane[]): boolean;
  89936. /**
  89937. * get the rotation matrix of the particle
  89938. * @hidden
  89939. */
  89940. getRotationMatrix(m: Matrix): void;
  89941. }
  89942. /**
  89943. * Represents the shape of the model used by one particle of a solid particle system.
  89944. * SPS internal tool, don't use it manually.
  89945. */
  89946. export class ModelShape {
  89947. /**
  89948. * The shape id
  89949. * @hidden
  89950. */
  89951. shapeID: number;
  89952. /**
  89953. * flat array of model positions (internal use)
  89954. * @hidden
  89955. */
  89956. _shape: Vector3[];
  89957. /**
  89958. * flat array of model UVs (internal use)
  89959. * @hidden
  89960. */
  89961. _shapeUV: number[];
  89962. /**
  89963. * length of the shape in the model indices array (internal use)
  89964. * @hidden
  89965. */
  89966. _indicesLength: number;
  89967. /**
  89968. * Custom position function (internal use)
  89969. * @hidden
  89970. */
  89971. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89972. /**
  89973. * Custom vertex function (internal use)
  89974. * @hidden
  89975. */
  89976. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89977. /**
  89978. * 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.
  89979. * SPS internal tool, don't use it manually.
  89980. * @hidden
  89981. */
  89982. 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>);
  89983. }
  89984. /**
  89985. * Represents a Depth Sorted Particle in the solid particle system.
  89986. */
  89987. export class DepthSortedParticle {
  89988. /**
  89989. * Index of the particle in the "indices" array
  89990. */
  89991. ind: number;
  89992. /**
  89993. * Length of the particle shape in the "indices" array
  89994. */
  89995. indicesLength: number;
  89996. /**
  89997. * Squared distance from the particle to the camera
  89998. */
  89999. sqDistance: number;
  90000. }
  90001. }
  90002. declare module BABYLON {
  90003. /**
  90004. * @hidden
  90005. */
  90006. export class _MeshCollisionData {
  90007. _checkCollisions: boolean;
  90008. _collisionMask: number;
  90009. _collisionGroup: number;
  90010. _collider: Nullable<Collider>;
  90011. _oldPositionForCollisions: Vector3;
  90012. _diffPositionForCollisions: Vector3;
  90013. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90014. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90015. }
  90016. }
  90017. declare module BABYLON {
  90018. /** @hidden */
  90019. class _FacetDataStorage {
  90020. facetPositions: Vector3[];
  90021. facetNormals: Vector3[];
  90022. facetPartitioning: number[][];
  90023. facetNb: number;
  90024. partitioningSubdivisions: number;
  90025. partitioningBBoxRatio: number;
  90026. facetDataEnabled: boolean;
  90027. facetParameters: any;
  90028. bbSize: Vector3;
  90029. subDiv: {
  90030. max: number;
  90031. X: number;
  90032. Y: number;
  90033. Z: number;
  90034. };
  90035. facetDepthSort: boolean;
  90036. facetDepthSortEnabled: boolean;
  90037. depthSortedIndices: IndicesArray;
  90038. depthSortedFacets: {
  90039. ind: number;
  90040. sqDistance: number;
  90041. }[];
  90042. facetDepthSortFunction: (f1: {
  90043. ind: number;
  90044. sqDistance: number;
  90045. }, f2: {
  90046. ind: number;
  90047. sqDistance: number;
  90048. }) => number;
  90049. facetDepthSortFrom: Vector3;
  90050. facetDepthSortOrigin: Vector3;
  90051. invertedMatrix: Matrix;
  90052. }
  90053. /**
  90054. * @hidden
  90055. **/
  90056. class _InternalAbstractMeshDataInfo {
  90057. _hasVertexAlpha: boolean;
  90058. _useVertexColors: boolean;
  90059. _numBoneInfluencers: number;
  90060. _applyFog: boolean;
  90061. _receiveShadows: boolean;
  90062. _facetData: _FacetDataStorage;
  90063. _visibility: number;
  90064. _skeleton: Nullable<Skeleton>;
  90065. _layerMask: number;
  90066. _computeBonesUsingShaders: boolean;
  90067. _isActive: boolean;
  90068. _onlyForInstances: boolean;
  90069. _isActiveIntermediate: boolean;
  90070. _onlyForInstancesIntermediate: boolean;
  90071. }
  90072. /**
  90073. * Class used to store all common mesh properties
  90074. */
  90075. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90076. /** No occlusion */
  90077. static OCCLUSION_TYPE_NONE: number;
  90078. /** Occlusion set to optimisitic */
  90079. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90080. /** Occlusion set to strict */
  90081. static OCCLUSION_TYPE_STRICT: number;
  90082. /** Use an accurante occlusion algorithm */
  90083. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90084. /** Use a conservative occlusion algorithm */
  90085. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90086. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90087. * Test order :
  90088. * Is the bounding sphere outside the frustum ?
  90089. * If not, are the bounding box vertices outside the frustum ?
  90090. * It not, then the cullable object is in the frustum.
  90091. */
  90092. static readonly CULLINGSTRATEGY_STANDARD: number;
  90093. /** Culling strategy : Bounding Sphere Only.
  90094. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90095. * It's also less accurate than the standard because some not visible objects can still be selected.
  90096. * Test : is the bounding sphere outside the frustum ?
  90097. * If not, then the cullable object is in the frustum.
  90098. */
  90099. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90100. /** Culling strategy : Optimistic Inclusion.
  90101. * This in an inclusion test first, then the standard exclusion test.
  90102. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90103. * 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.
  90104. * Anyway, it's as accurate as the standard strategy.
  90105. * Test :
  90106. * Is the cullable object bounding sphere center in the frustum ?
  90107. * If not, apply the default culling strategy.
  90108. */
  90109. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90110. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90111. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90112. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90113. * 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.
  90114. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90115. * Test :
  90116. * Is the cullable object bounding sphere center in the frustum ?
  90117. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90118. */
  90119. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90120. /**
  90121. * No billboard
  90122. */
  90123. static readonly BILLBOARDMODE_NONE: number;
  90124. /** Billboard on X axis */
  90125. static readonly BILLBOARDMODE_X: number;
  90126. /** Billboard on Y axis */
  90127. static readonly BILLBOARDMODE_Y: number;
  90128. /** Billboard on Z axis */
  90129. static readonly BILLBOARDMODE_Z: number;
  90130. /** Billboard on all axes */
  90131. static readonly BILLBOARDMODE_ALL: number;
  90132. /** Billboard on using position instead of orientation */
  90133. static readonly BILLBOARDMODE_USE_POSITION: number;
  90134. /** @hidden */
  90135. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90136. /**
  90137. * The culling strategy to use to check whether the mesh must be rendered or not.
  90138. * This value can be changed at any time and will be used on the next render mesh selection.
  90139. * The possible values are :
  90140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90144. * Please read each static variable documentation to get details about the culling process.
  90145. * */
  90146. cullingStrategy: number;
  90147. /**
  90148. * Gets the number of facets in the mesh
  90149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90150. */
  90151. readonly facetNb: number;
  90152. /**
  90153. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90155. */
  90156. partitioningSubdivisions: number;
  90157. /**
  90158. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90159. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90161. */
  90162. partitioningBBoxRatio: number;
  90163. /**
  90164. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90165. * Works only for updatable meshes.
  90166. * Doesn't work with multi-materials
  90167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90168. */
  90169. mustDepthSortFacets: boolean;
  90170. /**
  90171. * The location (Vector3) where the facet depth sort must be computed from.
  90172. * By default, the active camera position.
  90173. * Used only when facet depth sort is enabled
  90174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90175. */
  90176. facetDepthSortFrom: Vector3;
  90177. /**
  90178. * gets a boolean indicating if facetData is enabled
  90179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90180. */
  90181. readonly isFacetDataEnabled: boolean;
  90182. /** @hidden */
  90183. _updateNonUniformScalingState(value: boolean): boolean;
  90184. /**
  90185. * An event triggered when this mesh collides with another one
  90186. */
  90187. onCollideObservable: Observable<AbstractMesh>;
  90188. /** Set a function to call when this mesh collides with another one */
  90189. onCollide: () => void;
  90190. /**
  90191. * An event triggered when the collision's position changes
  90192. */
  90193. onCollisionPositionChangeObservable: Observable<Vector3>;
  90194. /** Set a function to call when the collision's position changes */
  90195. onCollisionPositionChange: () => void;
  90196. /**
  90197. * An event triggered when material is changed
  90198. */
  90199. onMaterialChangedObservable: Observable<AbstractMesh>;
  90200. /**
  90201. * Gets or sets the orientation for POV movement & rotation
  90202. */
  90203. definedFacingForward: boolean;
  90204. /** @hidden */
  90205. _occlusionQuery: Nullable<WebGLQuery>;
  90206. /** @hidden */
  90207. _renderingGroup: Nullable<RenderingGroup>;
  90208. /**
  90209. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90210. */
  90211. /**
  90212. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90213. */
  90214. visibility: number;
  90215. /** Gets or sets the alpha index used to sort transparent meshes
  90216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90217. */
  90218. alphaIndex: number;
  90219. /**
  90220. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90221. */
  90222. isVisible: boolean;
  90223. /**
  90224. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90225. */
  90226. isPickable: boolean;
  90227. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90228. showSubMeshesBoundingBox: boolean;
  90229. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90231. */
  90232. isBlocker: boolean;
  90233. /**
  90234. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90235. */
  90236. enablePointerMoveEvents: boolean;
  90237. /**
  90238. * Specifies the rendering group id for this mesh (0 by default)
  90239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90240. */
  90241. renderingGroupId: number;
  90242. private _material;
  90243. /** Gets or sets current material */
  90244. material: Nullable<Material>;
  90245. /**
  90246. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90247. * @see http://doc.babylonjs.com/babylon101/shadows
  90248. */
  90249. receiveShadows: boolean;
  90250. /** Defines color to use when rendering outline */
  90251. outlineColor: Color3;
  90252. /** Define width to use when rendering outline */
  90253. outlineWidth: number;
  90254. /** Defines color to use when rendering overlay */
  90255. overlayColor: Color3;
  90256. /** Defines alpha to use when rendering overlay */
  90257. overlayAlpha: number;
  90258. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90259. hasVertexAlpha: boolean;
  90260. /** 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) */
  90261. useVertexColors: boolean;
  90262. /**
  90263. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90264. */
  90265. computeBonesUsingShaders: boolean;
  90266. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90267. numBoneInfluencers: number;
  90268. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90269. applyFog: boolean;
  90270. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90271. useOctreeForRenderingSelection: boolean;
  90272. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90273. useOctreeForPicking: boolean;
  90274. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90275. useOctreeForCollisions: boolean;
  90276. /**
  90277. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90278. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90279. */
  90280. layerMask: number;
  90281. /**
  90282. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90283. */
  90284. alwaysSelectAsActiveMesh: boolean;
  90285. /**
  90286. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90287. */
  90288. doNotSyncBoundingInfo: boolean;
  90289. /**
  90290. * Gets or sets the current action manager
  90291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90292. */
  90293. actionManager: Nullable<AbstractActionManager>;
  90294. private _meshCollisionData;
  90295. /**
  90296. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90297. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90298. */
  90299. ellipsoid: Vector3;
  90300. /**
  90301. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90302. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90303. */
  90304. ellipsoidOffset: Vector3;
  90305. /**
  90306. * Gets or sets a collision mask used to mask collisions (default is -1).
  90307. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90308. */
  90309. collisionMask: number;
  90310. /**
  90311. * Gets or sets the current collision group mask (-1 by default).
  90312. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90313. */
  90314. collisionGroup: number;
  90315. /**
  90316. * Defines edge width used when edgesRenderer is enabled
  90317. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90318. */
  90319. edgesWidth: number;
  90320. /**
  90321. * Defines edge color used when edgesRenderer is enabled
  90322. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90323. */
  90324. edgesColor: Color4;
  90325. /** @hidden */
  90326. _edgesRenderer: Nullable<IEdgesRenderer>;
  90327. /** @hidden */
  90328. _masterMesh: Nullable<AbstractMesh>;
  90329. /** @hidden */
  90330. _boundingInfo: Nullable<BoundingInfo>;
  90331. /** @hidden */
  90332. _renderId: number;
  90333. /**
  90334. * Gets or sets the list of subMeshes
  90335. * @see http://doc.babylonjs.com/how_to/multi_materials
  90336. */
  90337. subMeshes: SubMesh[];
  90338. /** @hidden */
  90339. _intersectionsInProgress: AbstractMesh[];
  90340. /** @hidden */
  90341. _unIndexed: boolean;
  90342. /** @hidden */
  90343. _lightSources: Light[];
  90344. /** Gets the list of lights affecting that mesh */
  90345. readonly lightSources: Light[];
  90346. /** @hidden */
  90347. readonly _positions: Nullable<Vector3[]>;
  90348. /** @hidden */
  90349. _waitingData: {
  90350. lods: Nullable<any>;
  90351. actions: Nullable<any>;
  90352. freezeWorldMatrix: Nullable<boolean>;
  90353. };
  90354. /** @hidden */
  90355. _bonesTransformMatrices: Nullable<Float32Array>;
  90356. /** @hidden */
  90357. _transformMatrixTexture: Nullable<RawTexture>;
  90358. /**
  90359. * Gets or sets a skeleton to apply skining transformations
  90360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90361. */
  90362. skeleton: Nullable<Skeleton>;
  90363. /**
  90364. * An event triggered when the mesh is rebuilt.
  90365. */
  90366. onRebuildObservable: Observable<AbstractMesh>;
  90367. /**
  90368. * Creates a new AbstractMesh
  90369. * @param name defines the name of the mesh
  90370. * @param scene defines the hosting scene
  90371. */
  90372. constructor(name: string, scene?: Nullable<Scene>);
  90373. /**
  90374. * Returns the string "AbstractMesh"
  90375. * @returns "AbstractMesh"
  90376. */
  90377. getClassName(): string;
  90378. /**
  90379. * Gets a string representation of the current mesh
  90380. * @param fullDetails defines a boolean indicating if full details must be included
  90381. * @returns a string representation of the current mesh
  90382. */
  90383. toString(fullDetails?: boolean): string;
  90384. /**
  90385. * @hidden
  90386. */
  90387. protected _getEffectiveParent(): Nullable<Node>;
  90388. /** @hidden */
  90389. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90390. /** @hidden */
  90391. _rebuild(): void;
  90392. /** @hidden */
  90393. _resyncLightSources(): void;
  90394. /** @hidden */
  90395. _resyncLighSource(light: Light): void;
  90396. /** @hidden */
  90397. _unBindEffect(): void;
  90398. /** @hidden */
  90399. _removeLightSource(light: Light): void;
  90400. private _markSubMeshesAsDirty;
  90401. /** @hidden */
  90402. _markSubMeshesAsLightDirty(): void;
  90403. /** @hidden */
  90404. _markSubMeshesAsAttributesDirty(): void;
  90405. /** @hidden */
  90406. _markSubMeshesAsMiscDirty(): void;
  90407. /**
  90408. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90409. */
  90410. scaling: Vector3;
  90411. /**
  90412. * Returns true if the mesh is blocked. Implemented by child classes
  90413. */
  90414. readonly isBlocked: boolean;
  90415. /**
  90416. * Returns the mesh itself by default. Implemented by child classes
  90417. * @param camera defines the camera to use to pick the right LOD level
  90418. * @returns the currentAbstractMesh
  90419. */
  90420. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90421. /**
  90422. * Returns 0 by default. Implemented by child classes
  90423. * @returns an integer
  90424. */
  90425. getTotalVertices(): number;
  90426. /**
  90427. * Returns a positive integer : the total number of indices in this mesh geometry.
  90428. * @returns the numner of indices or zero if the mesh has no geometry.
  90429. */
  90430. getTotalIndices(): number;
  90431. /**
  90432. * Returns null by default. Implemented by child classes
  90433. * @returns null
  90434. */
  90435. getIndices(): Nullable<IndicesArray>;
  90436. /**
  90437. * Returns the array of the requested vertex data kind. Implemented by child classes
  90438. * @param kind defines the vertex data kind to use
  90439. * @returns null
  90440. */
  90441. getVerticesData(kind: string): Nullable<FloatArray>;
  90442. /**
  90443. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90444. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90445. * Note that a new underlying VertexBuffer object is created each call.
  90446. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90447. * @param kind defines vertex data kind:
  90448. * * VertexBuffer.PositionKind
  90449. * * VertexBuffer.UVKind
  90450. * * VertexBuffer.UV2Kind
  90451. * * VertexBuffer.UV3Kind
  90452. * * VertexBuffer.UV4Kind
  90453. * * VertexBuffer.UV5Kind
  90454. * * VertexBuffer.UV6Kind
  90455. * * VertexBuffer.ColorKind
  90456. * * VertexBuffer.MatricesIndicesKind
  90457. * * VertexBuffer.MatricesIndicesExtraKind
  90458. * * VertexBuffer.MatricesWeightsKind
  90459. * * VertexBuffer.MatricesWeightsExtraKind
  90460. * @param data defines the data source
  90461. * @param updatable defines if the data must be flagged as updatable (or static)
  90462. * @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
  90463. * @returns the current mesh
  90464. */
  90465. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90466. /**
  90467. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90468. * If the mesh has no geometry, it is simply returned as it is.
  90469. * @param kind defines vertex data kind:
  90470. * * VertexBuffer.PositionKind
  90471. * * VertexBuffer.UVKind
  90472. * * VertexBuffer.UV2Kind
  90473. * * VertexBuffer.UV3Kind
  90474. * * VertexBuffer.UV4Kind
  90475. * * VertexBuffer.UV5Kind
  90476. * * VertexBuffer.UV6Kind
  90477. * * VertexBuffer.ColorKind
  90478. * * VertexBuffer.MatricesIndicesKind
  90479. * * VertexBuffer.MatricesIndicesExtraKind
  90480. * * VertexBuffer.MatricesWeightsKind
  90481. * * VertexBuffer.MatricesWeightsExtraKind
  90482. * @param data defines the data source
  90483. * @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
  90484. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90485. * @returns the current mesh
  90486. */
  90487. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90488. /**
  90489. * Sets the mesh indices,
  90490. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90491. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90492. * @param totalVertices Defines the total number of vertices
  90493. * @returns the current mesh
  90494. */
  90495. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90496. /**
  90497. * Gets a boolean indicating if specific vertex data is present
  90498. * @param kind defines the vertex data kind to use
  90499. * @returns true is data kind is present
  90500. */
  90501. isVerticesDataPresent(kind: string): boolean;
  90502. /**
  90503. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90504. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90505. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90506. * @returns a BoundingInfo
  90507. */
  90508. getBoundingInfo(): BoundingInfo;
  90509. /**
  90510. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90511. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90512. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90513. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90514. * @returns the current mesh
  90515. */
  90516. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90517. /**
  90518. * Overwrite the current bounding info
  90519. * @param boundingInfo defines the new bounding info
  90520. * @returns the current mesh
  90521. */
  90522. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90523. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90524. readonly useBones: boolean;
  90525. /** @hidden */
  90526. _preActivate(): void;
  90527. /** @hidden */
  90528. _preActivateForIntermediateRendering(renderId: number): void;
  90529. /** @hidden */
  90530. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90531. /** @hidden */
  90532. _postActivate(): void;
  90533. /** @hidden */
  90534. _freeze(): void;
  90535. /** @hidden */
  90536. _unFreeze(): void;
  90537. /**
  90538. * Gets the current world matrix
  90539. * @returns a Matrix
  90540. */
  90541. getWorldMatrix(): Matrix;
  90542. /** @hidden */
  90543. _getWorldMatrixDeterminant(): number;
  90544. /**
  90545. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90546. */
  90547. readonly isAnInstance: boolean;
  90548. /**
  90549. * Perform relative position change from the point of view of behind the front of the mesh.
  90550. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90551. * Supports definition of mesh facing forward or backward
  90552. * @param amountRight defines the distance on the right axis
  90553. * @param amountUp defines the distance on the up axis
  90554. * @param amountForward defines the distance on the forward axis
  90555. * @returns the current mesh
  90556. */
  90557. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90558. /**
  90559. * Calculate relative position change from the point of view of behind the front of the mesh.
  90560. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90561. * Supports definition of mesh facing forward or backward
  90562. * @param amountRight defines the distance on the right axis
  90563. * @param amountUp defines the distance on the up axis
  90564. * @param amountForward defines the distance on the forward axis
  90565. * @returns the new displacement vector
  90566. */
  90567. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90568. /**
  90569. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90570. * Supports definition of mesh facing forward or backward
  90571. * @param flipBack defines the flip
  90572. * @param twirlClockwise defines the twirl
  90573. * @param tiltRight defines the tilt
  90574. * @returns the current mesh
  90575. */
  90576. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90577. /**
  90578. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90579. * Supports definition of mesh facing forward or backward.
  90580. * @param flipBack defines the flip
  90581. * @param twirlClockwise defines the twirl
  90582. * @param tiltRight defines the tilt
  90583. * @returns the new rotation vector
  90584. */
  90585. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90586. /**
  90587. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90588. * This means the mesh underlying bounding box and sphere are recomputed.
  90589. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90590. * @returns the current mesh
  90591. */
  90592. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90593. /** @hidden */
  90594. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90595. /** @hidden */
  90596. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90597. /** @hidden */
  90598. _updateBoundingInfo(): AbstractMesh;
  90599. /** @hidden */
  90600. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90601. /** @hidden */
  90602. protected _afterComputeWorldMatrix(): void;
  90603. /** @hidden */
  90604. readonly _effectiveMesh: AbstractMesh;
  90605. /**
  90606. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90607. * A mesh is in the frustum if its bounding box intersects the frustum
  90608. * @param frustumPlanes defines the frustum to test
  90609. * @returns true if the mesh is in the frustum planes
  90610. */
  90611. isInFrustum(frustumPlanes: Plane[]): boolean;
  90612. /**
  90613. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90614. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90615. * @param frustumPlanes defines the frustum to test
  90616. * @returns true if the mesh is completely in the frustum planes
  90617. */
  90618. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90619. /**
  90620. * True if the mesh intersects another mesh or a SolidParticle object
  90621. * @param mesh defines a target mesh or SolidParticle to test
  90622. * @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)
  90623. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90624. * @returns true if there is an intersection
  90625. */
  90626. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90627. /**
  90628. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90629. * @param point defines the point to test
  90630. * @returns true if there is an intersection
  90631. */
  90632. intersectsPoint(point: Vector3): boolean;
  90633. /**
  90634. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90636. */
  90637. checkCollisions: boolean;
  90638. /**
  90639. * Gets Collider object used to compute collisions (not physics)
  90640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90641. */
  90642. readonly collider: Nullable<Collider>;
  90643. /**
  90644. * Move the mesh using collision engine
  90645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90646. * @param displacement defines the requested displacement vector
  90647. * @returns the current mesh
  90648. */
  90649. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90650. private _onCollisionPositionChange;
  90651. /** @hidden */
  90652. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90653. /** @hidden */
  90654. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90655. /** @hidden */
  90656. _checkCollision(collider: Collider): AbstractMesh;
  90657. /** @hidden */
  90658. _generatePointsArray(): boolean;
  90659. /**
  90660. * Checks if the passed Ray intersects with the mesh
  90661. * @param ray defines the ray to use
  90662. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90664. * @returns the picking info
  90665. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90666. */
  90667. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90668. /**
  90669. * Clones the current mesh
  90670. * @param name defines the mesh name
  90671. * @param newParent defines the new mesh parent
  90672. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90673. * @returns the new mesh
  90674. */
  90675. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90676. /**
  90677. * Disposes all the submeshes of the current meshnp
  90678. * @returns the current mesh
  90679. */
  90680. releaseSubMeshes(): AbstractMesh;
  90681. /**
  90682. * Releases resources associated with this abstract mesh.
  90683. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90684. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90685. */
  90686. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90687. /**
  90688. * Adds the passed mesh as a child to the current mesh
  90689. * @param mesh defines the child mesh
  90690. * @returns the current mesh
  90691. */
  90692. addChild(mesh: AbstractMesh): AbstractMesh;
  90693. /**
  90694. * Removes the passed mesh from the current mesh children list
  90695. * @param mesh defines the child mesh
  90696. * @returns the current mesh
  90697. */
  90698. removeChild(mesh: AbstractMesh): AbstractMesh;
  90699. /** @hidden */
  90700. private _initFacetData;
  90701. /**
  90702. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90703. * This method can be called within the render loop.
  90704. * 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
  90705. * @returns the current mesh
  90706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90707. */
  90708. updateFacetData(): AbstractMesh;
  90709. /**
  90710. * Returns the facetLocalNormals array.
  90711. * The normals are expressed in the mesh local spac
  90712. * @returns an array of Vector3
  90713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90714. */
  90715. getFacetLocalNormals(): Vector3[];
  90716. /**
  90717. * Returns the facetLocalPositions array.
  90718. * The facet positions are expressed in the mesh local space
  90719. * @returns an array of Vector3
  90720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90721. */
  90722. getFacetLocalPositions(): Vector3[];
  90723. /**
  90724. * Returns the facetLocalPartioning array
  90725. * @returns an array of array of numbers
  90726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90727. */
  90728. getFacetLocalPartitioning(): number[][];
  90729. /**
  90730. * Returns the i-th facet position in the world system.
  90731. * This method allocates a new Vector3 per call
  90732. * @param i defines the facet index
  90733. * @returns a new Vector3
  90734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90735. */
  90736. getFacetPosition(i: number): Vector3;
  90737. /**
  90738. * Sets the reference Vector3 with the i-th facet position in the world system
  90739. * @param i defines the facet index
  90740. * @param ref defines the target vector
  90741. * @returns the current mesh
  90742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90743. */
  90744. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90745. /**
  90746. * Returns the i-th facet normal in the world system.
  90747. * This method allocates a new Vector3 per call
  90748. * @param i defines the facet index
  90749. * @returns a new Vector3
  90750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90751. */
  90752. getFacetNormal(i: number): Vector3;
  90753. /**
  90754. * Sets the reference Vector3 with the i-th facet normal in the world system
  90755. * @param i defines the facet index
  90756. * @param ref defines the target vector
  90757. * @returns the current mesh
  90758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90759. */
  90760. getFacetNormalToRef(i: number, ref: Vector3): this;
  90761. /**
  90762. * 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)
  90763. * @param x defines x coordinate
  90764. * @param y defines y coordinate
  90765. * @param z defines z coordinate
  90766. * @returns the array of facet indexes
  90767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90768. */
  90769. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90770. /**
  90771. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90772. * @param projected sets as the (x,y,z) world projection on the facet
  90773. * @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
  90774. * @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
  90775. * @param x defines x coordinate
  90776. * @param y defines y coordinate
  90777. * @param z defines z coordinate
  90778. * @returns the face index if found (or null instead)
  90779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90780. */
  90781. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90782. /**
  90783. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90784. * @param projected sets as the (x,y,z) local projection on the facet
  90785. * @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
  90786. * @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
  90787. * @param x defines x coordinate
  90788. * @param y defines y coordinate
  90789. * @param z defines z coordinate
  90790. * @returns the face index if found (or null instead)
  90791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90792. */
  90793. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90794. /**
  90795. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90796. * @returns the parameters
  90797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90798. */
  90799. getFacetDataParameters(): any;
  90800. /**
  90801. * Disables the feature FacetData and frees the related memory
  90802. * @returns the current mesh
  90803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90804. */
  90805. disableFacetData(): AbstractMesh;
  90806. /**
  90807. * Updates the AbstractMesh indices array
  90808. * @param indices defines the data source
  90809. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90810. * @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)
  90811. * @returns the current mesh
  90812. */
  90813. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90814. /**
  90815. * Creates new normals data for the mesh
  90816. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90817. * @returns the current mesh
  90818. */
  90819. createNormals(updatable: boolean): AbstractMesh;
  90820. /**
  90821. * Align the mesh with a normal
  90822. * @param normal defines the normal to use
  90823. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90824. * @returns the current mesh
  90825. */
  90826. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90827. /** @hidden */
  90828. _checkOcclusionQuery(): boolean;
  90829. /**
  90830. * Disables the mesh edge rendering mode
  90831. * @returns the currentAbstractMesh
  90832. */
  90833. disableEdgesRendering(): AbstractMesh;
  90834. /**
  90835. * Enables the edge rendering mode on the mesh.
  90836. * This mode makes the mesh edges visible
  90837. * @param epsilon defines the maximal distance between two angles to detect a face
  90838. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90839. * @returns the currentAbstractMesh
  90840. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90841. */
  90842. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90843. }
  90844. }
  90845. declare module BABYLON {
  90846. /**
  90847. * Interface used to define ActionEvent
  90848. */
  90849. export interface IActionEvent {
  90850. /** The mesh or sprite that triggered the action */
  90851. source: any;
  90852. /** The X mouse cursor position at the time of the event */
  90853. pointerX: number;
  90854. /** The Y mouse cursor position at the time of the event */
  90855. pointerY: number;
  90856. /** The mesh that is currently pointed at (can be null) */
  90857. meshUnderPointer: Nullable<AbstractMesh>;
  90858. /** the original (browser) event that triggered the ActionEvent */
  90859. sourceEvent?: any;
  90860. /** additional data for the event */
  90861. additionalData?: any;
  90862. }
  90863. /**
  90864. * ActionEvent is the event being sent when an action is triggered.
  90865. */
  90866. export class ActionEvent implements IActionEvent {
  90867. /** The mesh or sprite that triggered the action */
  90868. source: any;
  90869. /** The X mouse cursor position at the time of the event */
  90870. pointerX: number;
  90871. /** The Y mouse cursor position at the time of the event */
  90872. pointerY: number;
  90873. /** The mesh that is currently pointed at (can be null) */
  90874. meshUnderPointer: Nullable<AbstractMesh>;
  90875. /** the original (browser) event that triggered the ActionEvent */
  90876. sourceEvent?: any;
  90877. /** additional data for the event */
  90878. additionalData?: any;
  90879. /**
  90880. * Creates a new ActionEvent
  90881. * @param source The mesh or sprite that triggered the action
  90882. * @param pointerX The X mouse cursor position at the time of the event
  90883. * @param pointerY The Y mouse cursor position at the time of the event
  90884. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90885. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90886. * @param additionalData additional data for the event
  90887. */
  90888. constructor(
  90889. /** The mesh or sprite that triggered the action */
  90890. source: any,
  90891. /** The X mouse cursor position at the time of the event */
  90892. pointerX: number,
  90893. /** The Y mouse cursor position at the time of the event */
  90894. pointerY: number,
  90895. /** The mesh that is currently pointed at (can be null) */
  90896. meshUnderPointer: Nullable<AbstractMesh>,
  90897. /** the original (browser) event that triggered the ActionEvent */
  90898. sourceEvent?: any,
  90899. /** additional data for the event */
  90900. additionalData?: any);
  90901. /**
  90902. * Helper function to auto-create an ActionEvent from a source mesh.
  90903. * @param source The source mesh that triggered the event
  90904. * @param evt The original (browser) event
  90905. * @param additionalData additional data for the event
  90906. * @returns the new ActionEvent
  90907. */
  90908. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90909. /**
  90910. * Helper function to auto-create an ActionEvent from a source sprite
  90911. * @param source The source sprite that triggered the event
  90912. * @param scene Scene associated with the sprite
  90913. * @param evt The original (browser) event
  90914. * @param additionalData additional data for the event
  90915. * @returns the new ActionEvent
  90916. */
  90917. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90918. /**
  90919. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90920. * @param scene the scene where the event occurred
  90921. * @param evt The original (browser) event
  90922. * @returns the new ActionEvent
  90923. */
  90924. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90925. /**
  90926. * Helper function to auto-create an ActionEvent from a primitive
  90927. * @param prim defines the target primitive
  90928. * @param pointerPos defines the pointer position
  90929. * @param evt The original (browser) event
  90930. * @param additionalData additional data for the event
  90931. * @returns the new ActionEvent
  90932. */
  90933. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90934. }
  90935. }
  90936. declare module BABYLON {
  90937. /**
  90938. * Abstract class used to decouple action Manager from scene and meshes.
  90939. * Do not instantiate.
  90940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90941. */
  90942. export abstract class AbstractActionManager implements IDisposable {
  90943. /** Gets the list of active triggers */
  90944. static Triggers: {
  90945. [key: string]: number;
  90946. };
  90947. /** Gets the cursor to use when hovering items */
  90948. hoverCursor: string;
  90949. /** Gets the list of actions */
  90950. actions: IAction[];
  90951. /**
  90952. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90953. */
  90954. isRecursive: boolean;
  90955. /**
  90956. * Releases all associated resources
  90957. */
  90958. abstract dispose(): void;
  90959. /**
  90960. * Does this action manager has pointer triggers
  90961. */
  90962. abstract readonly hasPointerTriggers: boolean;
  90963. /**
  90964. * Does this action manager has pick triggers
  90965. */
  90966. abstract readonly hasPickTriggers: boolean;
  90967. /**
  90968. * Process a specific trigger
  90969. * @param trigger defines the trigger to process
  90970. * @param evt defines the event details to be processed
  90971. */
  90972. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90973. /**
  90974. * Does this action manager handles actions of any of the given triggers
  90975. * @param triggers defines the triggers to be tested
  90976. * @return a boolean indicating whether one (or more) of the triggers is handled
  90977. */
  90978. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90979. /**
  90980. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90981. * speed.
  90982. * @param triggerA defines the trigger to be tested
  90983. * @param triggerB defines the trigger to be tested
  90984. * @return a boolean indicating whether one (or more) of the triggers is handled
  90985. */
  90986. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90987. /**
  90988. * Does this action manager handles actions of a given trigger
  90989. * @param trigger defines the trigger to be tested
  90990. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90991. * @return whether the trigger is handled
  90992. */
  90993. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90994. /**
  90995. * Serialize this manager to a JSON object
  90996. * @param name defines the property name to store this manager
  90997. * @returns a JSON representation of this manager
  90998. */
  90999. abstract serialize(name: string): any;
  91000. /**
  91001. * Registers an action to this action manager
  91002. * @param action defines the action to be registered
  91003. * @return the action amended (prepared) after registration
  91004. */
  91005. abstract registerAction(action: IAction): Nullable<IAction>;
  91006. /**
  91007. * Unregisters an action to this action manager
  91008. * @param action defines the action to be unregistered
  91009. * @return a boolean indicating whether the action has been unregistered
  91010. */
  91011. abstract unregisterAction(action: IAction): Boolean;
  91012. /**
  91013. * Does exist one action manager with at least one trigger
  91014. **/
  91015. static readonly HasTriggers: boolean;
  91016. /**
  91017. * Does exist one action manager with at least one pick trigger
  91018. **/
  91019. static readonly HasPickTriggers: boolean;
  91020. /**
  91021. * Does exist one action manager that handles actions of a given trigger
  91022. * @param trigger defines the trigger to be tested
  91023. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91024. **/
  91025. static HasSpecificTrigger(trigger: number): boolean;
  91026. }
  91027. }
  91028. declare module BABYLON {
  91029. /**
  91030. * Defines how a node can be built from a string name.
  91031. */
  91032. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91033. /**
  91034. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91035. */
  91036. export class Node implements IBehaviorAware<Node> {
  91037. /** @hidden */
  91038. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91039. private static _NodeConstructors;
  91040. /**
  91041. * Add a new node constructor
  91042. * @param type defines the type name of the node to construct
  91043. * @param constructorFunc defines the constructor function
  91044. */
  91045. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91046. /**
  91047. * Returns a node constructor based on type name
  91048. * @param type defines the type name
  91049. * @param name defines the new node name
  91050. * @param scene defines the hosting scene
  91051. * @param options defines optional options to transmit to constructors
  91052. * @returns the new constructor or null
  91053. */
  91054. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91055. /**
  91056. * Gets or sets the name of the node
  91057. */
  91058. name: string;
  91059. /**
  91060. * Gets or sets the id of the node
  91061. */
  91062. id: string;
  91063. /**
  91064. * Gets or sets the unique id of the node
  91065. */
  91066. uniqueId: number;
  91067. /**
  91068. * Gets or sets a string used to store user defined state for the node
  91069. */
  91070. state: string;
  91071. /**
  91072. * Gets or sets an object used to store user defined information for the node
  91073. */
  91074. metadata: any;
  91075. /**
  91076. * For internal use only. Please do not use.
  91077. */
  91078. reservedDataStore: any;
  91079. /**
  91080. * List of inspectable custom properties (used by the Inspector)
  91081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91082. */
  91083. inspectableCustomProperties: IInspectable[];
  91084. /**
  91085. * Gets or sets a boolean used to define if the node must be serialized
  91086. */
  91087. doNotSerialize: boolean;
  91088. /** @hidden */
  91089. _isDisposed: boolean;
  91090. /**
  91091. * Gets a list of Animations associated with the node
  91092. */
  91093. animations: Animation[];
  91094. protected _ranges: {
  91095. [name: string]: Nullable<AnimationRange>;
  91096. };
  91097. /**
  91098. * Callback raised when the node is ready to be used
  91099. */
  91100. onReady: Nullable<(node: Node) => void>;
  91101. private _isEnabled;
  91102. private _isParentEnabled;
  91103. private _isReady;
  91104. /** @hidden */
  91105. _currentRenderId: number;
  91106. private _parentUpdateId;
  91107. /** @hidden */
  91108. _childUpdateId: number;
  91109. /** @hidden */
  91110. _waitingParentId: Nullable<string>;
  91111. /** @hidden */
  91112. _scene: Scene;
  91113. /** @hidden */
  91114. _cache: any;
  91115. private _parentNode;
  91116. private _children;
  91117. /** @hidden */
  91118. _worldMatrix: Matrix;
  91119. /** @hidden */
  91120. _worldMatrixDeterminant: number;
  91121. /** @hidden */
  91122. _worldMatrixDeterminantIsDirty: boolean;
  91123. /** @hidden */
  91124. private _sceneRootNodesIndex;
  91125. /**
  91126. * Gets a boolean indicating if the node has been disposed
  91127. * @returns true if the node was disposed
  91128. */
  91129. isDisposed(): boolean;
  91130. /**
  91131. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91132. * @see https://doc.babylonjs.com/how_to/parenting
  91133. */
  91134. parent: Nullable<Node>;
  91135. private addToSceneRootNodes;
  91136. private removeFromSceneRootNodes;
  91137. private _animationPropertiesOverride;
  91138. /**
  91139. * Gets or sets the animation properties override
  91140. */
  91141. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91142. /**
  91143. * Gets a string idenfifying the name of the class
  91144. * @returns "Node" string
  91145. */
  91146. getClassName(): string;
  91147. /** @hidden */
  91148. readonly _isNode: boolean;
  91149. /**
  91150. * An event triggered when the mesh is disposed
  91151. */
  91152. onDisposeObservable: Observable<Node>;
  91153. private _onDisposeObserver;
  91154. /**
  91155. * Sets a callback that will be raised when the node will be disposed
  91156. */
  91157. onDispose: () => void;
  91158. /**
  91159. * Creates a new Node
  91160. * @param name the name and id to be given to this node
  91161. * @param scene the scene this node will be added to
  91162. * @param addToRootNodes the node will be added to scene.rootNodes
  91163. */
  91164. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91165. /**
  91166. * Gets the scene of the node
  91167. * @returns a scene
  91168. */
  91169. getScene(): Scene;
  91170. /**
  91171. * Gets the engine of the node
  91172. * @returns a Engine
  91173. */
  91174. getEngine(): Engine;
  91175. private _behaviors;
  91176. /**
  91177. * Attach a behavior to the node
  91178. * @see http://doc.babylonjs.com/features/behaviour
  91179. * @param behavior defines the behavior to attach
  91180. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91181. * @returns the current Node
  91182. */
  91183. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91184. /**
  91185. * Remove an attached behavior
  91186. * @see http://doc.babylonjs.com/features/behaviour
  91187. * @param behavior defines the behavior to attach
  91188. * @returns the current Node
  91189. */
  91190. removeBehavior(behavior: Behavior<Node>): Node;
  91191. /**
  91192. * Gets the list of attached behaviors
  91193. * @see http://doc.babylonjs.com/features/behaviour
  91194. */
  91195. readonly behaviors: Behavior<Node>[];
  91196. /**
  91197. * Gets an attached behavior by name
  91198. * @param name defines the name of the behavior to look for
  91199. * @see http://doc.babylonjs.com/features/behaviour
  91200. * @returns null if behavior was not found else the requested behavior
  91201. */
  91202. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91203. /**
  91204. * Returns the latest update of the World matrix
  91205. * @returns a Matrix
  91206. */
  91207. getWorldMatrix(): Matrix;
  91208. /** @hidden */
  91209. _getWorldMatrixDeterminant(): number;
  91210. /**
  91211. * Returns directly the latest state of the mesh World matrix.
  91212. * A Matrix is returned.
  91213. */
  91214. readonly worldMatrixFromCache: Matrix;
  91215. /** @hidden */
  91216. _initCache(): void;
  91217. /** @hidden */
  91218. updateCache(force?: boolean): void;
  91219. /** @hidden */
  91220. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91221. /** @hidden */
  91222. _updateCache(ignoreParentClass?: boolean): void;
  91223. /** @hidden */
  91224. _isSynchronized(): boolean;
  91225. /** @hidden */
  91226. _markSyncedWithParent(): void;
  91227. /** @hidden */
  91228. isSynchronizedWithParent(): boolean;
  91229. /** @hidden */
  91230. isSynchronized(): boolean;
  91231. /**
  91232. * Is this node ready to be used/rendered
  91233. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91234. * @return true if the node is ready
  91235. */
  91236. isReady(completeCheck?: boolean): boolean;
  91237. /**
  91238. * Is this node enabled?
  91239. * 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
  91240. * @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
  91241. * @return whether this node (and its parent) is enabled
  91242. */
  91243. isEnabled(checkAncestors?: boolean): boolean;
  91244. /** @hidden */
  91245. protected _syncParentEnabledState(): void;
  91246. /**
  91247. * Set the enabled state of this node
  91248. * @param value defines the new enabled state
  91249. */
  91250. setEnabled(value: boolean): void;
  91251. /**
  91252. * Is this node a descendant of the given node?
  91253. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91254. * @param ancestor defines the parent node to inspect
  91255. * @returns a boolean indicating if this node is a descendant of the given node
  91256. */
  91257. isDescendantOf(ancestor: Node): boolean;
  91258. /** @hidden */
  91259. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91260. /**
  91261. * Will return all nodes that have this node as ascendant
  91262. * @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
  91263. * @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
  91264. * @return all children nodes of all types
  91265. */
  91266. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91267. /**
  91268. * Get all child-meshes of this node
  91269. * @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)
  91270. * @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
  91271. * @returns an array of AbstractMesh
  91272. */
  91273. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91274. /**
  91275. * Get all direct children of this node
  91276. * @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
  91277. * @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)
  91278. * @returns an array of Node
  91279. */
  91280. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91281. /** @hidden */
  91282. _setReady(state: boolean): void;
  91283. /**
  91284. * Get an animation by name
  91285. * @param name defines the name of the animation to look for
  91286. * @returns null if not found else the requested animation
  91287. */
  91288. getAnimationByName(name: string): Nullable<Animation>;
  91289. /**
  91290. * Creates an animation range for this node
  91291. * @param name defines the name of the range
  91292. * @param from defines the starting key
  91293. * @param to defines the end key
  91294. */
  91295. createAnimationRange(name: string, from: number, to: number): void;
  91296. /**
  91297. * Delete a specific animation range
  91298. * @param name defines the name of the range to delete
  91299. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91300. */
  91301. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91302. /**
  91303. * Get an animation range by name
  91304. * @param name defines the name of the animation range to look for
  91305. * @returns null if not found else the requested animation range
  91306. */
  91307. getAnimationRange(name: string): Nullable<AnimationRange>;
  91308. /**
  91309. * Gets the list of all animation ranges defined on this node
  91310. * @returns an array
  91311. */
  91312. getAnimationRanges(): Nullable<AnimationRange>[];
  91313. /**
  91314. * Will start the animation sequence
  91315. * @param name defines the range frames for animation sequence
  91316. * @param loop defines if the animation should loop (false by default)
  91317. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91318. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91319. * @returns the object created for this animation. If range does not exist, it will return null
  91320. */
  91321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91322. /**
  91323. * Serialize animation ranges into a JSON compatible object
  91324. * @returns serialization object
  91325. */
  91326. serializeAnimationRanges(): any;
  91327. /**
  91328. * Computes the world matrix of the node
  91329. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91330. * @returns the world matrix
  91331. */
  91332. computeWorldMatrix(force?: boolean): Matrix;
  91333. /**
  91334. * Releases resources associated with this node.
  91335. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91336. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91337. */
  91338. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91339. /**
  91340. * Parse animation range data from a serialization object and store them into a given node
  91341. * @param node defines where to store the animation ranges
  91342. * @param parsedNode defines the serialization object to read data from
  91343. * @param scene defines the hosting scene
  91344. */
  91345. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91346. /**
  91347. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91348. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91349. * @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
  91350. * @returns the new bounding vectors
  91351. */
  91352. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91353. min: Vector3;
  91354. max: Vector3;
  91355. };
  91356. }
  91357. }
  91358. declare module BABYLON {
  91359. /**
  91360. * @hidden
  91361. */
  91362. export class _IAnimationState {
  91363. key: number;
  91364. repeatCount: number;
  91365. workValue?: any;
  91366. loopMode?: number;
  91367. offsetValue?: any;
  91368. highLimitValue?: any;
  91369. }
  91370. /**
  91371. * Class used to store any kind of animation
  91372. */
  91373. export class Animation {
  91374. /**Name of the animation */
  91375. name: string;
  91376. /**Property to animate */
  91377. targetProperty: string;
  91378. /**The frames per second of the animation */
  91379. framePerSecond: number;
  91380. /**The data type of the animation */
  91381. dataType: number;
  91382. /**The loop mode of the animation */
  91383. loopMode?: number | undefined;
  91384. /**Specifies if blending should be enabled */
  91385. enableBlending?: boolean | undefined;
  91386. /**
  91387. * Use matrix interpolation instead of using direct key value when animating matrices
  91388. */
  91389. static AllowMatricesInterpolation: boolean;
  91390. /**
  91391. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91392. */
  91393. static AllowMatrixDecomposeForInterpolation: boolean;
  91394. /**
  91395. * Stores the key frames of the animation
  91396. */
  91397. private _keys;
  91398. /**
  91399. * Stores the easing function of the animation
  91400. */
  91401. private _easingFunction;
  91402. /**
  91403. * @hidden Internal use only
  91404. */
  91405. _runtimeAnimations: RuntimeAnimation[];
  91406. /**
  91407. * The set of event that will be linked to this animation
  91408. */
  91409. private _events;
  91410. /**
  91411. * Stores an array of target property paths
  91412. */
  91413. targetPropertyPath: string[];
  91414. /**
  91415. * Stores the blending speed of the animation
  91416. */
  91417. blendingSpeed: number;
  91418. /**
  91419. * Stores the animation ranges for the animation
  91420. */
  91421. private _ranges;
  91422. /**
  91423. * @hidden Internal use
  91424. */
  91425. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91426. /**
  91427. * Sets up an animation
  91428. * @param property The property to animate
  91429. * @param animationType The animation type to apply
  91430. * @param framePerSecond The frames per second of the animation
  91431. * @param easingFunction The easing function used in the animation
  91432. * @returns The created animation
  91433. */
  91434. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91435. /**
  91436. * Create and start an animation on a node
  91437. * @param name defines the name of the global animation that will be run on all nodes
  91438. * @param node defines the root node where the animation will take place
  91439. * @param targetProperty defines property to animate
  91440. * @param framePerSecond defines the number of frame per second yo use
  91441. * @param totalFrame defines the number of frames in total
  91442. * @param from defines the initial value
  91443. * @param to defines the final value
  91444. * @param loopMode defines which loop mode you want to use (off by default)
  91445. * @param easingFunction defines the easing function to use (linear by default)
  91446. * @param onAnimationEnd defines the callback to call when animation end
  91447. * @returns the animatable created for this animation
  91448. */
  91449. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91450. /**
  91451. * Create and start an animation on a node and its descendants
  91452. * @param name defines the name of the global animation that will be run on all nodes
  91453. * @param node defines the root node where the animation will take place
  91454. * @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
  91455. * @param targetProperty defines property to animate
  91456. * @param framePerSecond defines the number of frame per second to use
  91457. * @param totalFrame defines the number of frames in total
  91458. * @param from defines the initial value
  91459. * @param to defines the final value
  91460. * @param loopMode defines which loop mode you want to use (off by default)
  91461. * @param easingFunction defines the easing function to use (linear by default)
  91462. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91463. * @returns the list of animatables created for all nodes
  91464. * @example https://www.babylonjs-playground.com/#MH0VLI
  91465. */
  91466. 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[]>;
  91467. /**
  91468. * Creates a new animation, merges it with the existing animations and starts it
  91469. * @param name Name of the animation
  91470. * @param node Node which contains the scene that begins the animations
  91471. * @param targetProperty Specifies which property to animate
  91472. * @param framePerSecond The frames per second of the animation
  91473. * @param totalFrame The total number of frames
  91474. * @param from The frame at the beginning of the animation
  91475. * @param to The frame at the end of the animation
  91476. * @param loopMode Specifies the loop mode of the animation
  91477. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91478. * @param onAnimationEnd Callback to run once the animation is complete
  91479. * @returns Nullable animation
  91480. */
  91481. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91482. /**
  91483. * Transition property of an host to the target Value
  91484. * @param property The property to transition
  91485. * @param targetValue The target Value of the property
  91486. * @param host The object where the property to animate belongs
  91487. * @param scene Scene used to run the animation
  91488. * @param frameRate Framerate (in frame/s) to use
  91489. * @param transition The transition type we want to use
  91490. * @param duration The duration of the animation, in milliseconds
  91491. * @param onAnimationEnd Callback trigger at the end of the animation
  91492. * @returns Nullable animation
  91493. */
  91494. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91495. /**
  91496. * Return the array of runtime animations currently using this animation
  91497. */
  91498. readonly runtimeAnimations: RuntimeAnimation[];
  91499. /**
  91500. * Specifies if any of the runtime animations are currently running
  91501. */
  91502. readonly hasRunningRuntimeAnimations: boolean;
  91503. /**
  91504. * Initializes the animation
  91505. * @param name Name of the animation
  91506. * @param targetProperty Property to animate
  91507. * @param framePerSecond The frames per second of the animation
  91508. * @param dataType The data type of the animation
  91509. * @param loopMode The loop mode of the animation
  91510. * @param enableBlending Specifies if blending should be enabled
  91511. */
  91512. constructor(
  91513. /**Name of the animation */
  91514. name: string,
  91515. /**Property to animate */
  91516. targetProperty: string,
  91517. /**The frames per second of the animation */
  91518. framePerSecond: number,
  91519. /**The data type of the animation */
  91520. dataType: number,
  91521. /**The loop mode of the animation */
  91522. loopMode?: number | undefined,
  91523. /**Specifies if blending should be enabled */
  91524. enableBlending?: boolean | undefined);
  91525. /**
  91526. * Converts the animation to a string
  91527. * @param fullDetails support for multiple levels of logging within scene loading
  91528. * @returns String form of the animation
  91529. */
  91530. toString(fullDetails?: boolean): string;
  91531. /**
  91532. * Add an event to this animation
  91533. * @param event Event to add
  91534. */
  91535. addEvent(event: AnimationEvent): void;
  91536. /**
  91537. * Remove all events found at the given frame
  91538. * @param frame The frame to remove events from
  91539. */
  91540. removeEvents(frame: number): void;
  91541. /**
  91542. * Retrieves all the events from the animation
  91543. * @returns Events from the animation
  91544. */
  91545. getEvents(): AnimationEvent[];
  91546. /**
  91547. * Creates an animation range
  91548. * @param name Name of the animation range
  91549. * @param from Starting frame of the animation range
  91550. * @param to Ending frame of the animation
  91551. */
  91552. createRange(name: string, from: number, to: number): void;
  91553. /**
  91554. * Deletes an animation range by name
  91555. * @param name Name of the animation range to delete
  91556. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91557. */
  91558. deleteRange(name: string, deleteFrames?: boolean): void;
  91559. /**
  91560. * Gets the animation range by name, or null if not defined
  91561. * @param name Name of the animation range
  91562. * @returns Nullable animation range
  91563. */
  91564. getRange(name: string): Nullable<AnimationRange>;
  91565. /**
  91566. * Gets the key frames from the animation
  91567. * @returns The key frames of the animation
  91568. */
  91569. getKeys(): Array<IAnimationKey>;
  91570. /**
  91571. * Gets the highest frame rate of the animation
  91572. * @returns Highest frame rate of the animation
  91573. */
  91574. getHighestFrame(): number;
  91575. /**
  91576. * Gets the easing function of the animation
  91577. * @returns Easing function of the animation
  91578. */
  91579. getEasingFunction(): IEasingFunction;
  91580. /**
  91581. * Sets the easing function of the animation
  91582. * @param easingFunction A custom mathematical formula for animation
  91583. */
  91584. setEasingFunction(easingFunction: EasingFunction): void;
  91585. /**
  91586. * Interpolates a scalar linearly
  91587. * @param startValue Start value of the animation curve
  91588. * @param endValue End value of the animation curve
  91589. * @param gradient Scalar amount to interpolate
  91590. * @returns Interpolated scalar value
  91591. */
  91592. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91593. /**
  91594. * Interpolates a scalar cubically
  91595. * @param startValue Start value of the animation curve
  91596. * @param outTangent End tangent of the animation
  91597. * @param endValue End value of the animation curve
  91598. * @param inTangent Start tangent of the animation curve
  91599. * @param gradient Scalar amount to interpolate
  91600. * @returns Interpolated scalar value
  91601. */
  91602. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91603. /**
  91604. * Interpolates a quaternion using a spherical linear interpolation
  91605. * @param startValue Start value of the animation curve
  91606. * @param endValue End value of the animation curve
  91607. * @param gradient Scalar amount to interpolate
  91608. * @returns Interpolated quaternion value
  91609. */
  91610. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91611. /**
  91612. * Interpolates a quaternion cubically
  91613. * @param startValue Start value of the animation curve
  91614. * @param outTangent End tangent of the animation curve
  91615. * @param endValue End value of the animation curve
  91616. * @param inTangent Start tangent of the animation curve
  91617. * @param gradient Scalar amount to interpolate
  91618. * @returns Interpolated quaternion value
  91619. */
  91620. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91621. /**
  91622. * Interpolates a Vector3 linearl
  91623. * @param startValue Start value of the animation curve
  91624. * @param endValue End value of the animation curve
  91625. * @param gradient Scalar amount to interpolate
  91626. * @returns Interpolated scalar value
  91627. */
  91628. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91629. /**
  91630. * Interpolates a Vector3 cubically
  91631. * @param startValue Start value of the animation curve
  91632. * @param outTangent End tangent of the animation
  91633. * @param endValue End value of the animation curve
  91634. * @param inTangent Start tangent of the animation curve
  91635. * @param gradient Scalar amount to interpolate
  91636. * @returns InterpolatedVector3 value
  91637. */
  91638. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91639. /**
  91640. * Interpolates a Vector2 linearly
  91641. * @param startValue Start value of the animation curve
  91642. * @param endValue End value of the animation curve
  91643. * @param gradient Scalar amount to interpolate
  91644. * @returns Interpolated Vector2 value
  91645. */
  91646. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91647. /**
  91648. * Interpolates a Vector2 cubically
  91649. * @param startValue Start value of the animation curve
  91650. * @param outTangent End tangent of the animation
  91651. * @param endValue End value of the animation curve
  91652. * @param inTangent Start tangent of the animation curve
  91653. * @param gradient Scalar amount to interpolate
  91654. * @returns Interpolated Vector2 value
  91655. */
  91656. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91657. /**
  91658. * Interpolates a size linearly
  91659. * @param startValue Start value of the animation curve
  91660. * @param endValue End value of the animation curve
  91661. * @param gradient Scalar amount to interpolate
  91662. * @returns Interpolated Size value
  91663. */
  91664. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91665. /**
  91666. * Interpolates a Color3 linearly
  91667. * @param startValue Start value of the animation curve
  91668. * @param endValue End value of the animation curve
  91669. * @param gradient Scalar amount to interpolate
  91670. * @returns Interpolated Color3 value
  91671. */
  91672. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91673. /**
  91674. * @hidden Internal use only
  91675. */
  91676. _getKeyValue(value: any): any;
  91677. /**
  91678. * @hidden Internal use only
  91679. */
  91680. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91681. /**
  91682. * Defines the function to use to interpolate matrices
  91683. * @param startValue defines the start matrix
  91684. * @param endValue defines the end matrix
  91685. * @param gradient defines the gradient between both matrices
  91686. * @param result defines an optional target matrix where to store the interpolation
  91687. * @returns the interpolated matrix
  91688. */
  91689. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91690. /**
  91691. * Makes a copy of the animation
  91692. * @returns Cloned animation
  91693. */
  91694. clone(): Animation;
  91695. /**
  91696. * Sets the key frames of the animation
  91697. * @param values The animation key frames to set
  91698. */
  91699. setKeys(values: Array<IAnimationKey>): void;
  91700. /**
  91701. * Serializes the animation to an object
  91702. * @returns Serialized object
  91703. */
  91704. serialize(): any;
  91705. /**
  91706. * Float animation type
  91707. */
  91708. private static _ANIMATIONTYPE_FLOAT;
  91709. /**
  91710. * Vector3 animation type
  91711. */
  91712. private static _ANIMATIONTYPE_VECTOR3;
  91713. /**
  91714. * Quaternion animation type
  91715. */
  91716. private static _ANIMATIONTYPE_QUATERNION;
  91717. /**
  91718. * Matrix animation type
  91719. */
  91720. private static _ANIMATIONTYPE_MATRIX;
  91721. /**
  91722. * Color3 animation type
  91723. */
  91724. private static _ANIMATIONTYPE_COLOR3;
  91725. /**
  91726. * Vector2 animation type
  91727. */
  91728. private static _ANIMATIONTYPE_VECTOR2;
  91729. /**
  91730. * Size animation type
  91731. */
  91732. private static _ANIMATIONTYPE_SIZE;
  91733. /**
  91734. * Relative Loop Mode
  91735. */
  91736. private static _ANIMATIONLOOPMODE_RELATIVE;
  91737. /**
  91738. * Cycle Loop Mode
  91739. */
  91740. private static _ANIMATIONLOOPMODE_CYCLE;
  91741. /**
  91742. * Constant Loop Mode
  91743. */
  91744. private static _ANIMATIONLOOPMODE_CONSTANT;
  91745. /**
  91746. * Get the float animation type
  91747. */
  91748. static readonly ANIMATIONTYPE_FLOAT: number;
  91749. /**
  91750. * Get the Vector3 animation type
  91751. */
  91752. static readonly ANIMATIONTYPE_VECTOR3: number;
  91753. /**
  91754. * Get the Vector2 animation type
  91755. */
  91756. static readonly ANIMATIONTYPE_VECTOR2: number;
  91757. /**
  91758. * Get the Size animation type
  91759. */
  91760. static readonly ANIMATIONTYPE_SIZE: number;
  91761. /**
  91762. * Get the Quaternion animation type
  91763. */
  91764. static readonly ANIMATIONTYPE_QUATERNION: number;
  91765. /**
  91766. * Get the Matrix animation type
  91767. */
  91768. static readonly ANIMATIONTYPE_MATRIX: number;
  91769. /**
  91770. * Get the Color3 animation type
  91771. */
  91772. static readonly ANIMATIONTYPE_COLOR3: number;
  91773. /**
  91774. * Get the Relative Loop Mode
  91775. */
  91776. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91777. /**
  91778. * Get the Cycle Loop Mode
  91779. */
  91780. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91781. /**
  91782. * Get the Constant Loop Mode
  91783. */
  91784. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91785. /** @hidden */
  91786. static _UniversalLerp(left: any, right: any, amount: number): any;
  91787. /**
  91788. * Parses an animation object and creates an animation
  91789. * @param parsedAnimation Parsed animation object
  91790. * @returns Animation object
  91791. */
  91792. static Parse(parsedAnimation: any): Animation;
  91793. /**
  91794. * Appends the serialized animations from the source animations
  91795. * @param source Source containing the animations
  91796. * @param destination Target to store the animations
  91797. */
  91798. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91799. }
  91800. }
  91801. declare module BABYLON {
  91802. /**
  91803. * Interface containing an array of animations
  91804. */
  91805. export interface IAnimatable {
  91806. /**
  91807. * Array of animations
  91808. */
  91809. animations: Nullable<Array<Animation>>;
  91810. }
  91811. }
  91812. declare module BABYLON {
  91813. /**
  91814. * This represents all the required information to add a fresnel effect on a material:
  91815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91816. */
  91817. export class FresnelParameters {
  91818. private _isEnabled;
  91819. /**
  91820. * Define if the fresnel effect is enable or not.
  91821. */
  91822. isEnabled: boolean;
  91823. /**
  91824. * Define the color used on edges (grazing angle)
  91825. */
  91826. leftColor: Color3;
  91827. /**
  91828. * Define the color used on center
  91829. */
  91830. rightColor: Color3;
  91831. /**
  91832. * Define bias applied to computed fresnel term
  91833. */
  91834. bias: number;
  91835. /**
  91836. * Defined the power exponent applied to fresnel term
  91837. */
  91838. power: number;
  91839. /**
  91840. * Clones the current fresnel and its valuues
  91841. * @returns a clone fresnel configuration
  91842. */
  91843. clone(): FresnelParameters;
  91844. /**
  91845. * Serializes the current fresnel parameters to a JSON representation.
  91846. * @return the JSON serialization
  91847. */
  91848. serialize(): any;
  91849. /**
  91850. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91851. * @param parsedFresnelParameters Define the JSON representation
  91852. * @returns the parsed parameters
  91853. */
  91854. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91855. }
  91856. }
  91857. declare module BABYLON {
  91858. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91859. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91860. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91861. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91862. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91863. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91864. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91865. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91866. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91867. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91868. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91869. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91870. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91871. /**
  91872. * Decorator used to define property that can be serialized as reference to a camera
  91873. * @param sourceName defines the name of the property to decorate
  91874. */
  91875. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91876. /**
  91877. * Class used to help serialization objects
  91878. */
  91879. export class SerializationHelper {
  91880. /** @hidden */
  91881. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91882. /** @hidden */
  91883. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91884. /** @hidden */
  91885. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91886. /** @hidden */
  91887. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91888. /**
  91889. * Appends the serialized animations from the source animations
  91890. * @param source Source containing the animations
  91891. * @param destination Target to store the animations
  91892. */
  91893. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91894. /**
  91895. * Static function used to serialized a specific entity
  91896. * @param entity defines the entity to serialize
  91897. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91898. * @returns a JSON compatible object representing the serialization of the entity
  91899. */
  91900. static Serialize<T>(entity: T, serializationObject?: any): any;
  91901. /**
  91902. * Creates a new entity from a serialization data object
  91903. * @param creationFunction defines a function used to instanciated the new entity
  91904. * @param source defines the source serialization data
  91905. * @param scene defines the hosting scene
  91906. * @param rootUrl defines the root url for resources
  91907. * @returns a new entity
  91908. */
  91909. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91910. /**
  91911. * Clones an object
  91912. * @param creationFunction defines the function used to instanciate the new object
  91913. * @param source defines the source object
  91914. * @returns the cloned object
  91915. */
  91916. static Clone<T>(creationFunction: () => T, source: T): T;
  91917. /**
  91918. * Instanciates a new object based on a source one (some data will be shared between both object)
  91919. * @param creationFunction defines the function used to instanciate the new object
  91920. * @param source defines the source object
  91921. * @returns the new object
  91922. */
  91923. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91924. }
  91925. }
  91926. declare module BABYLON {
  91927. /**
  91928. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91929. */
  91930. export interface CubeMapInfo {
  91931. /**
  91932. * The pixel array for the front face.
  91933. * This is stored in format, left to right, up to down format.
  91934. */
  91935. front: Nullable<ArrayBufferView>;
  91936. /**
  91937. * The pixel array for the back face.
  91938. * This is stored in format, left to right, up to down format.
  91939. */
  91940. back: Nullable<ArrayBufferView>;
  91941. /**
  91942. * The pixel array for the left face.
  91943. * This is stored in format, left to right, up to down format.
  91944. */
  91945. left: Nullable<ArrayBufferView>;
  91946. /**
  91947. * The pixel array for the right face.
  91948. * This is stored in format, left to right, up to down format.
  91949. */
  91950. right: Nullable<ArrayBufferView>;
  91951. /**
  91952. * The pixel array for the up face.
  91953. * This is stored in format, left to right, up to down format.
  91954. */
  91955. up: Nullable<ArrayBufferView>;
  91956. /**
  91957. * The pixel array for the down face.
  91958. * This is stored in format, left to right, up to down format.
  91959. */
  91960. down: Nullable<ArrayBufferView>;
  91961. /**
  91962. * The size of the cubemap stored.
  91963. *
  91964. * Each faces will be size * size pixels.
  91965. */
  91966. size: number;
  91967. /**
  91968. * The format of the texture.
  91969. *
  91970. * RGBA, RGB.
  91971. */
  91972. format: number;
  91973. /**
  91974. * The type of the texture data.
  91975. *
  91976. * UNSIGNED_INT, FLOAT.
  91977. */
  91978. type: number;
  91979. /**
  91980. * Specifies whether the texture is in gamma space.
  91981. */
  91982. gammaSpace: boolean;
  91983. }
  91984. /**
  91985. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91986. */
  91987. export class PanoramaToCubeMapTools {
  91988. private static FACE_FRONT;
  91989. private static FACE_BACK;
  91990. private static FACE_RIGHT;
  91991. private static FACE_LEFT;
  91992. private static FACE_DOWN;
  91993. private static FACE_UP;
  91994. /**
  91995. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91996. *
  91997. * @param float32Array The source data.
  91998. * @param inputWidth The width of the input panorama.
  91999. * @param inputHeight The height of the input panorama.
  92000. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92001. * @return The cubemap data
  92002. */
  92003. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92004. private static CreateCubemapTexture;
  92005. private static CalcProjectionSpherical;
  92006. }
  92007. }
  92008. declare module BABYLON {
  92009. /**
  92010. * Helper class dealing with the extraction of spherical polynomial dataArray
  92011. * from a cube map.
  92012. */
  92013. export class CubeMapToSphericalPolynomialTools {
  92014. private static FileFaces;
  92015. /**
  92016. * Converts a texture to the according Spherical Polynomial data.
  92017. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92018. *
  92019. * @param texture The texture to extract the information from.
  92020. * @return The Spherical Polynomial data.
  92021. */
  92022. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92023. /**
  92024. * Converts a cubemap to the according Spherical Polynomial data.
  92025. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92026. *
  92027. * @param cubeInfo The Cube map to extract the information from.
  92028. * @return The Spherical Polynomial data.
  92029. */
  92030. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92031. }
  92032. }
  92033. declare module BABYLON {
  92034. /**
  92035. * Class used to manipulate GUIDs
  92036. */
  92037. export class GUID {
  92038. /**
  92039. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92040. * Be aware Math.random() could cause collisions, but:
  92041. * "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"
  92042. * @returns a pseudo random id
  92043. */
  92044. static RandomId(): string;
  92045. }
  92046. }
  92047. declare module BABYLON {
  92048. /**
  92049. * Base class of all the textures in babylon.
  92050. * It groups all the common properties the materials, post process, lights... might need
  92051. * in order to make a correct use of the texture.
  92052. */
  92053. export class BaseTexture implements IAnimatable {
  92054. /**
  92055. * Default anisotropic filtering level for the application.
  92056. * It is set to 4 as a good tradeoff between perf and quality.
  92057. */
  92058. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92059. /**
  92060. * Gets or sets the unique id of the texture
  92061. */
  92062. uniqueId: number;
  92063. /**
  92064. * Define the name of the texture.
  92065. */
  92066. name: string;
  92067. /**
  92068. * Gets or sets an object used to store user defined information.
  92069. */
  92070. metadata: any;
  92071. /**
  92072. * For internal use only. Please do not use.
  92073. */
  92074. reservedDataStore: any;
  92075. private _hasAlpha;
  92076. /**
  92077. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92078. */
  92079. hasAlpha: boolean;
  92080. /**
  92081. * Defines if the alpha value should be determined via the rgb values.
  92082. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92083. */
  92084. getAlphaFromRGB: boolean;
  92085. /**
  92086. * Intensity or strength of the texture.
  92087. * It is commonly used by materials to fine tune the intensity of the texture
  92088. */
  92089. level: number;
  92090. /**
  92091. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92092. * This is part of the texture as textures usually maps to one uv set.
  92093. */
  92094. coordinatesIndex: number;
  92095. private _coordinatesMode;
  92096. /**
  92097. * How a texture is mapped.
  92098. *
  92099. * | Value | Type | Description |
  92100. * | ----- | ----------------------------------- | ----------- |
  92101. * | 0 | EXPLICIT_MODE | |
  92102. * | 1 | SPHERICAL_MODE | |
  92103. * | 2 | PLANAR_MODE | |
  92104. * | 3 | CUBIC_MODE | |
  92105. * | 4 | PROJECTION_MODE | |
  92106. * | 5 | SKYBOX_MODE | |
  92107. * | 6 | INVCUBIC_MODE | |
  92108. * | 7 | EQUIRECTANGULAR_MODE | |
  92109. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92110. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92111. */
  92112. coordinatesMode: number;
  92113. /**
  92114. * | Value | Type | Description |
  92115. * | ----- | ------------------ | ----------- |
  92116. * | 0 | CLAMP_ADDRESSMODE | |
  92117. * | 1 | WRAP_ADDRESSMODE | |
  92118. * | 2 | MIRROR_ADDRESSMODE | |
  92119. */
  92120. wrapU: number;
  92121. /**
  92122. * | Value | Type | Description |
  92123. * | ----- | ------------------ | ----------- |
  92124. * | 0 | CLAMP_ADDRESSMODE | |
  92125. * | 1 | WRAP_ADDRESSMODE | |
  92126. * | 2 | MIRROR_ADDRESSMODE | |
  92127. */
  92128. wrapV: number;
  92129. /**
  92130. * | Value | Type | Description |
  92131. * | ----- | ------------------ | ----------- |
  92132. * | 0 | CLAMP_ADDRESSMODE | |
  92133. * | 1 | WRAP_ADDRESSMODE | |
  92134. * | 2 | MIRROR_ADDRESSMODE | |
  92135. */
  92136. wrapR: number;
  92137. /**
  92138. * With compliant hardware and browser (supporting anisotropic filtering)
  92139. * this defines the level of anisotropic filtering in the texture.
  92140. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92141. */
  92142. anisotropicFilteringLevel: number;
  92143. /**
  92144. * Define if the texture is a cube texture or if false a 2d texture.
  92145. */
  92146. isCube: boolean;
  92147. /**
  92148. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92149. */
  92150. is3D: boolean;
  92151. /**
  92152. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92153. * HDR texture are usually stored in linear space.
  92154. * This only impacts the PBR and Background materials
  92155. */
  92156. gammaSpace: boolean;
  92157. /**
  92158. * Gets whether or not the texture contains RGBD data.
  92159. */
  92160. readonly isRGBD: boolean;
  92161. /**
  92162. * Is Z inverted in the texture (useful in a cube texture).
  92163. */
  92164. invertZ: boolean;
  92165. /**
  92166. * Are mip maps generated for this texture or not.
  92167. */
  92168. readonly noMipmap: boolean;
  92169. /**
  92170. * @hidden
  92171. */
  92172. lodLevelInAlpha: boolean;
  92173. /**
  92174. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92175. */
  92176. lodGenerationOffset: number;
  92177. /**
  92178. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92179. */
  92180. lodGenerationScale: number;
  92181. /**
  92182. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92183. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92184. * average roughness values.
  92185. */
  92186. linearSpecularLOD: boolean;
  92187. /**
  92188. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92189. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92190. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92191. */
  92192. irradianceTexture: Nullable<BaseTexture>;
  92193. /**
  92194. * Define if the texture is a render target.
  92195. */
  92196. isRenderTarget: boolean;
  92197. /**
  92198. * Define the unique id of the texture in the scene.
  92199. */
  92200. readonly uid: string;
  92201. /**
  92202. * Return a string representation of the texture.
  92203. * @returns the texture as a string
  92204. */
  92205. toString(): string;
  92206. /**
  92207. * Get the class name of the texture.
  92208. * @returns "BaseTexture"
  92209. */
  92210. getClassName(): string;
  92211. /**
  92212. * Define the list of animation attached to the texture.
  92213. */
  92214. animations: Animation[];
  92215. /**
  92216. * An event triggered when the texture is disposed.
  92217. */
  92218. onDisposeObservable: Observable<BaseTexture>;
  92219. private _onDisposeObserver;
  92220. /**
  92221. * Callback triggered when the texture has been disposed.
  92222. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92223. */
  92224. onDispose: () => void;
  92225. /**
  92226. * Define the current state of the loading sequence when in delayed load mode.
  92227. */
  92228. delayLoadState: number;
  92229. private _scene;
  92230. /** @hidden */
  92231. _texture: Nullable<InternalTexture>;
  92232. private _uid;
  92233. /**
  92234. * Define if the texture is preventinga material to render or not.
  92235. * If not and the texture is not ready, the engine will use a default black texture instead.
  92236. */
  92237. readonly isBlocking: boolean;
  92238. /**
  92239. * Instantiates a new BaseTexture.
  92240. * Base class of all the textures in babylon.
  92241. * It groups all the common properties the materials, post process, lights... might need
  92242. * in order to make a correct use of the texture.
  92243. * @param scene Define the scene the texture blongs to
  92244. */
  92245. constructor(scene: Nullable<Scene>);
  92246. /**
  92247. * Get the scene the texture belongs to.
  92248. * @returns the scene or null if undefined
  92249. */
  92250. getScene(): Nullable<Scene>;
  92251. /**
  92252. * Get the texture transform matrix used to offset tile the texture for istance.
  92253. * @returns the transformation matrix
  92254. */
  92255. getTextureMatrix(): Matrix;
  92256. /**
  92257. * Get the texture reflection matrix used to rotate/transform the reflection.
  92258. * @returns the reflection matrix
  92259. */
  92260. getReflectionTextureMatrix(): Matrix;
  92261. /**
  92262. * Get the underlying lower level texture from Babylon.
  92263. * @returns the insternal texture
  92264. */
  92265. getInternalTexture(): Nullable<InternalTexture>;
  92266. /**
  92267. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92268. * @returns true if ready or not blocking
  92269. */
  92270. isReadyOrNotBlocking(): boolean;
  92271. /**
  92272. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92273. * @returns true if fully ready
  92274. */
  92275. isReady(): boolean;
  92276. private _cachedSize;
  92277. /**
  92278. * Get the size of the texture.
  92279. * @returns the texture size.
  92280. */
  92281. getSize(): ISize;
  92282. /**
  92283. * Get the base size of the texture.
  92284. * It can be different from the size if the texture has been resized for POT for instance
  92285. * @returns the base size
  92286. */
  92287. getBaseSize(): ISize;
  92288. /**
  92289. * Update the sampling mode of the texture.
  92290. * Default is Trilinear mode.
  92291. *
  92292. * | Value | Type | Description |
  92293. * | ----- | ------------------ | ----------- |
  92294. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92295. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92296. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92297. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92298. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92299. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92300. * | 7 | NEAREST_LINEAR | |
  92301. * | 8 | NEAREST_NEAREST | |
  92302. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92303. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92304. * | 11 | LINEAR_LINEAR | |
  92305. * | 12 | LINEAR_NEAREST | |
  92306. *
  92307. * > _mag_: magnification filter (close to the viewer)
  92308. * > _min_: minification filter (far from the viewer)
  92309. * > _mip_: filter used between mip map levels
  92310. *@param samplingMode Define the new sampling mode of the texture
  92311. */
  92312. updateSamplingMode(samplingMode: number): void;
  92313. /**
  92314. * Scales the texture if is `canRescale()`
  92315. * @param ratio the resize factor we want to use to rescale
  92316. */
  92317. scale(ratio: number): void;
  92318. /**
  92319. * Get if the texture can rescale.
  92320. */
  92321. readonly canRescale: boolean;
  92322. /** @hidden */
  92323. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92324. /** @hidden */
  92325. _rebuild(): void;
  92326. /**
  92327. * Triggers the load sequence in delayed load mode.
  92328. */
  92329. delayLoad(): void;
  92330. /**
  92331. * Clones the texture.
  92332. * @returns the cloned texture
  92333. */
  92334. clone(): Nullable<BaseTexture>;
  92335. /**
  92336. * Get the texture underlying type (INT, FLOAT...)
  92337. */
  92338. readonly textureType: number;
  92339. /**
  92340. * Get the texture underlying format (RGB, RGBA...)
  92341. */
  92342. readonly textureFormat: number;
  92343. /**
  92344. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92345. * This will returns an RGBA array buffer containing either in values (0-255) or
  92346. * float values (0-1) depending of the underlying buffer type.
  92347. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92348. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92349. * @param buffer defines a user defined buffer to fill with data (can be null)
  92350. * @returns The Array buffer containing the pixels data.
  92351. */
  92352. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92353. /**
  92354. * Release and destroy the underlying lower level texture aka internalTexture.
  92355. */
  92356. releaseInternalTexture(): void;
  92357. /**
  92358. * Get the polynomial representation of the texture data.
  92359. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92360. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92361. */
  92362. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92363. /** @hidden */
  92364. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92365. /** @hidden */
  92366. readonly _lodTextureMid: Nullable<BaseTexture>;
  92367. /** @hidden */
  92368. readonly _lodTextureLow: Nullable<BaseTexture>;
  92369. /**
  92370. * Dispose the texture and release its associated resources.
  92371. */
  92372. dispose(): void;
  92373. /**
  92374. * Serialize the texture into a JSON representation that can be parsed later on.
  92375. * @returns the JSON representation of the texture
  92376. */
  92377. serialize(): any;
  92378. /**
  92379. * Helper function to be called back once a list of texture contains only ready textures.
  92380. * @param textures Define the list of textures to wait for
  92381. * @param callback Define the callback triggered once the entire list will be ready
  92382. */
  92383. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92384. }
  92385. }
  92386. declare module BABYLON {
  92387. /**
  92388. * Class used to store data associated with WebGL texture data for the engine
  92389. * This class should not be used directly
  92390. */
  92391. export class InternalTexture {
  92392. /** @hidden */
  92393. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92394. /**
  92395. * The source of the texture data is unknown
  92396. */
  92397. static DATASOURCE_UNKNOWN: number;
  92398. /**
  92399. * Texture data comes from an URL
  92400. */
  92401. static DATASOURCE_URL: number;
  92402. /**
  92403. * Texture data is only used for temporary storage
  92404. */
  92405. static DATASOURCE_TEMP: number;
  92406. /**
  92407. * Texture data comes from raw data (ArrayBuffer)
  92408. */
  92409. static DATASOURCE_RAW: number;
  92410. /**
  92411. * Texture content is dynamic (video or dynamic texture)
  92412. */
  92413. static DATASOURCE_DYNAMIC: number;
  92414. /**
  92415. * Texture content is generated by rendering to it
  92416. */
  92417. static DATASOURCE_RENDERTARGET: number;
  92418. /**
  92419. * Texture content is part of a multi render target process
  92420. */
  92421. static DATASOURCE_MULTIRENDERTARGET: number;
  92422. /**
  92423. * Texture data comes from a cube data file
  92424. */
  92425. static DATASOURCE_CUBE: number;
  92426. /**
  92427. * Texture data comes from a raw cube data
  92428. */
  92429. static DATASOURCE_CUBERAW: number;
  92430. /**
  92431. * Texture data come from a prefiltered cube data file
  92432. */
  92433. static DATASOURCE_CUBEPREFILTERED: number;
  92434. /**
  92435. * Texture content is raw 3D data
  92436. */
  92437. static DATASOURCE_RAW3D: number;
  92438. /**
  92439. * Texture content is a depth texture
  92440. */
  92441. static DATASOURCE_DEPTHTEXTURE: number;
  92442. /**
  92443. * Texture data comes from a raw cube data encoded with RGBD
  92444. */
  92445. static DATASOURCE_CUBERAW_RGBD: number;
  92446. /**
  92447. * Defines if the texture is ready
  92448. */
  92449. isReady: boolean;
  92450. /**
  92451. * Defines if the texture is a cube texture
  92452. */
  92453. isCube: boolean;
  92454. /**
  92455. * Defines if the texture contains 3D data
  92456. */
  92457. is3D: boolean;
  92458. /**
  92459. * Defines if the texture contains multiview data
  92460. */
  92461. isMultiview: boolean;
  92462. /**
  92463. * Gets the URL used to load this texture
  92464. */
  92465. url: string;
  92466. /**
  92467. * Gets the sampling mode of the texture
  92468. */
  92469. samplingMode: number;
  92470. /**
  92471. * Gets a boolean indicating if the texture needs mipmaps generation
  92472. */
  92473. generateMipMaps: boolean;
  92474. /**
  92475. * Gets the number of samples used by the texture (WebGL2+ only)
  92476. */
  92477. samples: number;
  92478. /**
  92479. * Gets the type of the texture (int, float...)
  92480. */
  92481. type: number;
  92482. /**
  92483. * Gets the format of the texture (RGB, RGBA...)
  92484. */
  92485. format: number;
  92486. /**
  92487. * Observable called when the texture is loaded
  92488. */
  92489. onLoadedObservable: Observable<InternalTexture>;
  92490. /**
  92491. * Gets the width of the texture
  92492. */
  92493. width: number;
  92494. /**
  92495. * Gets the height of the texture
  92496. */
  92497. height: number;
  92498. /**
  92499. * Gets the depth of the texture
  92500. */
  92501. depth: number;
  92502. /**
  92503. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92504. */
  92505. baseWidth: number;
  92506. /**
  92507. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92508. */
  92509. baseHeight: number;
  92510. /**
  92511. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92512. */
  92513. baseDepth: number;
  92514. /**
  92515. * Gets a boolean indicating if the texture is inverted on Y axis
  92516. */
  92517. invertY: boolean;
  92518. /** @hidden */
  92519. _invertVScale: boolean;
  92520. /** @hidden */
  92521. _associatedChannel: number;
  92522. /** @hidden */
  92523. _dataSource: number;
  92524. /** @hidden */
  92525. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92526. /** @hidden */
  92527. _bufferView: Nullable<ArrayBufferView>;
  92528. /** @hidden */
  92529. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92530. /** @hidden */
  92531. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92532. /** @hidden */
  92533. _size: number;
  92534. /** @hidden */
  92535. _extension: string;
  92536. /** @hidden */
  92537. _files: Nullable<string[]>;
  92538. /** @hidden */
  92539. _workingCanvas: Nullable<HTMLCanvasElement>;
  92540. /** @hidden */
  92541. _workingContext: Nullable<CanvasRenderingContext2D>;
  92542. /** @hidden */
  92543. _framebuffer: Nullable<WebGLFramebuffer>;
  92544. /** @hidden */
  92545. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92546. /** @hidden */
  92547. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92548. /** @hidden */
  92549. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92550. /** @hidden */
  92551. _attachments: Nullable<number[]>;
  92552. /** @hidden */
  92553. _cachedCoordinatesMode: Nullable<number>;
  92554. /** @hidden */
  92555. _cachedWrapU: Nullable<number>;
  92556. /** @hidden */
  92557. _cachedWrapV: Nullable<number>;
  92558. /** @hidden */
  92559. _cachedWrapR: Nullable<number>;
  92560. /** @hidden */
  92561. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92562. /** @hidden */
  92563. _isDisabled: boolean;
  92564. /** @hidden */
  92565. _compression: Nullable<string>;
  92566. /** @hidden */
  92567. _generateStencilBuffer: boolean;
  92568. /** @hidden */
  92569. _generateDepthBuffer: boolean;
  92570. /** @hidden */
  92571. _comparisonFunction: number;
  92572. /** @hidden */
  92573. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92574. /** @hidden */
  92575. _lodGenerationScale: number;
  92576. /** @hidden */
  92577. _lodGenerationOffset: number;
  92578. /** @hidden */
  92579. _colorTextureArray: Nullable<WebGLTexture>;
  92580. /** @hidden */
  92581. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92582. /** @hidden */
  92583. _lodTextureHigh: Nullable<BaseTexture>;
  92584. /** @hidden */
  92585. _lodTextureMid: Nullable<BaseTexture>;
  92586. /** @hidden */
  92587. _lodTextureLow: Nullable<BaseTexture>;
  92588. /** @hidden */
  92589. _isRGBD: boolean;
  92590. /** @hidden */
  92591. _linearSpecularLOD: boolean;
  92592. /** @hidden */
  92593. _irradianceTexture: Nullable<BaseTexture>;
  92594. /** @hidden */
  92595. _webGLTexture: Nullable<WebGLTexture>;
  92596. /** @hidden */
  92597. _references: number;
  92598. private _engine;
  92599. /**
  92600. * Gets the Engine the texture belongs to.
  92601. * @returns The babylon engine
  92602. */
  92603. getEngine(): Engine;
  92604. /**
  92605. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92606. */
  92607. readonly dataSource: number;
  92608. /**
  92609. * Creates a new InternalTexture
  92610. * @param engine defines the engine to use
  92611. * @param dataSource defines the type of data that will be used
  92612. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92613. */
  92614. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92615. /**
  92616. * Increments the number of references (ie. the number of Texture that point to it)
  92617. */
  92618. incrementReferences(): void;
  92619. /**
  92620. * Change the size of the texture (not the size of the content)
  92621. * @param width defines the new width
  92622. * @param height defines the new height
  92623. * @param depth defines the new depth (1 by default)
  92624. */
  92625. updateSize(width: int, height: int, depth?: int): void;
  92626. /** @hidden */
  92627. _rebuild(): void;
  92628. /** @hidden */
  92629. _swapAndDie(target: InternalTexture): void;
  92630. /**
  92631. * Dispose the current allocated resources
  92632. */
  92633. dispose(): void;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /**
  92638. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92639. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92640. */
  92641. export class EffectFallbacks {
  92642. private _defines;
  92643. private _currentRank;
  92644. private _maxRank;
  92645. private _mesh;
  92646. /**
  92647. * Removes the fallback from the bound mesh.
  92648. */
  92649. unBindMesh(): void;
  92650. /**
  92651. * Adds a fallback on the specified property.
  92652. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92653. * @param define The name of the define in the shader
  92654. */
  92655. addFallback(rank: number, define: string): void;
  92656. /**
  92657. * Sets the mesh to use CPU skinning when needing to fallback.
  92658. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92659. * @param mesh The mesh to use the fallbacks.
  92660. */
  92661. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92662. /**
  92663. * Checks to see if more fallbacks are still availible.
  92664. */
  92665. readonly isMoreFallbacks: boolean;
  92666. /**
  92667. * Removes the defines that should be removed when falling back.
  92668. * @param currentDefines defines the current define statements for the shader.
  92669. * @param effect defines the current effect we try to compile
  92670. * @returns The resulting defines with defines of the current rank removed.
  92671. */
  92672. reduce(currentDefines: string, effect: Effect): string;
  92673. }
  92674. /**
  92675. * Options to be used when creating an effect.
  92676. */
  92677. export class EffectCreationOptions {
  92678. /**
  92679. * Atrributes that will be used in the shader.
  92680. */
  92681. attributes: string[];
  92682. /**
  92683. * Uniform varible names that will be set in the shader.
  92684. */
  92685. uniformsNames: string[];
  92686. /**
  92687. * Uniform buffer varible names that will be set in the shader.
  92688. */
  92689. uniformBuffersNames: string[];
  92690. /**
  92691. * Sampler texture variable names that will be set in the shader.
  92692. */
  92693. samplers: string[];
  92694. /**
  92695. * Define statements that will be set in the shader.
  92696. */
  92697. defines: any;
  92698. /**
  92699. * Possible fallbacks for this effect to improve performance when needed.
  92700. */
  92701. fallbacks: Nullable<EffectFallbacks>;
  92702. /**
  92703. * Callback that will be called when the shader is compiled.
  92704. */
  92705. onCompiled: Nullable<(effect: Effect) => void>;
  92706. /**
  92707. * Callback that will be called if an error occurs during shader compilation.
  92708. */
  92709. onError: Nullable<(effect: Effect, errors: string) => void>;
  92710. /**
  92711. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92712. */
  92713. indexParameters: any;
  92714. /**
  92715. * Max number of lights that can be used in the shader.
  92716. */
  92717. maxSimultaneousLights: number;
  92718. /**
  92719. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92720. */
  92721. transformFeedbackVaryings: Nullable<string[]>;
  92722. }
  92723. /**
  92724. * Effect containing vertex and fragment shader that can be executed on an object.
  92725. */
  92726. export class Effect implements IDisposable {
  92727. /**
  92728. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92729. */
  92730. static ShadersRepository: string;
  92731. /**
  92732. * Name of the effect.
  92733. */
  92734. name: any;
  92735. /**
  92736. * String container all the define statements that should be set on the shader.
  92737. */
  92738. defines: string;
  92739. /**
  92740. * Callback that will be called when the shader is compiled.
  92741. */
  92742. onCompiled: Nullable<(effect: Effect) => void>;
  92743. /**
  92744. * Callback that will be called if an error occurs during shader compilation.
  92745. */
  92746. onError: Nullable<(effect: Effect, errors: string) => void>;
  92747. /**
  92748. * Callback that will be called when effect is bound.
  92749. */
  92750. onBind: Nullable<(effect: Effect) => void>;
  92751. /**
  92752. * Unique ID of the effect.
  92753. */
  92754. uniqueId: number;
  92755. /**
  92756. * Observable that will be called when the shader is compiled.
  92757. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92758. */
  92759. onCompileObservable: Observable<Effect>;
  92760. /**
  92761. * Observable that will be called if an error occurs during shader compilation.
  92762. */
  92763. onErrorObservable: Observable<Effect>;
  92764. /** @hidden */
  92765. _onBindObservable: Nullable<Observable<Effect>>;
  92766. /**
  92767. * Observable that will be called when effect is bound.
  92768. */
  92769. readonly onBindObservable: Observable<Effect>;
  92770. /** @hidden */
  92771. _bonesComputationForcedToCPU: boolean;
  92772. private static _uniqueIdSeed;
  92773. private _engine;
  92774. private _uniformBuffersNames;
  92775. private _uniformsNames;
  92776. private _samplerList;
  92777. private _samplers;
  92778. private _isReady;
  92779. private _compilationError;
  92780. private _attributesNames;
  92781. private _attributes;
  92782. private _uniforms;
  92783. /**
  92784. * Key for the effect.
  92785. * @hidden
  92786. */
  92787. _key: string;
  92788. private _indexParameters;
  92789. private _fallbacks;
  92790. private _vertexSourceCode;
  92791. private _fragmentSourceCode;
  92792. private _vertexSourceCodeOverride;
  92793. private _fragmentSourceCodeOverride;
  92794. private _transformFeedbackVaryings;
  92795. /**
  92796. * Compiled shader to webGL program.
  92797. * @hidden
  92798. */
  92799. _pipelineContext: Nullable<IPipelineContext>;
  92800. private _valueCache;
  92801. private static _baseCache;
  92802. /**
  92803. * Instantiates an effect.
  92804. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92805. * @param baseName Name of the effect.
  92806. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92807. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92808. * @param samplers List of sampler variables that will be passed to the shader.
  92809. * @param engine Engine to be used to render the effect
  92810. * @param defines Define statements to be added to the shader.
  92811. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92812. * @param onCompiled Callback that will be called when the shader is compiled.
  92813. * @param onError Callback that will be called if an error occurs during shader compilation.
  92814. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92815. */
  92816. 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);
  92817. private _useFinalCode;
  92818. /**
  92819. * Unique key for this effect
  92820. */
  92821. readonly key: string;
  92822. /**
  92823. * If the effect has been compiled and prepared.
  92824. * @returns if the effect is compiled and prepared.
  92825. */
  92826. isReady(): boolean;
  92827. /**
  92828. * The engine the effect was initialized with.
  92829. * @returns the engine.
  92830. */
  92831. getEngine(): Engine;
  92832. /**
  92833. * The pipeline context for this effect
  92834. * @returns the associated pipeline context
  92835. */
  92836. getPipelineContext(): Nullable<IPipelineContext>;
  92837. /**
  92838. * The set of names of attribute variables for the shader.
  92839. * @returns An array of attribute names.
  92840. */
  92841. getAttributesNames(): string[];
  92842. /**
  92843. * Returns the attribute at the given index.
  92844. * @param index The index of the attribute.
  92845. * @returns The location of the attribute.
  92846. */
  92847. getAttributeLocation(index: number): number;
  92848. /**
  92849. * Returns the attribute based on the name of the variable.
  92850. * @param name of the attribute to look up.
  92851. * @returns the attribute location.
  92852. */
  92853. getAttributeLocationByName(name: string): number;
  92854. /**
  92855. * The number of attributes.
  92856. * @returns the numnber of attributes.
  92857. */
  92858. getAttributesCount(): number;
  92859. /**
  92860. * Gets the index of a uniform variable.
  92861. * @param uniformName of the uniform to look up.
  92862. * @returns the index.
  92863. */
  92864. getUniformIndex(uniformName: string): number;
  92865. /**
  92866. * Returns the attribute based on the name of the variable.
  92867. * @param uniformName of the uniform to look up.
  92868. * @returns the location of the uniform.
  92869. */
  92870. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92871. /**
  92872. * Returns an array of sampler variable names
  92873. * @returns The array of sampler variable neames.
  92874. */
  92875. getSamplers(): string[];
  92876. /**
  92877. * The error from the last compilation.
  92878. * @returns the error string.
  92879. */
  92880. getCompilationError(): string;
  92881. /**
  92882. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92883. * @param func The callback to be used.
  92884. */
  92885. executeWhenCompiled(func: (effect: Effect) => void): void;
  92886. private _checkIsReady;
  92887. /** @hidden */
  92888. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92889. /** @hidden */
  92890. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92891. /** @hidden */
  92892. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92893. /**
  92894. * Recompiles the webGL program
  92895. * @param vertexSourceCode The source code for the vertex shader.
  92896. * @param fragmentSourceCode The source code for the fragment shader.
  92897. * @param onCompiled Callback called when completed.
  92898. * @param onError Callback called on error.
  92899. * @hidden
  92900. */
  92901. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92902. /**
  92903. * Prepares the effect
  92904. * @hidden
  92905. */
  92906. _prepareEffect(): void;
  92907. /**
  92908. * Checks if the effect is supported. (Must be called after compilation)
  92909. */
  92910. readonly isSupported: boolean;
  92911. /**
  92912. * Binds a texture to the engine to be used as output of the shader.
  92913. * @param channel Name of the output variable.
  92914. * @param texture Texture to bind.
  92915. * @hidden
  92916. */
  92917. _bindTexture(channel: string, texture: InternalTexture): void;
  92918. /**
  92919. * Sets a texture on the engine to be used in the shader.
  92920. * @param channel Name of the sampler variable.
  92921. * @param texture Texture to set.
  92922. */
  92923. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92924. /**
  92925. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92926. * @param channel Name of the sampler variable.
  92927. * @param texture Texture to set.
  92928. */
  92929. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92930. /**
  92931. * Sets an array of textures on the engine to be used in the shader.
  92932. * @param channel Name of the variable.
  92933. * @param textures Textures to set.
  92934. */
  92935. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92936. /**
  92937. * 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)
  92938. * @param channel Name of the sampler variable.
  92939. * @param postProcess Post process to get the input texture from.
  92940. */
  92941. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92942. /**
  92943. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92944. * 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)
  92945. * @param channel Name of the sampler variable.
  92946. * @param postProcess Post process to get the output texture from.
  92947. */
  92948. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92949. /** @hidden */
  92950. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92951. /** @hidden */
  92952. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92953. /** @hidden */
  92954. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92955. /** @hidden */
  92956. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92957. /**
  92958. * Binds a buffer to a uniform.
  92959. * @param buffer Buffer to bind.
  92960. * @param name Name of the uniform variable to bind to.
  92961. */
  92962. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92963. /**
  92964. * Binds block to a uniform.
  92965. * @param blockName Name of the block to bind.
  92966. * @param index Index to bind.
  92967. */
  92968. bindUniformBlock(blockName: string, index: number): void;
  92969. /**
  92970. * Sets an interger value on a uniform variable.
  92971. * @param uniformName Name of the variable.
  92972. * @param value Value to be set.
  92973. * @returns this effect.
  92974. */
  92975. setInt(uniformName: string, value: number): Effect;
  92976. /**
  92977. * Sets an int array on a uniform variable.
  92978. * @param uniformName Name of the variable.
  92979. * @param array array to be set.
  92980. * @returns this effect.
  92981. */
  92982. setIntArray(uniformName: string, array: Int32Array): Effect;
  92983. /**
  92984. * 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)
  92985. * @param uniformName Name of the variable.
  92986. * @param array array to be set.
  92987. * @returns this effect.
  92988. */
  92989. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92990. /**
  92991. * 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)
  92992. * @param uniformName Name of the variable.
  92993. * @param array array to be set.
  92994. * @returns this effect.
  92995. */
  92996. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92997. /**
  92998. * 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)
  92999. * @param uniformName Name of the variable.
  93000. * @param array array to be set.
  93001. * @returns this effect.
  93002. */
  93003. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93004. /**
  93005. * Sets an float array on a uniform variable.
  93006. * @param uniformName Name of the variable.
  93007. * @param array array to be set.
  93008. * @returns this effect.
  93009. */
  93010. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93011. /**
  93012. * 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)
  93013. * @param uniformName Name of the variable.
  93014. * @param array array to be set.
  93015. * @returns this effect.
  93016. */
  93017. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93018. /**
  93019. * 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)
  93020. * @param uniformName Name of the variable.
  93021. * @param array array to be set.
  93022. * @returns this effect.
  93023. */
  93024. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93025. /**
  93026. * 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)
  93027. * @param uniformName Name of the variable.
  93028. * @param array array to be set.
  93029. * @returns this effect.
  93030. */
  93031. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93032. /**
  93033. * Sets an array on a uniform variable.
  93034. * @param uniformName Name of the variable.
  93035. * @param array array to be set.
  93036. * @returns this effect.
  93037. */
  93038. setArray(uniformName: string, array: number[]): Effect;
  93039. /**
  93040. * 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)
  93041. * @param uniformName Name of the variable.
  93042. * @param array array to be set.
  93043. * @returns this effect.
  93044. */
  93045. setArray2(uniformName: string, array: number[]): Effect;
  93046. /**
  93047. * 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)
  93048. * @param uniformName Name of the variable.
  93049. * @param array array to be set.
  93050. * @returns this effect.
  93051. */
  93052. setArray3(uniformName: string, array: number[]): Effect;
  93053. /**
  93054. * 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)
  93055. * @param uniformName Name of the variable.
  93056. * @param array array to be set.
  93057. * @returns this effect.
  93058. */
  93059. setArray4(uniformName: string, array: number[]): Effect;
  93060. /**
  93061. * Sets matrices on a uniform variable.
  93062. * @param uniformName Name of the variable.
  93063. * @param matrices matrices to be set.
  93064. * @returns this effect.
  93065. */
  93066. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93067. /**
  93068. * Sets matrix on a uniform variable.
  93069. * @param uniformName Name of the variable.
  93070. * @param matrix matrix to be set.
  93071. * @returns this effect.
  93072. */
  93073. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93074. /**
  93075. * 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)
  93076. * @param uniformName Name of the variable.
  93077. * @param matrix matrix to be set.
  93078. * @returns this effect.
  93079. */
  93080. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93081. /**
  93082. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93083. * @param uniformName Name of the variable.
  93084. * @param matrix matrix to be set.
  93085. * @returns this effect.
  93086. */
  93087. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93088. /**
  93089. * Sets a float on a uniform variable.
  93090. * @param uniformName Name of the variable.
  93091. * @param value value to be set.
  93092. * @returns this effect.
  93093. */
  93094. setFloat(uniformName: string, value: number): Effect;
  93095. /**
  93096. * Sets a boolean on a uniform variable.
  93097. * @param uniformName Name of the variable.
  93098. * @param bool value to be set.
  93099. * @returns this effect.
  93100. */
  93101. setBool(uniformName: string, bool: boolean): Effect;
  93102. /**
  93103. * Sets a Vector2 on a uniform variable.
  93104. * @param uniformName Name of the variable.
  93105. * @param vector2 vector2 to be set.
  93106. * @returns this effect.
  93107. */
  93108. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93109. /**
  93110. * Sets a float2 on a uniform variable.
  93111. * @param uniformName Name of the variable.
  93112. * @param x First float in float2.
  93113. * @param y Second float in float2.
  93114. * @returns this effect.
  93115. */
  93116. setFloat2(uniformName: string, x: number, y: number): Effect;
  93117. /**
  93118. * Sets a Vector3 on a uniform variable.
  93119. * @param uniformName Name of the variable.
  93120. * @param vector3 Value to be set.
  93121. * @returns this effect.
  93122. */
  93123. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93124. /**
  93125. * Sets a float3 on a uniform variable.
  93126. * @param uniformName Name of the variable.
  93127. * @param x First float in float3.
  93128. * @param y Second float in float3.
  93129. * @param z Third float in float3.
  93130. * @returns this effect.
  93131. */
  93132. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93133. /**
  93134. * Sets a Vector4 on a uniform variable.
  93135. * @param uniformName Name of the variable.
  93136. * @param vector4 Value to be set.
  93137. * @returns this effect.
  93138. */
  93139. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93140. /**
  93141. * Sets a float4 on a uniform variable.
  93142. * @param uniformName Name of the variable.
  93143. * @param x First float in float4.
  93144. * @param y Second float in float4.
  93145. * @param z Third float in float4.
  93146. * @param w Fourth float in float4.
  93147. * @returns this effect.
  93148. */
  93149. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93150. /**
  93151. * Sets a Color3 on a uniform variable.
  93152. * @param uniformName Name of the variable.
  93153. * @param color3 Value to be set.
  93154. * @returns this effect.
  93155. */
  93156. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93157. /**
  93158. * Sets a Color4 on a uniform variable.
  93159. * @param uniformName Name of the variable.
  93160. * @param color3 Value to be set.
  93161. * @param alpha Alpha value to be set.
  93162. * @returns this effect.
  93163. */
  93164. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93165. /**
  93166. * Sets a Color4 on a uniform variable
  93167. * @param uniformName defines the name of the variable
  93168. * @param color4 defines the value to be set
  93169. * @returns this effect.
  93170. */
  93171. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93172. /** Release all associated resources */
  93173. dispose(): void;
  93174. /**
  93175. * This function will add a new shader to the shader store
  93176. * @param name the name of the shader
  93177. * @param pixelShader optional pixel shader content
  93178. * @param vertexShader optional vertex shader content
  93179. */
  93180. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93181. /**
  93182. * Store of each shader (The can be looked up using effect.key)
  93183. */
  93184. static ShadersStore: {
  93185. [key: string]: string;
  93186. };
  93187. /**
  93188. * Store of each included file for a shader (The can be looked up using effect.key)
  93189. */
  93190. static IncludesShadersStore: {
  93191. [key: string]: string;
  93192. };
  93193. /**
  93194. * Resets the cache of effects.
  93195. */
  93196. static ResetCache(): void;
  93197. }
  93198. }
  93199. declare module BABYLON {
  93200. /**
  93201. * Uniform buffer objects.
  93202. *
  93203. * Handles blocks of uniform on the GPU.
  93204. *
  93205. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93206. *
  93207. * For more information, please refer to :
  93208. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93209. */
  93210. export class UniformBuffer {
  93211. private _engine;
  93212. private _buffer;
  93213. private _data;
  93214. private _bufferData;
  93215. private _dynamic?;
  93216. private _uniformLocations;
  93217. private _uniformSizes;
  93218. private _uniformLocationPointer;
  93219. private _needSync;
  93220. private _noUBO;
  93221. private _currentEffect;
  93222. private static _MAX_UNIFORM_SIZE;
  93223. private static _tempBuffer;
  93224. /**
  93225. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93226. * This is dynamic to allow compat with webgl 1 and 2.
  93227. * You will need to pass the name of the uniform as well as the value.
  93228. */
  93229. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93230. /**
  93231. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93232. * This is dynamic to allow compat with webgl 1 and 2.
  93233. * You will need to pass the name of the uniform as well as the value.
  93234. */
  93235. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93236. /**
  93237. * Lambda to Update a single float in a uniform buffer.
  93238. * This is dynamic to allow compat with webgl 1 and 2.
  93239. * You will need to pass the name of the uniform as well as the value.
  93240. */
  93241. updateFloat: (name: string, x: number) => void;
  93242. /**
  93243. * Lambda to Update a vec2 of float in a uniform buffer.
  93244. * This is dynamic to allow compat with webgl 1 and 2.
  93245. * You will need to pass the name of the uniform as well as the value.
  93246. */
  93247. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93248. /**
  93249. * Lambda to Update a vec3 of float in a uniform buffer.
  93250. * This is dynamic to allow compat with webgl 1 and 2.
  93251. * You will need to pass the name of the uniform as well as the value.
  93252. */
  93253. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93254. /**
  93255. * Lambda to Update a vec4 of float in a uniform buffer.
  93256. * This is dynamic to allow compat with webgl 1 and 2.
  93257. * You will need to pass the name of the uniform as well as the value.
  93258. */
  93259. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93260. /**
  93261. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93262. * This is dynamic to allow compat with webgl 1 and 2.
  93263. * You will need to pass the name of the uniform as well as the value.
  93264. */
  93265. updateMatrix: (name: string, mat: Matrix) => void;
  93266. /**
  93267. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93268. * This is dynamic to allow compat with webgl 1 and 2.
  93269. * You will need to pass the name of the uniform as well as the value.
  93270. */
  93271. updateVector3: (name: string, vector: Vector3) => void;
  93272. /**
  93273. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93274. * This is dynamic to allow compat with webgl 1 and 2.
  93275. * You will need to pass the name of the uniform as well as the value.
  93276. */
  93277. updateVector4: (name: string, vector: Vector4) => void;
  93278. /**
  93279. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93280. * This is dynamic to allow compat with webgl 1 and 2.
  93281. * You will need to pass the name of the uniform as well as the value.
  93282. */
  93283. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93284. /**
  93285. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93286. * This is dynamic to allow compat with webgl 1 and 2.
  93287. * You will need to pass the name of the uniform as well as the value.
  93288. */
  93289. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93290. /**
  93291. * Instantiates a new Uniform buffer objects.
  93292. *
  93293. * Handles blocks of uniform on the GPU.
  93294. *
  93295. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93296. *
  93297. * For more information, please refer to :
  93298. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93299. * @param engine Define the engine the buffer is associated with
  93300. * @param data Define the data contained in the buffer
  93301. * @param dynamic Define if the buffer is updatable
  93302. */
  93303. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93304. /**
  93305. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93306. * or just falling back on setUniformXXX calls.
  93307. */
  93308. readonly useUbo: boolean;
  93309. /**
  93310. * Indicates if the WebGL underlying uniform buffer is in sync
  93311. * with the javascript cache data.
  93312. */
  93313. readonly isSync: boolean;
  93314. /**
  93315. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93316. * Also, a dynamic UniformBuffer will disable cache verification and always
  93317. * update the underlying WebGL uniform buffer to the GPU.
  93318. * @returns if Dynamic, otherwise false
  93319. */
  93320. isDynamic(): boolean;
  93321. /**
  93322. * The data cache on JS side.
  93323. * @returns the underlying data as a float array
  93324. */
  93325. getData(): Float32Array;
  93326. /**
  93327. * The underlying WebGL Uniform buffer.
  93328. * @returns the webgl buffer
  93329. */
  93330. getBuffer(): Nullable<DataBuffer>;
  93331. /**
  93332. * std140 layout specifies how to align data within an UBO structure.
  93333. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93334. * for specs.
  93335. */
  93336. private _fillAlignment;
  93337. /**
  93338. * Adds an uniform in the buffer.
  93339. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93340. * for the layout to be correct !
  93341. * @param name Name of the uniform, as used in the uniform block in the shader.
  93342. * @param size Data size, or data directly.
  93343. */
  93344. addUniform(name: string, size: number | number[]): void;
  93345. /**
  93346. * Adds a Matrix 4x4 to the uniform buffer.
  93347. * @param name Name of the uniform, as used in the uniform block in the shader.
  93348. * @param mat A 4x4 matrix.
  93349. */
  93350. addMatrix(name: string, mat: Matrix): void;
  93351. /**
  93352. * Adds a vec2 to the uniform buffer.
  93353. * @param name Name of the uniform, as used in the uniform block in the shader.
  93354. * @param x Define the x component value of the vec2
  93355. * @param y Define the y component value of the vec2
  93356. */
  93357. addFloat2(name: string, x: number, y: number): void;
  93358. /**
  93359. * Adds a vec3 to the uniform buffer.
  93360. * @param name Name of the uniform, as used in the uniform block in the shader.
  93361. * @param x Define the x component value of the vec3
  93362. * @param y Define the y component value of the vec3
  93363. * @param z Define the z component value of the vec3
  93364. */
  93365. addFloat3(name: string, x: number, y: number, z: number): void;
  93366. /**
  93367. * Adds a vec3 to the uniform buffer.
  93368. * @param name Name of the uniform, as used in the uniform block in the shader.
  93369. * @param color Define the vec3 from a Color
  93370. */
  93371. addColor3(name: string, color: Color3): void;
  93372. /**
  93373. * Adds a vec4 to the uniform buffer.
  93374. * @param name Name of the uniform, as used in the uniform block in the shader.
  93375. * @param color Define the rgb components from a Color
  93376. * @param alpha Define the a component of the vec4
  93377. */
  93378. addColor4(name: string, color: Color3, alpha: number): void;
  93379. /**
  93380. * Adds a vec3 to the uniform buffer.
  93381. * @param name Name of the uniform, as used in the uniform block in the shader.
  93382. * @param vector Define the vec3 components from a Vector
  93383. */
  93384. addVector3(name: string, vector: Vector3): void;
  93385. /**
  93386. * Adds a Matrix 3x3 to the uniform buffer.
  93387. * @param name Name of the uniform, as used in the uniform block in the shader.
  93388. */
  93389. addMatrix3x3(name: string): void;
  93390. /**
  93391. * Adds a Matrix 2x2 to the uniform buffer.
  93392. * @param name Name of the uniform, as used in the uniform block in the shader.
  93393. */
  93394. addMatrix2x2(name: string): void;
  93395. /**
  93396. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93397. */
  93398. create(): void;
  93399. /** @hidden */
  93400. _rebuild(): void;
  93401. /**
  93402. * Updates the WebGL Uniform Buffer on the GPU.
  93403. * If the `dynamic` flag is set to true, no cache comparison is done.
  93404. * Otherwise, the buffer will be updated only if the cache differs.
  93405. */
  93406. update(): void;
  93407. /**
  93408. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93409. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93410. * @param data Define the flattened data
  93411. * @param size Define the size of the data.
  93412. */
  93413. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93414. private _updateMatrix3x3ForUniform;
  93415. private _updateMatrix3x3ForEffect;
  93416. private _updateMatrix2x2ForEffect;
  93417. private _updateMatrix2x2ForUniform;
  93418. private _updateFloatForEffect;
  93419. private _updateFloatForUniform;
  93420. private _updateFloat2ForEffect;
  93421. private _updateFloat2ForUniform;
  93422. private _updateFloat3ForEffect;
  93423. private _updateFloat3ForUniform;
  93424. private _updateFloat4ForEffect;
  93425. private _updateFloat4ForUniform;
  93426. private _updateMatrixForEffect;
  93427. private _updateMatrixForUniform;
  93428. private _updateVector3ForEffect;
  93429. private _updateVector3ForUniform;
  93430. private _updateVector4ForEffect;
  93431. private _updateVector4ForUniform;
  93432. private _updateColor3ForEffect;
  93433. private _updateColor3ForUniform;
  93434. private _updateColor4ForEffect;
  93435. private _updateColor4ForUniform;
  93436. /**
  93437. * Sets a sampler uniform on the effect.
  93438. * @param name Define the name of the sampler.
  93439. * @param texture Define the texture to set in the sampler
  93440. */
  93441. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93442. /**
  93443. * Directly updates the value of the uniform in the cache AND on the GPU.
  93444. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93445. * @param data Define the flattened data
  93446. */
  93447. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93448. /**
  93449. * Binds this uniform buffer to an effect.
  93450. * @param effect Define the effect to bind the buffer to
  93451. * @param name Name of the uniform block in the shader.
  93452. */
  93453. bindToEffect(effect: Effect, name: string): void;
  93454. /**
  93455. * Disposes the uniform buffer.
  93456. */
  93457. dispose(): void;
  93458. }
  93459. }
  93460. declare module BABYLON {
  93461. /**
  93462. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93464. */
  93465. export class Analyser {
  93466. /**
  93467. * Gets or sets the smoothing
  93468. * @ignorenaming
  93469. */
  93470. SMOOTHING: number;
  93471. /**
  93472. * Gets or sets the FFT table size
  93473. * @ignorenaming
  93474. */
  93475. FFT_SIZE: number;
  93476. /**
  93477. * Gets or sets the bar graph amplitude
  93478. * @ignorenaming
  93479. */
  93480. BARGRAPHAMPLITUDE: number;
  93481. /**
  93482. * Gets or sets the position of the debug canvas
  93483. * @ignorenaming
  93484. */
  93485. DEBUGCANVASPOS: {
  93486. x: number;
  93487. y: number;
  93488. };
  93489. /**
  93490. * Gets or sets the debug canvas size
  93491. * @ignorenaming
  93492. */
  93493. DEBUGCANVASSIZE: {
  93494. width: number;
  93495. height: number;
  93496. };
  93497. private _byteFreqs;
  93498. private _byteTime;
  93499. private _floatFreqs;
  93500. private _webAudioAnalyser;
  93501. private _debugCanvas;
  93502. private _debugCanvasContext;
  93503. private _scene;
  93504. private _registerFunc;
  93505. private _audioEngine;
  93506. /**
  93507. * Creates a new analyser
  93508. * @param scene defines hosting scene
  93509. */
  93510. constructor(scene: Scene);
  93511. /**
  93512. * Get the number of data values you will have to play with for the visualization
  93513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93514. * @returns a number
  93515. */
  93516. getFrequencyBinCount(): number;
  93517. /**
  93518. * Gets the current frequency data as a byte array
  93519. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93520. * @returns a Uint8Array
  93521. */
  93522. getByteFrequencyData(): Uint8Array;
  93523. /**
  93524. * Gets the current waveform as a byte array
  93525. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93526. * @returns a Uint8Array
  93527. */
  93528. getByteTimeDomainData(): Uint8Array;
  93529. /**
  93530. * Gets the current frequency data as a float array
  93531. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93532. * @returns a Float32Array
  93533. */
  93534. getFloatFrequencyData(): Float32Array;
  93535. /**
  93536. * Renders the debug canvas
  93537. */
  93538. drawDebugCanvas(): void;
  93539. /**
  93540. * Stops rendering the debug canvas and removes it
  93541. */
  93542. stopDebugCanvas(): void;
  93543. /**
  93544. * Connects two audio nodes
  93545. * @param inputAudioNode defines first node to connect
  93546. * @param outputAudioNode defines second node to connect
  93547. */
  93548. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93549. /**
  93550. * Releases all associated resources
  93551. */
  93552. dispose(): void;
  93553. }
  93554. }
  93555. declare module BABYLON {
  93556. /**
  93557. * This represents an audio engine and it is responsible
  93558. * to play, synchronize and analyse sounds throughout the application.
  93559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93560. */
  93561. export interface IAudioEngine extends IDisposable {
  93562. /**
  93563. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93564. */
  93565. readonly canUseWebAudio: boolean;
  93566. /**
  93567. * Gets the current AudioContext if available.
  93568. */
  93569. readonly audioContext: Nullable<AudioContext>;
  93570. /**
  93571. * The master gain node defines the global audio volume of your audio engine.
  93572. */
  93573. readonly masterGain: GainNode;
  93574. /**
  93575. * Gets whether or not mp3 are supported by your browser.
  93576. */
  93577. readonly isMP3supported: boolean;
  93578. /**
  93579. * Gets whether or not ogg are supported by your browser.
  93580. */
  93581. readonly isOGGsupported: boolean;
  93582. /**
  93583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93584. * @ignoreNaming
  93585. */
  93586. WarnedWebAudioUnsupported: boolean;
  93587. /**
  93588. * Defines if the audio engine relies on a custom unlocked button.
  93589. * In this case, the embedded button will not be displayed.
  93590. */
  93591. useCustomUnlockedButton: boolean;
  93592. /**
  93593. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93594. */
  93595. readonly unlocked: boolean;
  93596. /**
  93597. * Event raised when audio has been unlocked on the browser.
  93598. */
  93599. onAudioUnlockedObservable: Observable<AudioEngine>;
  93600. /**
  93601. * Event raised when audio has been locked on the browser.
  93602. */
  93603. onAudioLockedObservable: Observable<AudioEngine>;
  93604. /**
  93605. * Flags the audio engine in Locked state.
  93606. * This happens due to new browser policies preventing audio to autoplay.
  93607. */
  93608. lock(): void;
  93609. /**
  93610. * Unlocks the audio engine once a user action has been done on the dom.
  93611. * This is helpful to resume play once browser policies have been satisfied.
  93612. */
  93613. unlock(): void;
  93614. }
  93615. /**
  93616. * This represents the default audio engine used in babylon.
  93617. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93619. */
  93620. export class AudioEngine implements IAudioEngine {
  93621. private _audioContext;
  93622. private _audioContextInitialized;
  93623. private _muteButton;
  93624. private _hostElement;
  93625. /**
  93626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93627. */
  93628. canUseWebAudio: boolean;
  93629. /**
  93630. * The master gain node defines the global audio volume of your audio engine.
  93631. */
  93632. masterGain: GainNode;
  93633. /**
  93634. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93635. * @ignoreNaming
  93636. */
  93637. WarnedWebAudioUnsupported: boolean;
  93638. /**
  93639. * Gets whether or not mp3 are supported by your browser.
  93640. */
  93641. isMP3supported: boolean;
  93642. /**
  93643. * Gets whether or not ogg are supported by your browser.
  93644. */
  93645. isOGGsupported: boolean;
  93646. /**
  93647. * Gets whether audio has been unlocked on the device.
  93648. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93649. * a user interaction has happened.
  93650. */
  93651. unlocked: boolean;
  93652. /**
  93653. * Defines if the audio engine relies on a custom unlocked button.
  93654. * In this case, the embedded button will not be displayed.
  93655. */
  93656. useCustomUnlockedButton: boolean;
  93657. /**
  93658. * Event raised when audio has been unlocked on the browser.
  93659. */
  93660. onAudioUnlockedObservable: Observable<AudioEngine>;
  93661. /**
  93662. * Event raised when audio has been locked on the browser.
  93663. */
  93664. onAudioLockedObservable: Observable<AudioEngine>;
  93665. /**
  93666. * Gets the current AudioContext if available.
  93667. */
  93668. readonly audioContext: Nullable<AudioContext>;
  93669. private _connectedAnalyser;
  93670. /**
  93671. * Instantiates a new audio engine.
  93672. *
  93673. * There should be only one per page as some browsers restrict the number
  93674. * of audio contexts you can create.
  93675. * @param hostElement defines the host element where to display the mute icon if necessary
  93676. */
  93677. constructor(hostElement?: Nullable<HTMLElement>);
  93678. /**
  93679. * Flags the audio engine in Locked state.
  93680. * This happens due to new browser policies preventing audio to autoplay.
  93681. */
  93682. lock(): void;
  93683. /**
  93684. * Unlocks the audio engine once a user action has been done on the dom.
  93685. * This is helpful to resume play once browser policies have been satisfied.
  93686. */
  93687. unlock(): void;
  93688. private _resumeAudioContext;
  93689. private _initializeAudioContext;
  93690. private _tryToRun;
  93691. private _triggerRunningState;
  93692. private _triggerSuspendedState;
  93693. private _displayMuteButton;
  93694. private _moveButtonToTopLeft;
  93695. private _onResize;
  93696. private _hideMuteButton;
  93697. /**
  93698. * Destroy and release the resources associated with the audio ccontext.
  93699. */
  93700. dispose(): void;
  93701. /**
  93702. * Gets the global volume sets on the master gain.
  93703. * @returns the global volume if set or -1 otherwise
  93704. */
  93705. getGlobalVolume(): number;
  93706. /**
  93707. * Sets the global volume of your experience (sets on the master gain).
  93708. * @param newVolume Defines the new global volume of the application
  93709. */
  93710. setGlobalVolume(newVolume: number): void;
  93711. /**
  93712. * Connect the audio engine to an audio analyser allowing some amazing
  93713. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93715. * @param analyser The analyser to connect to the engine
  93716. */
  93717. connectToAnalyser(analyser: Analyser): void;
  93718. }
  93719. }
  93720. declare module BABYLON {
  93721. /**
  93722. * Interface used to present a loading screen while loading a scene
  93723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93724. */
  93725. export interface ILoadingScreen {
  93726. /**
  93727. * Function called to display the loading screen
  93728. */
  93729. displayLoadingUI: () => void;
  93730. /**
  93731. * Function called to hide the loading screen
  93732. */
  93733. hideLoadingUI: () => void;
  93734. /**
  93735. * Gets or sets the color to use for the background
  93736. */
  93737. loadingUIBackgroundColor: string;
  93738. /**
  93739. * Gets or sets the text to display while loading
  93740. */
  93741. loadingUIText: string;
  93742. }
  93743. /**
  93744. * Class used for the default loading screen
  93745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93746. */
  93747. export class DefaultLoadingScreen implements ILoadingScreen {
  93748. private _renderingCanvas;
  93749. private _loadingText;
  93750. private _loadingDivBackgroundColor;
  93751. private _loadingDiv;
  93752. private _loadingTextDiv;
  93753. /** Gets or sets the logo url to use for the default loading screen */
  93754. static DefaultLogoUrl: string;
  93755. /** Gets or sets the spinner url to use for the default loading screen */
  93756. static DefaultSpinnerUrl: string;
  93757. /**
  93758. * Creates a new default loading screen
  93759. * @param _renderingCanvas defines the canvas used to render the scene
  93760. * @param _loadingText defines the default text to display
  93761. * @param _loadingDivBackgroundColor defines the default background color
  93762. */
  93763. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93764. /**
  93765. * Function called to display the loading screen
  93766. */
  93767. displayLoadingUI(): void;
  93768. /**
  93769. * Function called to hide the loading screen
  93770. */
  93771. hideLoadingUI(): void;
  93772. /**
  93773. * Gets or sets the text to display while loading
  93774. */
  93775. loadingUIText: string;
  93776. /**
  93777. * Gets or sets the color to use for the background
  93778. */
  93779. loadingUIBackgroundColor: string;
  93780. private _resizeLoadingUI;
  93781. }
  93782. }
  93783. declare module BABYLON {
  93784. /** @hidden */
  93785. export class WebGLPipelineContext implements IPipelineContext {
  93786. engine: Engine;
  93787. program: Nullable<WebGLProgram>;
  93788. context?: WebGLRenderingContext;
  93789. vertexShader?: WebGLShader;
  93790. fragmentShader?: WebGLShader;
  93791. isParallelCompiled: boolean;
  93792. onCompiled?: () => void;
  93793. transformFeedback?: WebGLTransformFeedback | null;
  93794. readonly isAsync: boolean;
  93795. readonly isReady: boolean;
  93796. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93797. }
  93798. }
  93799. declare module BABYLON {
  93800. /** @hidden */
  93801. export class WebGLDataBuffer extends DataBuffer {
  93802. private _buffer;
  93803. constructor(resource: WebGLBuffer);
  93804. readonly underlyingResource: any;
  93805. }
  93806. }
  93807. declare module BABYLON {
  93808. /** @hidden */
  93809. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93810. attributeProcessor(attribute: string): string;
  93811. varyingProcessor(varying: string, isFragment: boolean): string;
  93812. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /**
  93817. * This class is used to track a performance counter which is number based.
  93818. * The user has access to many properties which give statistics of different nature.
  93819. *
  93820. * The implementer can track two kinds of Performance Counter: time and count.
  93821. * 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.
  93822. * 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.
  93823. */
  93824. export class PerfCounter {
  93825. /**
  93826. * Gets or sets a global boolean to turn on and off all the counters
  93827. */
  93828. static Enabled: boolean;
  93829. /**
  93830. * Returns the smallest value ever
  93831. */
  93832. readonly min: number;
  93833. /**
  93834. * Returns the biggest value ever
  93835. */
  93836. readonly max: number;
  93837. /**
  93838. * Returns the average value since the performance counter is running
  93839. */
  93840. readonly average: number;
  93841. /**
  93842. * Returns the average value of the last second the counter was monitored
  93843. */
  93844. readonly lastSecAverage: number;
  93845. /**
  93846. * Returns the current value
  93847. */
  93848. readonly current: number;
  93849. /**
  93850. * Gets the accumulated total
  93851. */
  93852. readonly total: number;
  93853. /**
  93854. * Gets the total value count
  93855. */
  93856. readonly count: number;
  93857. /**
  93858. * Creates a new counter
  93859. */
  93860. constructor();
  93861. /**
  93862. * Call this method to start monitoring a new frame.
  93863. * 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.
  93864. */
  93865. fetchNewFrame(): void;
  93866. /**
  93867. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93868. * @param newCount the count value to add to the monitored count
  93869. * @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.
  93870. */
  93871. addCount(newCount: number, fetchResult: boolean): void;
  93872. /**
  93873. * Start monitoring this performance counter
  93874. */
  93875. beginMonitoring(): void;
  93876. /**
  93877. * Compute the time lapsed since the previous beginMonitoring() call.
  93878. * @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
  93879. */
  93880. endMonitoring(newFrame?: boolean): void;
  93881. private _fetchResult;
  93882. private _startMonitoringTime;
  93883. private _min;
  93884. private _max;
  93885. private _average;
  93886. private _current;
  93887. private _totalValueCount;
  93888. private _totalAccumulated;
  93889. private _lastSecAverage;
  93890. private _lastSecAccumulated;
  93891. private _lastSecTime;
  93892. private _lastSecValueCount;
  93893. }
  93894. }
  93895. declare module BABYLON {
  93896. /**
  93897. * Interface for any object that can request an animation frame
  93898. */
  93899. export interface ICustomAnimationFrameRequester {
  93900. /**
  93901. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93902. */
  93903. renderFunction?: Function;
  93904. /**
  93905. * Called to request the next frame to render to
  93906. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93907. */
  93908. requestAnimationFrame: Function;
  93909. /**
  93910. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93911. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93912. */
  93913. requestID?: number;
  93914. }
  93915. }
  93916. declare module BABYLON {
  93917. /**
  93918. * Settings for finer control over video usage
  93919. */
  93920. export interface VideoTextureSettings {
  93921. /**
  93922. * Applies `autoplay` to video, if specified
  93923. */
  93924. autoPlay?: boolean;
  93925. /**
  93926. * Applies `loop` to video, if specified
  93927. */
  93928. loop?: boolean;
  93929. /**
  93930. * Automatically updates internal texture from video at every frame in the render loop
  93931. */
  93932. autoUpdateTexture: boolean;
  93933. /**
  93934. * Image src displayed during the video loading or until the user interacts with the video.
  93935. */
  93936. poster?: string;
  93937. }
  93938. /**
  93939. * If you want to display a video in your scene, this is the special texture for that.
  93940. * This special texture works similar to other textures, with the exception of a few parameters.
  93941. * @see https://doc.babylonjs.com/how_to/video_texture
  93942. */
  93943. export class VideoTexture extends Texture {
  93944. /**
  93945. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93946. */
  93947. readonly autoUpdateTexture: boolean;
  93948. /**
  93949. * The video instance used by the texture internally
  93950. */
  93951. readonly video: HTMLVideoElement;
  93952. private _onUserActionRequestedObservable;
  93953. /**
  93954. * Event triggerd when a dom action is required by the user to play the video.
  93955. * This happens due to recent changes in browser policies preventing video to auto start.
  93956. */
  93957. readonly onUserActionRequestedObservable: Observable<Texture>;
  93958. private _generateMipMaps;
  93959. private _engine;
  93960. private _stillImageCaptured;
  93961. private _displayingPosterTexture;
  93962. private _settings;
  93963. private _createInternalTextureOnEvent;
  93964. /**
  93965. * Creates a video texture.
  93966. * If you want to display a video in your scene, this is the special texture for that.
  93967. * This special texture works similar to other textures, with the exception of a few parameters.
  93968. * @see https://doc.babylonjs.com/how_to/video_texture
  93969. * @param name optional name, will detect from video source, if not defined
  93970. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93971. * @param scene is obviously the current scene.
  93972. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93973. * @param invertY is false by default but can be used to invert video on Y axis
  93974. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93975. * @param settings allows finer control over video usage
  93976. */
  93977. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93978. private _getName;
  93979. private _getVideo;
  93980. private _createInternalTexture;
  93981. private reset;
  93982. /**
  93983. * @hidden Internal method to initiate `update`.
  93984. */
  93985. _rebuild(): void;
  93986. /**
  93987. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93988. */
  93989. update(): void;
  93990. /**
  93991. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93992. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93993. */
  93994. updateTexture(isVisible: boolean): void;
  93995. protected _updateInternalTexture: () => void;
  93996. /**
  93997. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93998. * @param url New url.
  93999. */
  94000. updateURL(url: string): void;
  94001. /**
  94002. * Dispose the texture and release its associated resources.
  94003. */
  94004. dispose(): void;
  94005. /**
  94006. * Creates a video texture straight from a stream.
  94007. * @param scene Define the scene the texture should be created in
  94008. * @param stream Define the stream the texture should be created from
  94009. * @returns The created video texture as a promise
  94010. */
  94011. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94012. /**
  94013. * Creates a video texture straight from your WebCam video feed.
  94014. * @param scene Define the scene the texture should be created in
  94015. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94016. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94017. * @returns The created video texture as a promise
  94018. */
  94019. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94020. minWidth: number;
  94021. maxWidth: number;
  94022. minHeight: number;
  94023. maxHeight: number;
  94024. deviceId: string;
  94025. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94026. /**
  94027. * Creates a video texture straight from your WebCam video feed.
  94028. * @param scene Define the scene the texture should be created in
  94029. * @param onReady Define a callback to triggered once the texture will be ready
  94030. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94031. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94032. */
  94033. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94034. minWidth: number;
  94035. maxWidth: number;
  94036. minHeight: number;
  94037. maxHeight: number;
  94038. deviceId: string;
  94039. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94040. }
  94041. }
  94042. declare module BABYLON {
  94043. /**
  94044. * Defines the interface used by objects containing a viewport (like a camera)
  94045. */
  94046. interface IViewportOwnerLike {
  94047. /**
  94048. * Gets or sets the viewport
  94049. */
  94050. viewport: IViewportLike;
  94051. }
  94052. /**
  94053. * Interface for attribute information associated with buffer instanciation
  94054. */
  94055. export class InstancingAttributeInfo {
  94056. /**
  94057. * Index/offset of the attribute in the vertex shader
  94058. */
  94059. index: number;
  94060. /**
  94061. * size of the attribute, 1, 2, 3 or 4
  94062. */
  94063. attributeSize: number;
  94064. /**
  94065. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94066. * default is FLOAT
  94067. */
  94068. attribyteType: number;
  94069. /**
  94070. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94071. */
  94072. normalized: boolean;
  94073. /**
  94074. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94075. */
  94076. offset: number;
  94077. /**
  94078. * Name of the GLSL attribute, for debugging purpose only
  94079. */
  94080. attributeName: string;
  94081. }
  94082. /**
  94083. * Define options used to create a depth texture
  94084. */
  94085. export class DepthTextureCreationOptions {
  94086. /** Specifies whether or not a stencil should be allocated in the texture */
  94087. generateStencil?: boolean;
  94088. /** Specifies whether or not bilinear filtering is enable on the texture */
  94089. bilinearFiltering?: boolean;
  94090. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94091. comparisonFunction?: number;
  94092. /** Specifies if the created texture is a cube texture */
  94093. isCube?: boolean;
  94094. }
  94095. /**
  94096. * Class used to describe the capabilities of the engine relatively to the current browser
  94097. */
  94098. export class EngineCapabilities {
  94099. /** Maximum textures units per fragment shader */
  94100. maxTexturesImageUnits: number;
  94101. /** Maximum texture units per vertex shader */
  94102. maxVertexTextureImageUnits: number;
  94103. /** Maximum textures units in the entire pipeline */
  94104. maxCombinedTexturesImageUnits: number;
  94105. /** Maximum texture size */
  94106. maxTextureSize: number;
  94107. /** Maximum cube texture size */
  94108. maxCubemapTextureSize: number;
  94109. /** Maximum render texture size */
  94110. maxRenderTextureSize: number;
  94111. /** Maximum number of vertex attributes */
  94112. maxVertexAttribs: number;
  94113. /** Maximum number of varyings */
  94114. maxVaryingVectors: number;
  94115. /** Maximum number of uniforms per vertex shader */
  94116. maxVertexUniformVectors: number;
  94117. /** Maximum number of uniforms per fragment shader */
  94118. maxFragmentUniformVectors: number;
  94119. /** Defines if standard derivates (dx/dy) are supported */
  94120. standardDerivatives: boolean;
  94121. /** Defines if s3tc texture compression is supported */
  94122. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94123. /** Defines if pvrtc texture compression is supported */
  94124. pvrtc: any;
  94125. /** Defines if etc1 texture compression is supported */
  94126. etc1: any;
  94127. /** Defines if etc2 texture compression is supported */
  94128. etc2: any;
  94129. /** Defines if astc texture compression is supported */
  94130. astc: any;
  94131. /** Defines if float textures are supported */
  94132. textureFloat: boolean;
  94133. /** Defines if vertex array objects are supported */
  94134. vertexArrayObject: boolean;
  94135. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94136. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94137. /** Gets the maximum level of anisotropy supported */
  94138. maxAnisotropy: number;
  94139. /** Defines if instancing is supported */
  94140. instancedArrays: boolean;
  94141. /** Defines if 32 bits indices are supported */
  94142. uintIndices: boolean;
  94143. /** Defines if high precision shaders are supported */
  94144. highPrecisionShaderSupported: boolean;
  94145. /** Defines if depth reading in the fragment shader is supported */
  94146. fragmentDepthSupported: boolean;
  94147. /** Defines if float texture linear filtering is supported*/
  94148. textureFloatLinearFiltering: boolean;
  94149. /** Defines if rendering to float textures is supported */
  94150. textureFloatRender: boolean;
  94151. /** Defines if half float textures are supported*/
  94152. textureHalfFloat: boolean;
  94153. /** Defines if half float texture linear filtering is supported*/
  94154. textureHalfFloatLinearFiltering: boolean;
  94155. /** Defines if rendering to half float textures is supported */
  94156. textureHalfFloatRender: boolean;
  94157. /** Defines if textureLOD shader command is supported */
  94158. textureLOD: boolean;
  94159. /** Defines if draw buffers extension is supported */
  94160. drawBuffersExtension: boolean;
  94161. /** Defines if depth textures are supported */
  94162. depthTextureExtension: boolean;
  94163. /** Defines if float color buffer are supported */
  94164. colorBufferFloat: boolean;
  94165. /** Gets disjoint timer query extension (null if not supported) */
  94166. timerQuery: EXT_disjoint_timer_query;
  94167. /** Defines if timestamp can be used with timer query */
  94168. canUseTimestampForTimerQuery: boolean;
  94169. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94170. multiview: any;
  94171. /** Function used to let the system compiles shaders in background */
  94172. parallelShaderCompile: {
  94173. COMPLETION_STATUS_KHR: number;
  94174. };
  94175. /** Max number of texture samples for MSAA */
  94176. maxMSAASamples: number;
  94177. }
  94178. /** Interface defining initialization parameters for Engine class */
  94179. export interface EngineOptions extends WebGLContextAttributes {
  94180. /**
  94181. * Defines if the engine should no exceed a specified device ratio
  94182. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94183. */
  94184. limitDeviceRatio?: number;
  94185. /**
  94186. * Defines if webvr should be enabled automatically
  94187. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94188. */
  94189. autoEnableWebVR?: boolean;
  94190. /**
  94191. * Defines if webgl2 should be turned off even if supported
  94192. * @see http://doc.babylonjs.com/features/webgl2
  94193. */
  94194. disableWebGL2Support?: boolean;
  94195. /**
  94196. * Defines if webaudio should be initialized as well
  94197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94198. */
  94199. audioEngine?: boolean;
  94200. /**
  94201. * Defines if animations should run using a deterministic lock step
  94202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94203. */
  94204. deterministicLockstep?: boolean;
  94205. /** Defines the maximum steps to use with deterministic lock step mode */
  94206. lockstepMaxSteps?: number;
  94207. /**
  94208. * Defines that engine should ignore context lost events
  94209. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94210. */
  94211. doNotHandleContextLost?: boolean;
  94212. /**
  94213. * Defines that engine should ignore modifying touch action attribute and style
  94214. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94215. */
  94216. doNotHandleTouchAction?: boolean;
  94217. /**
  94218. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94219. */
  94220. useHighPrecisionFloats?: boolean;
  94221. }
  94222. /**
  94223. * Defines the interface used by display changed events
  94224. */
  94225. export interface IDisplayChangedEventArgs {
  94226. /** Gets the vrDisplay object (if any) */
  94227. vrDisplay: Nullable<any>;
  94228. /** Gets a boolean indicating if webVR is supported */
  94229. vrSupported: boolean;
  94230. }
  94231. /**
  94232. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94233. */
  94234. export class Engine {
  94235. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94236. static ExceptionList: ({
  94237. key: string;
  94238. capture: string;
  94239. captureConstraint: number;
  94240. targets: string[];
  94241. } | {
  94242. key: string;
  94243. capture: null;
  94244. captureConstraint: null;
  94245. targets: string[];
  94246. })[];
  94247. /** Gets the list of created engines */
  94248. static readonly Instances: Engine[];
  94249. /**
  94250. * Gets the latest created engine
  94251. */
  94252. static readonly LastCreatedEngine: Nullable<Engine>;
  94253. /**
  94254. * Gets the latest created scene
  94255. */
  94256. static readonly LastCreatedScene: Nullable<Scene>;
  94257. /**
  94258. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94259. * @param flag defines which part of the materials must be marked as dirty
  94260. * @param predicate defines a predicate used to filter which materials should be affected
  94261. */
  94262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94263. /** @hidden */
  94264. static _TextureLoaders: IInternalTextureLoader[];
  94265. /** Defines that alpha blending is disabled */
  94266. static readonly ALPHA_DISABLE: number;
  94267. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94268. static readonly ALPHA_ADD: number;
  94269. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94270. static readonly ALPHA_COMBINE: number;
  94271. /** Defines that alpha blending to DEST - SRC * DEST */
  94272. static readonly ALPHA_SUBTRACT: number;
  94273. /** Defines that alpha blending to SRC * DEST */
  94274. static readonly ALPHA_MULTIPLY: number;
  94275. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94276. static readonly ALPHA_MAXIMIZED: number;
  94277. /** Defines that alpha blending to SRC + DEST */
  94278. static readonly ALPHA_ONEONE: number;
  94279. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94280. static readonly ALPHA_PREMULTIPLIED: number;
  94281. /**
  94282. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94283. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94284. */
  94285. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94286. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94287. static readonly ALPHA_INTERPOLATE: number;
  94288. /**
  94289. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94290. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94291. */
  94292. static readonly ALPHA_SCREENMODE: number;
  94293. /** Defines that the ressource is not delayed*/
  94294. static readonly DELAYLOADSTATE_NONE: number;
  94295. /** Defines that the ressource was successfully delay loaded */
  94296. static readonly DELAYLOADSTATE_LOADED: number;
  94297. /** Defines that the ressource is currently delay loading */
  94298. static readonly DELAYLOADSTATE_LOADING: number;
  94299. /** Defines that the ressource is delayed and has not started loading */
  94300. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94301. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94302. static readonly NEVER: number;
  94303. /** 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 */
  94304. static readonly ALWAYS: number;
  94305. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94306. static readonly LESS: number;
  94307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94308. static readonly EQUAL: number;
  94309. /** 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 */
  94310. static readonly LEQUAL: number;
  94311. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94312. static readonly GREATER: number;
  94313. /** 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 */
  94314. static readonly GEQUAL: number;
  94315. /** 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 */
  94316. static readonly NOTEQUAL: number;
  94317. /** Passed to stencilOperation to specify that stencil value must be kept */
  94318. static readonly KEEP: number;
  94319. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94320. static readonly REPLACE: number;
  94321. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94322. static readonly INCR: number;
  94323. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94324. static readonly DECR: number;
  94325. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94326. static readonly INVERT: number;
  94327. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94328. static readonly INCR_WRAP: number;
  94329. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94330. static readonly DECR_WRAP: number;
  94331. /** Texture is not repeating outside of 0..1 UVs */
  94332. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94333. /** Texture is repeating outside of 0..1 UVs */
  94334. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94335. /** Texture is repeating and mirrored */
  94336. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94337. /** ALPHA */
  94338. static readonly TEXTUREFORMAT_ALPHA: number;
  94339. /** LUMINANCE */
  94340. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94341. /** LUMINANCE_ALPHA */
  94342. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94343. /** RGB */
  94344. static readonly TEXTUREFORMAT_RGB: number;
  94345. /** RGBA */
  94346. static readonly TEXTUREFORMAT_RGBA: number;
  94347. /** RED */
  94348. static readonly TEXTUREFORMAT_RED: number;
  94349. /** RED (2nd reference) */
  94350. static readonly TEXTUREFORMAT_R: number;
  94351. /** RG */
  94352. static readonly TEXTUREFORMAT_RG: number;
  94353. /** RED_INTEGER */
  94354. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94355. /** RED_INTEGER (2nd reference) */
  94356. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94357. /** RG_INTEGER */
  94358. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94359. /** RGB_INTEGER */
  94360. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94361. /** RGBA_INTEGER */
  94362. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94363. /** UNSIGNED_BYTE */
  94364. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94365. /** UNSIGNED_BYTE (2nd reference) */
  94366. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94367. /** FLOAT */
  94368. static readonly TEXTURETYPE_FLOAT: number;
  94369. /** HALF_FLOAT */
  94370. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94371. /** BYTE */
  94372. static readonly TEXTURETYPE_BYTE: number;
  94373. /** SHORT */
  94374. static readonly TEXTURETYPE_SHORT: number;
  94375. /** UNSIGNED_SHORT */
  94376. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94377. /** INT */
  94378. static readonly TEXTURETYPE_INT: number;
  94379. /** UNSIGNED_INT */
  94380. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94381. /** UNSIGNED_SHORT_4_4_4_4 */
  94382. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94383. /** UNSIGNED_SHORT_5_5_5_1 */
  94384. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94385. /** UNSIGNED_SHORT_5_6_5 */
  94386. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94387. /** UNSIGNED_INT_2_10_10_10_REV */
  94388. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94389. /** UNSIGNED_INT_24_8 */
  94390. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94391. /** UNSIGNED_INT_10F_11F_11F_REV */
  94392. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94393. /** UNSIGNED_INT_5_9_9_9_REV */
  94394. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94395. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94396. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94397. /** nearest is mag = nearest and min = nearest and mip = linear */
  94398. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94399. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94400. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94401. /** Trilinear is mag = linear and min = linear and mip = linear */
  94402. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94403. /** nearest is mag = nearest and min = nearest and mip = linear */
  94404. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94405. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94406. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94407. /** Trilinear is mag = linear and min = linear and mip = linear */
  94408. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94409. /** mag = nearest and min = nearest and mip = nearest */
  94410. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94411. /** mag = nearest and min = linear and mip = nearest */
  94412. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94413. /** mag = nearest and min = linear and mip = linear */
  94414. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94415. /** mag = nearest and min = linear and mip = none */
  94416. static readonly TEXTURE_NEAREST_LINEAR: number;
  94417. /** mag = nearest and min = nearest and mip = none */
  94418. static readonly TEXTURE_NEAREST_NEAREST: number;
  94419. /** mag = linear and min = nearest and mip = nearest */
  94420. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94421. /** mag = linear and min = nearest and mip = linear */
  94422. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94423. /** mag = linear and min = linear and mip = none */
  94424. static readonly TEXTURE_LINEAR_LINEAR: number;
  94425. /** mag = linear and min = nearest and mip = none */
  94426. static readonly TEXTURE_LINEAR_NEAREST: number;
  94427. /** Explicit coordinates mode */
  94428. static readonly TEXTURE_EXPLICIT_MODE: number;
  94429. /** Spherical coordinates mode */
  94430. static readonly TEXTURE_SPHERICAL_MODE: number;
  94431. /** Planar coordinates mode */
  94432. static readonly TEXTURE_PLANAR_MODE: number;
  94433. /** Cubic coordinates mode */
  94434. static readonly TEXTURE_CUBIC_MODE: number;
  94435. /** Projection coordinates mode */
  94436. static readonly TEXTURE_PROJECTION_MODE: number;
  94437. /** Skybox coordinates mode */
  94438. static readonly TEXTURE_SKYBOX_MODE: number;
  94439. /** Inverse Cubic coordinates mode */
  94440. static readonly TEXTURE_INVCUBIC_MODE: number;
  94441. /** Equirectangular coordinates mode */
  94442. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94443. /** Equirectangular Fixed coordinates mode */
  94444. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94445. /** Equirectangular Fixed Mirrored coordinates mode */
  94446. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94447. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94448. static readonly SCALEMODE_FLOOR: number;
  94449. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94450. static readonly SCALEMODE_NEAREST: number;
  94451. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94452. static readonly SCALEMODE_CEILING: number;
  94453. /**
  94454. * Returns the current npm package of the sdk
  94455. */
  94456. static readonly NpmPackage: string;
  94457. /**
  94458. * Returns the current version of the framework
  94459. */
  94460. static readonly Version: string;
  94461. /**
  94462. * Returns a string describing the current engine
  94463. */
  94464. readonly description: string;
  94465. /**
  94466. * Gets or sets the epsilon value used by collision engine
  94467. */
  94468. static CollisionsEpsilon: number;
  94469. /**
  94470. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94471. */
  94472. static ShadersRepository: string;
  94473. /**
  94474. * Method called to create the default loading screen.
  94475. * This can be overriden in your own app.
  94476. * @param canvas The rendering canvas element
  94477. * @returns The loading screen
  94478. */
  94479. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94480. /**
  94481. * Method called to create the default rescale post process on each engine.
  94482. */
  94483. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94484. /** @hidden */
  94485. _shaderProcessor: IShaderProcessor;
  94486. /**
  94487. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94488. */
  94489. forcePOTTextures: boolean;
  94490. /**
  94491. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94492. */
  94493. isFullscreen: boolean;
  94494. /**
  94495. * Gets a boolean indicating if the pointer is currently locked
  94496. */
  94497. isPointerLock: boolean;
  94498. /**
  94499. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94500. */
  94501. cullBackFaces: boolean;
  94502. /**
  94503. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94504. */
  94505. renderEvenInBackground: boolean;
  94506. /**
  94507. * Gets or sets a boolean indicating that cache can be kept between frames
  94508. */
  94509. preventCacheWipeBetweenFrames: boolean;
  94510. /**
  94511. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94512. **/
  94513. enableOfflineSupport: boolean;
  94514. /**
  94515. * 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)
  94516. **/
  94517. disableManifestCheck: boolean;
  94518. /**
  94519. * Gets the list of created scenes
  94520. */
  94521. scenes: Scene[];
  94522. /**
  94523. * Event raised when a new scene is created
  94524. */
  94525. onNewSceneAddedObservable: Observable<Scene>;
  94526. /**
  94527. * Gets the list of created postprocesses
  94528. */
  94529. postProcesses: PostProcess[];
  94530. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94531. validateShaderPrograms: boolean;
  94532. /**
  94533. * Observable event triggered each time the rendering canvas is resized
  94534. */
  94535. onResizeObservable: Observable<Engine>;
  94536. /**
  94537. * Observable event triggered each time the canvas loses focus
  94538. */
  94539. onCanvasBlurObservable: Observable<Engine>;
  94540. /**
  94541. * Observable event triggered each time the canvas gains focus
  94542. */
  94543. onCanvasFocusObservable: Observable<Engine>;
  94544. /**
  94545. * Observable event triggered each time the canvas receives pointerout event
  94546. */
  94547. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94548. /**
  94549. * Observable event triggered before each texture is initialized
  94550. */
  94551. onBeforeTextureInitObservable: Observable<Texture>;
  94552. /**
  94553. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94554. */
  94555. disableUniformBuffers: boolean;
  94556. /** @hidden */
  94557. _uniformBuffers: UniformBuffer[];
  94558. /**
  94559. * Gets a boolean indicating that the engine supports uniform buffers
  94560. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94561. */
  94562. readonly supportsUniformBuffers: boolean;
  94563. /**
  94564. * Observable raised when the engine begins a new frame
  94565. */
  94566. onBeginFrameObservable: Observable<Engine>;
  94567. /**
  94568. * If set, will be used to request the next animation frame for the render loop
  94569. */
  94570. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94571. /**
  94572. * Observable raised when the engine ends the current frame
  94573. */
  94574. onEndFrameObservable: Observable<Engine>;
  94575. /**
  94576. * Observable raised when the engine is about to compile a shader
  94577. */
  94578. onBeforeShaderCompilationObservable: Observable<Engine>;
  94579. /**
  94580. * Observable raised when the engine has jsut compiled a shader
  94581. */
  94582. onAfterShaderCompilationObservable: Observable<Engine>;
  94583. /** @hidden */
  94584. _gl: WebGLRenderingContext;
  94585. private _renderingCanvas;
  94586. private _windowIsBackground;
  94587. private _webGLVersion;
  94588. protected _highPrecisionShadersAllowed: boolean;
  94589. /** @hidden */
  94590. readonly _shouldUseHighPrecisionShader: boolean;
  94591. /**
  94592. * Gets a boolean indicating that only power of 2 textures are supported
  94593. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94594. */
  94595. readonly needPOTTextures: boolean;
  94596. /** @hidden */
  94597. _badOS: boolean;
  94598. /** @hidden */
  94599. _badDesktopOS: boolean;
  94600. /**
  94601. * Gets the audio engine
  94602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94603. * @ignorenaming
  94604. */
  94605. static audioEngine: IAudioEngine;
  94606. /**
  94607. * Default AudioEngine factory responsible of creating the Audio Engine.
  94608. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94609. */
  94610. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94611. /**
  94612. * Default offline support factory responsible of creating a tool used to store data locally.
  94613. * By default, this will create a Database object if the workload has been embedded.
  94614. */
  94615. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94616. private _onFocus;
  94617. private _onBlur;
  94618. private _onCanvasPointerOut;
  94619. private _onCanvasBlur;
  94620. private _onCanvasFocus;
  94621. private _onFullscreenChange;
  94622. private _onPointerLockChange;
  94623. private _hardwareScalingLevel;
  94624. /** @hidden */
  94625. _caps: EngineCapabilities;
  94626. private _pointerLockRequested;
  94627. private _isStencilEnable;
  94628. private _colorWrite;
  94629. private _loadingScreen;
  94630. /** @hidden */
  94631. _drawCalls: PerfCounter;
  94632. private _glVersion;
  94633. private _glRenderer;
  94634. private _glVendor;
  94635. private _videoTextureSupported;
  94636. private _renderingQueueLaunched;
  94637. private _activeRenderLoops;
  94638. private _deterministicLockstep;
  94639. private _lockstepMaxSteps;
  94640. /**
  94641. * Observable signaled when a context lost event is raised
  94642. */
  94643. onContextLostObservable: Observable<Engine>;
  94644. /**
  94645. * Observable signaled when a context restored event is raised
  94646. */
  94647. onContextRestoredObservable: Observable<Engine>;
  94648. private _onContextLost;
  94649. private _onContextRestored;
  94650. private _contextWasLost;
  94651. /** @hidden */
  94652. _doNotHandleContextLost: boolean;
  94653. /**
  94654. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94656. */
  94657. doNotHandleContextLost: boolean;
  94658. private _performanceMonitor;
  94659. private _fps;
  94660. private _deltaTime;
  94661. /**
  94662. * Turn this value on if you want to pause FPS computation when in background
  94663. */
  94664. disablePerformanceMonitorInBackground: boolean;
  94665. /**
  94666. * Gets the performance monitor attached to this engine
  94667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94668. */
  94669. readonly performanceMonitor: PerformanceMonitor;
  94670. /**
  94671. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94672. */
  94673. disableVertexArrayObjects: boolean;
  94674. /** @hidden */
  94675. protected _depthCullingState: _DepthCullingState;
  94676. /** @hidden */
  94677. protected _stencilState: _StencilState;
  94678. /** @hidden */
  94679. protected _alphaState: _AlphaState;
  94680. /** @hidden */
  94681. protected _alphaMode: number;
  94682. /** @hidden */
  94683. _internalTexturesCache: InternalTexture[];
  94684. /** @hidden */
  94685. protected _activeChannel: number;
  94686. private _currentTextureChannel;
  94687. /** @hidden */
  94688. protected _boundTexturesCache: {
  94689. [key: string]: Nullable<InternalTexture>;
  94690. };
  94691. /** @hidden */
  94692. protected _currentEffect: Nullable<Effect>;
  94693. /** @hidden */
  94694. protected _currentProgram: Nullable<WebGLProgram>;
  94695. private _compiledEffects;
  94696. private _vertexAttribArraysEnabled;
  94697. /** @hidden */
  94698. protected _cachedViewport: Nullable<IViewportLike>;
  94699. private _cachedVertexArrayObject;
  94700. /** @hidden */
  94701. protected _cachedVertexBuffers: any;
  94702. /** @hidden */
  94703. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94704. /** @hidden */
  94705. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94706. /** @hidden */
  94707. _currentRenderTarget: Nullable<InternalTexture>;
  94708. private _uintIndicesCurrentlySet;
  94709. private _currentBoundBuffer;
  94710. /** @hidden */
  94711. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94712. private _currentBufferPointers;
  94713. private _currentInstanceLocations;
  94714. private _currentInstanceBuffers;
  94715. private _textureUnits;
  94716. /** @hidden */
  94717. _workingCanvas: Nullable<HTMLCanvasElement>;
  94718. /** @hidden */
  94719. _workingContext: Nullable<CanvasRenderingContext2D>;
  94720. private _rescalePostProcess;
  94721. private _dummyFramebuffer;
  94722. private _externalData;
  94723. /** @hidden */
  94724. _bindedRenderFunction: any;
  94725. private _vaoRecordInProgress;
  94726. private _mustWipeVertexAttributes;
  94727. private _emptyTexture;
  94728. private _emptyCubeTexture;
  94729. private _emptyTexture3D;
  94730. /** @hidden */
  94731. _frameHandler: number;
  94732. private _nextFreeTextureSlots;
  94733. private _maxSimultaneousTextures;
  94734. private _activeRequests;
  94735. private _texturesSupported;
  94736. /** @hidden */
  94737. _textureFormatInUse: Nullable<string>;
  94738. /**
  94739. * Gets the list of texture formats supported
  94740. */
  94741. readonly texturesSupported: Array<string>;
  94742. /**
  94743. * Gets the list of texture formats in use
  94744. */
  94745. readonly textureFormatInUse: Nullable<string>;
  94746. /**
  94747. * Gets the current viewport
  94748. */
  94749. readonly currentViewport: Nullable<IViewportLike>;
  94750. /**
  94751. * Gets the default empty texture
  94752. */
  94753. readonly emptyTexture: InternalTexture;
  94754. /**
  94755. * Gets the default empty 3D texture
  94756. */
  94757. readonly emptyTexture3D: InternalTexture;
  94758. /**
  94759. * Gets the default empty cube texture
  94760. */
  94761. readonly emptyCubeTexture: InternalTexture;
  94762. /**
  94763. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94764. */
  94765. readonly premultipliedAlpha: boolean;
  94766. /**
  94767. * Creates a new engine
  94768. * @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
  94769. * @param antialias defines enable antialiasing (default: false)
  94770. * @param options defines further options to be sent to the getContext() function
  94771. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94772. */
  94773. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94774. /**
  94775. * Initializes a webVR display and starts listening to display change events
  94776. * The onVRDisplayChangedObservable will be notified upon these changes
  94777. * @returns The onVRDisplayChangedObservable
  94778. */
  94779. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94780. /** @hidden */
  94781. _prepareVRComponent(): void;
  94782. /** @hidden */
  94783. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94784. /** @hidden */
  94785. _submitVRFrame(): void;
  94786. /**
  94787. * Call this function to leave webVR mode
  94788. * Will do nothing if webVR is not supported or if there is no webVR device
  94789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94790. */
  94791. disableVR(): void;
  94792. /**
  94793. * Gets a boolean indicating that the system is in VR mode and is presenting
  94794. * @returns true if VR mode is engaged
  94795. */
  94796. isVRPresenting(): boolean;
  94797. /** @hidden */
  94798. _requestVRFrame(): void;
  94799. private _disableTouchAction;
  94800. private _rebuildInternalTextures;
  94801. private _rebuildEffects;
  94802. /**
  94803. * Gets a boolean indicating if all created effects are ready
  94804. * @returns true if all effects are ready
  94805. */
  94806. areAllEffectsReady(): boolean;
  94807. private _rebuildBuffers;
  94808. private _initGLContext;
  94809. /**
  94810. * Gets version of the current webGL context
  94811. */
  94812. readonly webGLVersion: number;
  94813. /**
  94814. * Gets a string idenfifying the name of the class
  94815. * @returns "Engine" string
  94816. */
  94817. getClassName(): string;
  94818. /**
  94819. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94820. */
  94821. readonly isStencilEnable: boolean;
  94822. /** @hidden */
  94823. _prepareWorkingCanvas(): void;
  94824. /**
  94825. * Reset the texture cache to empty state
  94826. */
  94827. resetTextureCache(): void;
  94828. /**
  94829. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94831. * @returns true if engine is in deterministic lock step mode
  94832. */
  94833. isDeterministicLockStep(): boolean;
  94834. /**
  94835. * Gets the max steps when engine is running in deterministic lock step
  94836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94837. * @returns the max steps
  94838. */
  94839. getLockstepMaxSteps(): number;
  94840. /**
  94841. * Gets an object containing information about the current webGL context
  94842. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94843. */
  94844. getGlInfo(): {
  94845. vendor: string;
  94846. renderer: string;
  94847. version: string;
  94848. };
  94849. /**
  94850. * Gets current aspect ratio
  94851. * @param viewportOwner defines the camera to use to get the aspect ratio
  94852. * @param useScreen defines if screen size must be used (or the current render target if any)
  94853. * @returns a number defining the aspect ratio
  94854. */
  94855. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94856. /**
  94857. * Gets current screen aspect ratio
  94858. * @returns a number defining the aspect ratio
  94859. */
  94860. getScreenAspectRatio(): number;
  94861. /**
  94862. * Gets the current render width
  94863. * @param useScreen defines if screen size must be used (or the current render target if any)
  94864. * @returns a number defining the current render width
  94865. */
  94866. getRenderWidth(useScreen?: boolean): number;
  94867. /**
  94868. * Gets the current render height
  94869. * @param useScreen defines if screen size must be used (or the current render target if any)
  94870. * @returns a number defining the current render height
  94871. */
  94872. getRenderHeight(useScreen?: boolean): number;
  94873. /**
  94874. * Gets the HTML canvas attached with the current webGL context
  94875. * @returns a HTML canvas
  94876. */
  94877. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94878. /**
  94879. * Gets host window
  94880. * @returns the host window object
  94881. */
  94882. getHostWindow(): Window;
  94883. /**
  94884. * Gets host document
  94885. * @returns the host document object
  94886. */
  94887. getHostDocument(): Document;
  94888. /**
  94889. * Gets the client rect of the HTML canvas attached with the current webGL context
  94890. * @returns a client rectanglee
  94891. */
  94892. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94893. /**
  94894. * Defines the hardware scaling level.
  94895. * By default the hardware scaling level is computed from the window device ratio.
  94896. * 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.
  94897. * @param level defines the level to use
  94898. */
  94899. setHardwareScalingLevel(level: number): void;
  94900. /**
  94901. * Gets the current hardware scaling level.
  94902. * By default the hardware scaling level is computed from the window device ratio.
  94903. * 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.
  94904. * @returns a number indicating the current hardware scaling level
  94905. */
  94906. getHardwareScalingLevel(): number;
  94907. /**
  94908. * Gets the list of loaded textures
  94909. * @returns an array containing all loaded textures
  94910. */
  94911. getLoadedTexturesCache(): InternalTexture[];
  94912. /**
  94913. * Gets the object containing all engine capabilities
  94914. * @returns the EngineCapabilities object
  94915. */
  94916. getCaps(): EngineCapabilities;
  94917. /**
  94918. * Gets the current depth function
  94919. * @returns a number defining the depth function
  94920. */
  94921. getDepthFunction(): Nullable<number>;
  94922. /**
  94923. * Sets the current depth function
  94924. * @param depthFunc defines the function to use
  94925. */
  94926. setDepthFunction(depthFunc: number): void;
  94927. /**
  94928. * Sets the current depth function to GREATER
  94929. */
  94930. setDepthFunctionToGreater(): void;
  94931. /**
  94932. * Sets the current depth function to GEQUAL
  94933. */
  94934. setDepthFunctionToGreaterOrEqual(): void;
  94935. /**
  94936. * Sets the current depth function to LESS
  94937. */
  94938. setDepthFunctionToLess(): void;
  94939. private _cachedStencilBuffer;
  94940. private _cachedStencilFunction;
  94941. private _cachedStencilMask;
  94942. private _cachedStencilOperationPass;
  94943. private _cachedStencilOperationFail;
  94944. private _cachedStencilOperationDepthFail;
  94945. private _cachedStencilReference;
  94946. /**
  94947. * Caches the the state of the stencil buffer
  94948. */
  94949. cacheStencilState(): void;
  94950. /**
  94951. * Restores the state of the stencil buffer
  94952. */
  94953. restoreStencilState(): void;
  94954. /**
  94955. * Sets the current depth function to LEQUAL
  94956. */
  94957. setDepthFunctionToLessOrEqual(): void;
  94958. /**
  94959. * Gets a boolean indicating if stencil buffer is enabled
  94960. * @returns the current stencil buffer state
  94961. */
  94962. getStencilBuffer(): boolean;
  94963. /**
  94964. * Enable or disable the stencil buffer
  94965. * @param enable defines if the stencil buffer must be enabled or disabled
  94966. */
  94967. setStencilBuffer(enable: boolean): void;
  94968. /**
  94969. * Gets the current stencil mask
  94970. * @returns a number defining the new stencil mask to use
  94971. */
  94972. getStencilMask(): number;
  94973. /**
  94974. * Sets the current stencil mask
  94975. * @param mask defines the new stencil mask to use
  94976. */
  94977. setStencilMask(mask: number): void;
  94978. /**
  94979. * Gets the current stencil function
  94980. * @returns a number defining the stencil function to use
  94981. */
  94982. getStencilFunction(): number;
  94983. /**
  94984. * Gets the current stencil reference value
  94985. * @returns a number defining the stencil reference value to use
  94986. */
  94987. getStencilFunctionReference(): number;
  94988. /**
  94989. * Gets the current stencil mask
  94990. * @returns a number defining the stencil mask to use
  94991. */
  94992. getStencilFunctionMask(): number;
  94993. /**
  94994. * Sets the current stencil function
  94995. * @param stencilFunc defines the new stencil function to use
  94996. */
  94997. setStencilFunction(stencilFunc: number): void;
  94998. /**
  94999. * Sets the current stencil reference
  95000. * @param reference defines the new stencil reference to use
  95001. */
  95002. setStencilFunctionReference(reference: number): void;
  95003. /**
  95004. * Sets the current stencil mask
  95005. * @param mask defines the new stencil mask to use
  95006. */
  95007. setStencilFunctionMask(mask: number): void;
  95008. /**
  95009. * Gets the current stencil operation when stencil fails
  95010. * @returns a number defining stencil operation to use when stencil fails
  95011. */
  95012. getStencilOperationFail(): number;
  95013. /**
  95014. * Gets the current stencil operation when depth fails
  95015. * @returns a number defining stencil operation to use when depth fails
  95016. */
  95017. getStencilOperationDepthFail(): number;
  95018. /**
  95019. * Gets the current stencil operation when stencil passes
  95020. * @returns a number defining stencil operation to use when stencil passes
  95021. */
  95022. getStencilOperationPass(): number;
  95023. /**
  95024. * Sets the stencil operation to use when stencil fails
  95025. * @param operation defines the stencil operation to use when stencil fails
  95026. */
  95027. setStencilOperationFail(operation: number): void;
  95028. /**
  95029. * Sets the stencil operation to use when depth fails
  95030. * @param operation defines the stencil operation to use when depth fails
  95031. */
  95032. setStencilOperationDepthFail(operation: number): void;
  95033. /**
  95034. * Sets the stencil operation to use when stencil passes
  95035. * @param operation defines the stencil operation to use when stencil passes
  95036. */
  95037. setStencilOperationPass(operation: number): void;
  95038. /**
  95039. * Sets a boolean indicating if the dithering state is enabled or disabled
  95040. * @param value defines the dithering state
  95041. */
  95042. setDitheringState(value: boolean): void;
  95043. /**
  95044. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95045. * @param value defines the rasterizer state
  95046. */
  95047. setRasterizerState(value: boolean): void;
  95048. /**
  95049. * stop executing a render loop function and remove it from the execution array
  95050. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95051. */
  95052. stopRenderLoop(renderFunction?: () => void): void;
  95053. /** @hidden */
  95054. _renderLoop(): void;
  95055. /**
  95056. * Register and execute a render loop. The engine can have more than one render function
  95057. * @param renderFunction defines the function to continuously execute
  95058. */
  95059. runRenderLoop(renderFunction: () => void): void;
  95060. /**
  95061. * Toggle full screen mode
  95062. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95063. */
  95064. switchFullscreen(requestPointerLock: boolean): void;
  95065. /**
  95066. * Enters full screen mode
  95067. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95068. */
  95069. enterFullscreen(requestPointerLock: boolean): void;
  95070. /**
  95071. * Exits full screen mode
  95072. */
  95073. exitFullscreen(): void;
  95074. /**
  95075. * Enters Pointerlock mode
  95076. */
  95077. enterPointerlock(): void;
  95078. /**
  95079. * Exits Pointerlock mode
  95080. */
  95081. exitPointerlock(): void;
  95082. /**
  95083. * Clear the current render buffer or the current render target (if any is set up)
  95084. * @param color defines the color to use
  95085. * @param backBuffer defines if the back buffer must be cleared
  95086. * @param depth defines if the depth buffer must be cleared
  95087. * @param stencil defines if the stencil buffer must be cleared
  95088. */
  95089. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95090. /**
  95091. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95092. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95093. * @param y defines the y-coordinate of the corner of the clear rectangle
  95094. * @param width defines the width of the clear rectangle
  95095. * @param height defines the height of the clear rectangle
  95096. * @param clearColor defines the clear color
  95097. */
  95098. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95099. /**
  95100. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95101. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95102. * @param y defines the y-coordinate of the corner of the clear rectangle
  95103. * @param width defines the width of the clear rectangle
  95104. * @param height defines the height of the clear rectangle
  95105. */
  95106. enableScissor(x: number, y: number, width: number, height: number): void;
  95107. /**
  95108. * Disable previously set scissor test rectangle
  95109. */
  95110. disableScissor(): void;
  95111. private _viewportCached;
  95112. /** @hidden */
  95113. _viewport(x: number, y: number, width: number, height: number): void;
  95114. /**
  95115. * Set the WebGL's viewport
  95116. * @param viewport defines the viewport element to be used
  95117. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95118. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95119. */
  95120. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95121. /**
  95122. * Directly set the WebGL Viewport
  95123. * @param x defines the x coordinate of the viewport (in screen space)
  95124. * @param y defines the y coordinate of the viewport (in screen space)
  95125. * @param width defines the width of the viewport (in screen space)
  95126. * @param height defines the height of the viewport (in screen space)
  95127. * @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
  95128. */
  95129. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95130. /**
  95131. * Begin a new frame
  95132. */
  95133. beginFrame(): void;
  95134. /**
  95135. * Enf the current frame
  95136. */
  95137. endFrame(): void;
  95138. /**
  95139. * Resize the view according to the canvas' size
  95140. */
  95141. resize(): void;
  95142. /**
  95143. * Force a specific size of the canvas
  95144. * @param width defines the new canvas' width
  95145. * @param height defines the new canvas' height
  95146. */
  95147. setSize(width: number, height: number): void;
  95148. /**
  95149. * Binds the frame buffer to the specified texture.
  95150. * @param texture The texture to render to or null for the default canvas
  95151. * @param faceIndex The face of the texture to render to in case of cube texture
  95152. * @param requiredWidth The width of the target to render to
  95153. * @param requiredHeight The height of the target to render to
  95154. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95155. * @param depthStencilTexture The depth stencil texture to use to render
  95156. * @param lodLevel defines le lod level to bind to the frame buffer
  95157. */
  95158. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95159. /** @hidden */
  95160. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95161. /**
  95162. * Unbind the current render target texture from the webGL context
  95163. * @param texture defines the render target texture to unbind
  95164. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95165. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95166. */
  95167. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95168. /**
  95169. * Force the mipmap generation for the given render target texture
  95170. * @param texture defines the render target texture to use
  95171. */
  95172. generateMipMapsForCubemap(texture: InternalTexture): void;
  95173. /**
  95174. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95175. */
  95176. flushFramebuffer(): void;
  95177. /**
  95178. * Unbind the current render target and bind the default framebuffer
  95179. */
  95180. restoreDefaultFramebuffer(): void;
  95181. /**
  95182. * Create an uniform buffer
  95183. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95184. * @param elements defines the content of the uniform buffer
  95185. * @returns the webGL uniform buffer
  95186. */
  95187. createUniformBuffer(elements: FloatArray): DataBuffer;
  95188. /**
  95189. * Create a dynamic uniform buffer
  95190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95191. * @param elements defines the content of the uniform buffer
  95192. * @returns the webGL uniform buffer
  95193. */
  95194. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95195. /**
  95196. * Update an existing uniform buffer
  95197. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95198. * @param uniformBuffer defines the target uniform buffer
  95199. * @param elements defines the content to update
  95200. * @param offset defines the offset in the uniform buffer where update should start
  95201. * @param count defines the size of the data to update
  95202. */
  95203. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95204. private _resetVertexBufferBinding;
  95205. /**
  95206. * Creates a vertex buffer
  95207. * @param data the data for the vertex buffer
  95208. * @returns the new WebGL static buffer
  95209. */
  95210. createVertexBuffer(data: DataArray): DataBuffer;
  95211. /**
  95212. * Creates a dynamic vertex buffer
  95213. * @param data the data for the dynamic vertex buffer
  95214. * @returns the new WebGL dynamic buffer
  95215. */
  95216. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95217. /**
  95218. * Update a dynamic index buffer
  95219. * @param indexBuffer defines the target index buffer
  95220. * @param indices defines the data to update
  95221. * @param offset defines the offset in the target index buffer where update should start
  95222. */
  95223. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95224. /**
  95225. * Updates a dynamic vertex buffer.
  95226. * @param vertexBuffer the vertex buffer to update
  95227. * @param data the data used to update the vertex buffer
  95228. * @param byteOffset the byte offset of the data
  95229. * @param byteLength the byte length of the data
  95230. */
  95231. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95232. private _resetIndexBufferBinding;
  95233. /**
  95234. * Creates a new index buffer
  95235. * @param indices defines the content of the index buffer
  95236. * @param updatable defines if the index buffer must be updatable
  95237. * @returns a new webGL buffer
  95238. */
  95239. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95240. /**
  95241. * Bind a webGL buffer to the webGL context
  95242. * @param buffer defines the buffer to bind
  95243. */
  95244. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95245. /**
  95246. * Bind an uniform buffer to the current webGL context
  95247. * @param buffer defines the buffer to bind
  95248. */
  95249. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95250. /**
  95251. * Bind a buffer to the current webGL context at a given location
  95252. * @param buffer defines the buffer to bind
  95253. * @param location defines the index where to bind the buffer
  95254. */
  95255. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95256. /**
  95257. * Bind a specific block at a given index in a specific shader program
  95258. * @param pipelineContext defines the pipeline context to use
  95259. * @param blockName defines the block name
  95260. * @param index defines the index where to bind the block
  95261. */
  95262. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95263. private bindIndexBuffer;
  95264. private bindBuffer;
  95265. /**
  95266. * update the bound buffer with the given data
  95267. * @param data defines the data to update
  95268. */
  95269. updateArrayBuffer(data: Float32Array): void;
  95270. private _vertexAttribPointer;
  95271. private _bindIndexBufferWithCache;
  95272. private _bindVertexBuffersAttributes;
  95273. /**
  95274. * Records a vertex array object
  95275. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95276. * @param vertexBuffers defines the list of vertex buffers to store
  95277. * @param indexBuffer defines the index buffer to store
  95278. * @param effect defines the effect to store
  95279. * @returns the new vertex array object
  95280. */
  95281. recordVertexArrayObject(vertexBuffers: {
  95282. [key: string]: VertexBuffer;
  95283. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95284. /**
  95285. * Bind a specific vertex array object
  95286. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95287. * @param vertexArrayObject defines the vertex array object to bind
  95288. * @param indexBuffer defines the index buffer to bind
  95289. */
  95290. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95291. /**
  95292. * Bind webGl buffers directly to the webGL context
  95293. * @param vertexBuffer defines the vertex buffer to bind
  95294. * @param indexBuffer defines the index buffer to bind
  95295. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95296. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95297. * @param effect defines the effect associated with the vertex buffer
  95298. */
  95299. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95300. private _unbindVertexArrayObject;
  95301. /**
  95302. * Bind a list of vertex buffers to the webGL context
  95303. * @param vertexBuffers defines the list of vertex buffers to bind
  95304. * @param indexBuffer defines the index buffer to bind
  95305. * @param effect defines the effect associated with the vertex buffers
  95306. */
  95307. bindBuffers(vertexBuffers: {
  95308. [key: string]: Nullable<VertexBuffer>;
  95309. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95310. /**
  95311. * Unbind all instance attributes
  95312. */
  95313. unbindInstanceAttributes(): void;
  95314. /**
  95315. * Release and free the memory of a vertex array object
  95316. * @param vao defines the vertex array object to delete
  95317. */
  95318. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95319. /** @hidden */
  95320. _releaseBuffer(buffer: DataBuffer): boolean;
  95321. /**
  95322. * Creates a webGL buffer to use with instanciation
  95323. * @param capacity defines the size of the buffer
  95324. * @returns the webGL buffer
  95325. */
  95326. createInstancesBuffer(capacity: number): DataBuffer;
  95327. /**
  95328. * Delete a webGL buffer used with instanciation
  95329. * @param buffer defines the webGL buffer to delete
  95330. */
  95331. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95332. /**
  95333. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95334. * @param instancesBuffer defines the webGL buffer to update and bind
  95335. * @param data defines the data to store in the buffer
  95336. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95337. */
  95338. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95339. /**
  95340. * Apply all cached states (depth, culling, stencil and alpha)
  95341. */
  95342. applyStates(): void;
  95343. /**
  95344. * Send a draw order
  95345. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95346. * @param indexStart defines the starting index
  95347. * @param indexCount defines the number of index to draw
  95348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95349. */
  95350. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95351. /**
  95352. * Draw a list of points
  95353. * @param verticesStart defines the index of first vertex to draw
  95354. * @param verticesCount defines the count of vertices to draw
  95355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95356. */
  95357. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95358. /**
  95359. * Draw a list of unindexed primitives
  95360. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95361. * @param verticesStart defines the index of first vertex to draw
  95362. * @param verticesCount defines the count of vertices to draw
  95363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95364. */
  95365. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95366. /**
  95367. * Draw a list of indexed primitives
  95368. * @param fillMode defines the primitive to use
  95369. * @param indexStart defines the starting index
  95370. * @param indexCount defines the number of index to draw
  95371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95372. */
  95373. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95374. /**
  95375. * Draw a list of unindexed primitives
  95376. * @param fillMode defines the primitive to use
  95377. * @param verticesStart defines the index of first vertex to draw
  95378. * @param verticesCount defines the count of vertices to draw
  95379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95380. */
  95381. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95382. private _drawMode;
  95383. /** @hidden */
  95384. _releaseEffect(effect: Effect): void;
  95385. /** @hidden */
  95386. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95387. /**
  95388. * Create a new effect (used to store vertex/fragment shaders)
  95389. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95390. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95391. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95392. * @param samplers defines an array of string used to represent textures
  95393. * @param defines defines the string containing the defines to use to compile the shaders
  95394. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95395. * @param onCompiled defines a function to call when the effect creation is successful
  95396. * @param onError defines a function to call when the effect creation has failed
  95397. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95398. * @returns the new Effect
  95399. */
  95400. 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;
  95401. private _compileShader;
  95402. private _compileRawShader;
  95403. /**
  95404. * Directly creates a webGL program
  95405. * @param pipelineContext defines the pipeline context to attach to
  95406. * @param vertexCode defines the vertex shader code to use
  95407. * @param fragmentCode defines the fragment shader code to use
  95408. * @param context defines the webGL context to use (if not set, the current one will be used)
  95409. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95410. * @returns the new webGL program
  95411. */
  95412. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95413. /**
  95414. * Creates a webGL program
  95415. * @param pipelineContext defines the pipeline context to attach to
  95416. * @param vertexCode defines the vertex shader code to use
  95417. * @param fragmentCode defines the fragment shader code to use
  95418. * @param defines defines the string containing the defines to use to compile the shaders
  95419. * @param context defines the webGL context to use (if not set, the current one will be used)
  95420. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95421. * @returns the new webGL program
  95422. */
  95423. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95424. /**
  95425. * Creates a new pipeline context
  95426. * @returns the new pipeline
  95427. */
  95428. createPipelineContext(): WebGLPipelineContext;
  95429. private _createShaderProgram;
  95430. private _finalizePipelineContext;
  95431. /** @hidden */
  95432. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95433. /** @hidden */
  95434. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95435. /** @hidden */
  95436. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95437. /**
  95438. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95439. * @param pipelineContext defines the pipeline context to use
  95440. * @param uniformsNames defines the list of uniform names
  95441. * @returns an array of webGL uniform locations
  95442. */
  95443. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95444. /**
  95445. * Gets the lsit of active attributes for a given webGL program
  95446. * @param pipelineContext defines the pipeline context to use
  95447. * @param attributesNames defines the list of attribute names to get
  95448. * @returns an array of indices indicating the offset of each attribute
  95449. */
  95450. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95451. /**
  95452. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95453. * @param effect defines the effect to activate
  95454. */
  95455. enableEffect(effect: Nullable<Effect>): void;
  95456. /**
  95457. * Set the value of an uniform to an array of int32
  95458. * @param uniform defines the webGL uniform location where to store the value
  95459. * @param array defines the array of int32 to store
  95460. */
  95461. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95462. /**
  95463. * Set the value of an uniform to an array of int32 (stored as vec2)
  95464. * @param uniform defines the webGL uniform location where to store the value
  95465. * @param array defines the array of int32 to store
  95466. */
  95467. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95468. /**
  95469. * Set the value of an uniform to an array of int32 (stored as vec3)
  95470. * @param uniform defines the webGL uniform location where to store the value
  95471. * @param array defines the array of int32 to store
  95472. */
  95473. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95474. /**
  95475. * Set the value of an uniform to an array of int32 (stored as vec4)
  95476. * @param uniform defines the webGL uniform location where to store the value
  95477. * @param array defines the array of int32 to store
  95478. */
  95479. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95480. /**
  95481. * Set the value of an uniform to an array of float32
  95482. * @param uniform defines the webGL uniform location where to store the value
  95483. * @param array defines the array of float32 to store
  95484. */
  95485. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95486. /**
  95487. * Set the value of an uniform to an array of float32 (stored as vec2)
  95488. * @param uniform defines the webGL uniform location where to store the value
  95489. * @param array defines the array of float32 to store
  95490. */
  95491. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95492. /**
  95493. * Set the value of an uniform to an array of float32 (stored as vec3)
  95494. * @param uniform defines the webGL uniform location where to store the value
  95495. * @param array defines the array of float32 to store
  95496. */
  95497. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95498. /**
  95499. * Set the value of an uniform to an array of float32 (stored as vec4)
  95500. * @param uniform defines the webGL uniform location where to store the value
  95501. * @param array defines the array of float32 to store
  95502. */
  95503. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95504. /**
  95505. * Set the value of an uniform to an array of number
  95506. * @param uniform defines the webGL uniform location where to store the value
  95507. * @param array defines the array of number to store
  95508. */
  95509. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95510. /**
  95511. * Set the value of an uniform to an array of number (stored as vec2)
  95512. * @param uniform defines the webGL uniform location where to store the value
  95513. * @param array defines the array of number to store
  95514. */
  95515. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95516. /**
  95517. * Set the value of an uniform to an array of number (stored as vec3)
  95518. * @param uniform defines the webGL uniform location where to store the value
  95519. * @param array defines the array of number to store
  95520. */
  95521. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95522. /**
  95523. * Set the value of an uniform to an array of number (stored as vec4)
  95524. * @param uniform defines the webGL uniform location where to store the value
  95525. * @param array defines the array of number to store
  95526. */
  95527. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95528. /**
  95529. * Set the value of an uniform to an array of float32 (stored as matrices)
  95530. * @param uniform defines the webGL uniform location where to store the value
  95531. * @param matrices defines the array of float32 to store
  95532. */
  95533. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95534. /**
  95535. * Set the value of an uniform to a matrix (3x3)
  95536. * @param uniform defines the webGL uniform location where to store the value
  95537. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95538. */
  95539. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95540. /**
  95541. * Set the value of an uniform to a matrix (2x2)
  95542. * @param uniform defines the webGL uniform location where to store the value
  95543. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95544. */
  95545. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95546. /**
  95547. * Set the value of an uniform to a number (int)
  95548. * @param uniform defines the webGL uniform location where to store the value
  95549. * @param value defines the int number to store
  95550. */
  95551. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95552. /**
  95553. * Set the value of an uniform to a number (float)
  95554. * @param uniform defines the webGL uniform location where to store the value
  95555. * @param value defines the float number to store
  95556. */
  95557. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95558. /**
  95559. * Set the value of an uniform to a vec2
  95560. * @param uniform defines the webGL uniform location where to store the value
  95561. * @param x defines the 1st component of the value
  95562. * @param y defines the 2nd component of the value
  95563. */
  95564. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95565. /**
  95566. * Set the value of an uniform to a vec3
  95567. * @param uniform defines the webGL uniform location where to store the value
  95568. * @param x defines the 1st component of the value
  95569. * @param y defines the 2nd component of the value
  95570. * @param z defines the 3rd component of the value
  95571. */
  95572. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95573. /**
  95574. * Set the value of an uniform to a boolean
  95575. * @param uniform defines the webGL uniform location where to store the value
  95576. * @param bool defines the boolean to store
  95577. */
  95578. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95579. /**
  95580. * Set the value of an uniform to a vec4
  95581. * @param uniform defines the webGL uniform location where to store the value
  95582. * @param x defines the 1st component of the value
  95583. * @param y defines the 2nd component of the value
  95584. * @param z defines the 3rd component of the value
  95585. * @param w defines the 4th component of the value
  95586. */
  95587. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95588. /**
  95589. * Sets a Color4 on a uniform variable
  95590. * @param uniform defines the uniform location
  95591. * @param color4 defines the value to be set
  95592. */
  95593. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95594. /**
  95595. * Set various states to the webGL context
  95596. * @param culling defines backface culling state
  95597. * @param zOffset defines the value to apply to zOffset (0 by default)
  95598. * @param force defines if states must be applied even if cache is up to date
  95599. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95600. */
  95601. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95602. /**
  95603. * Set the z offset to apply to current rendering
  95604. * @param value defines the offset to apply
  95605. */
  95606. setZOffset(value: number): void;
  95607. /**
  95608. * Gets the current value of the zOffset
  95609. * @returns the current zOffset state
  95610. */
  95611. getZOffset(): number;
  95612. /**
  95613. * Enable or disable depth buffering
  95614. * @param enable defines the state to set
  95615. */
  95616. setDepthBuffer(enable: boolean): void;
  95617. /**
  95618. * Gets a boolean indicating if depth writing is enabled
  95619. * @returns the current depth writing state
  95620. */
  95621. getDepthWrite(): boolean;
  95622. /**
  95623. * Enable or disable depth writing
  95624. * @param enable defines the state to set
  95625. */
  95626. setDepthWrite(enable: boolean): void;
  95627. /**
  95628. * Enable or disable color writing
  95629. * @param enable defines the state to set
  95630. */
  95631. setColorWrite(enable: boolean): void;
  95632. /**
  95633. * Gets a boolean indicating if color writing is enabled
  95634. * @returns the current color writing state
  95635. */
  95636. getColorWrite(): boolean;
  95637. /**
  95638. * Sets alpha constants used by some alpha blending modes
  95639. * @param r defines the red component
  95640. * @param g defines the green component
  95641. * @param b defines the blue component
  95642. * @param a defines the alpha component
  95643. */
  95644. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95645. /**
  95646. * Sets the current alpha mode
  95647. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95648. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95650. */
  95651. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95652. /**
  95653. * Gets the current alpha mode
  95654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95655. * @returns the current alpha mode
  95656. */
  95657. getAlphaMode(): number;
  95658. /**
  95659. * Clears the list of texture accessible through engine.
  95660. * This can help preventing texture load conflict due to name collision.
  95661. */
  95662. clearInternalTexturesCache(): void;
  95663. /**
  95664. * Force the entire cache to be cleared
  95665. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95666. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95667. */
  95668. wipeCaches(bruteForce?: boolean): void;
  95669. /**
  95670. * Set the compressed texture format to use, based on the formats you have, and the formats
  95671. * supported by the hardware / browser.
  95672. *
  95673. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95674. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95675. * to API arguments needed to compressed textures. This puts the burden on the container
  95676. * generator to house the arcane code for determining these for current & future formats.
  95677. *
  95678. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95679. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95680. *
  95681. * Note: The result of this call is not taken into account when a texture is base64.
  95682. *
  95683. * @param formatsAvailable defines the list of those format families you have created
  95684. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95685. *
  95686. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95687. * @returns The extension selected.
  95688. */
  95689. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95690. /** @hidden */
  95691. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95692. min: number;
  95693. mag: number;
  95694. };
  95695. /** @hidden */
  95696. _createTexture(): WebGLTexture;
  95697. /**
  95698. * Usually called from Texture.ts.
  95699. * Passed information to create a WebGLTexture
  95700. * @param urlArg defines a value which contains one of the following:
  95701. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95702. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95703. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95704. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95705. * @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)
  95706. * @param scene needed for loading to the correct scene
  95707. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95708. * @param onLoad optional callback to be called upon successful completion
  95709. * @param onError optional callback to be called upon failure
  95710. * @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
  95711. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95712. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95713. * @param forcedExtension defines the extension to use to pick the right loader
  95714. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95716. */
  95717. 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;
  95718. /**
  95719. * @hidden
  95720. * Rescales a texture
  95721. * @param source input texutre
  95722. * @param destination destination texture
  95723. * @param scene scene to use to render the resize
  95724. * @param internalFormat format to use when resizing
  95725. * @param onComplete callback to be called when resize has completed
  95726. */
  95727. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95728. private _unpackFlipYCached;
  95729. /**
  95730. * In case you are sharing the context with other applications, it might
  95731. * be interested to not cache the unpack flip y state to ensure a consistent
  95732. * value would be set.
  95733. */
  95734. enableUnpackFlipYCached: boolean;
  95735. /** @hidden */
  95736. _unpackFlipY(value: boolean): void;
  95737. /** @hidden */
  95738. _getUnpackAlignement(): number;
  95739. /**
  95740. * Creates a dynamic texture
  95741. * @param width defines the width of the texture
  95742. * @param height defines the height of the texture
  95743. * @param generateMipMaps defines if the engine should generate the mip levels
  95744. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95745. * @returns the dynamic texture inside an InternalTexture
  95746. */
  95747. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95748. /**
  95749. * Update the sampling mode of a given texture
  95750. * @param samplingMode defines the required sampling mode
  95751. * @param texture defines the texture to update
  95752. */
  95753. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95754. /**
  95755. * Update the content of a dynamic texture
  95756. * @param texture defines the texture to update
  95757. * @param canvas defines the canvas containing the source
  95758. * @param invertY defines if data must be stored with Y axis inverted
  95759. * @param premulAlpha defines if alpha is stored as premultiplied
  95760. * @param format defines the format of the data
  95761. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95762. */
  95763. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95764. /**
  95765. * Update a video texture
  95766. * @param texture defines the texture to update
  95767. * @param video defines the video element to use
  95768. * @param invertY defines if data must be stored with Y axis inverted
  95769. */
  95770. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95771. /**
  95772. * Updates a depth texture Comparison Mode and Function.
  95773. * If the comparison Function is equal to 0, the mode will be set to none.
  95774. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95775. * @param texture The texture to set the comparison function for
  95776. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95777. */
  95778. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95779. /** @hidden */
  95780. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95781. width: number;
  95782. height: number;
  95783. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95784. /**
  95785. * Creates a depth stencil texture.
  95786. * This is only available in WebGL 2 or with the depth texture extension available.
  95787. * @param size The size of face edge in the texture.
  95788. * @param options The options defining the texture.
  95789. * @returns The texture
  95790. */
  95791. createDepthStencilTexture(size: number | {
  95792. width: number;
  95793. height: number;
  95794. }, options: DepthTextureCreationOptions): InternalTexture;
  95795. /**
  95796. * Creates a depth stencil texture.
  95797. * This is only available in WebGL 2 or with the depth texture extension available.
  95798. * @param size The size of face edge in the texture.
  95799. * @param options The options defining the texture.
  95800. * @returns The texture
  95801. */
  95802. private _createDepthStencilTexture;
  95803. /**
  95804. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95805. * @param renderTarget The render target to set the frame buffer for
  95806. */
  95807. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95808. /**
  95809. * Creates a new render target texture
  95810. * @param size defines the size of the texture
  95811. * @param options defines the options used to create the texture
  95812. * @returns a new render target texture stored in an InternalTexture
  95813. */
  95814. createRenderTargetTexture(size: number | {
  95815. width: number;
  95816. height: number;
  95817. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95818. /** @hidden */
  95819. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95820. /**
  95821. * Updates the sample count of a render target texture
  95822. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95823. * @param texture defines the texture to update
  95824. * @param samples defines the sample count to set
  95825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95826. */
  95827. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95828. /** @hidden */
  95829. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95830. /** @hidden */
  95831. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95832. /** @hidden */
  95833. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95834. /** @hidden */
  95835. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95836. /**
  95837. * @hidden
  95838. */
  95839. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95840. private _prepareWebGLTextureContinuation;
  95841. private _prepareWebGLTexture;
  95842. /** @hidden */
  95843. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95844. /** @hidden */
  95845. _releaseFramebufferObjects(texture: InternalTexture): void;
  95846. /** @hidden */
  95847. _releaseTexture(texture: InternalTexture): void;
  95848. private setProgram;
  95849. private _boundUniforms;
  95850. /**
  95851. * Binds an effect to the webGL context
  95852. * @param effect defines the effect to bind
  95853. */
  95854. bindSamplers(effect: Effect): void;
  95855. private _activateCurrentTexture;
  95856. /** @hidden */
  95857. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95858. /** @hidden */
  95859. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95860. /**
  95861. * Sets a texture to the webGL context from a postprocess
  95862. * @param channel defines the channel to use
  95863. * @param postProcess defines the source postprocess
  95864. */
  95865. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95866. /**
  95867. * Binds the output of the passed in post process to the texture channel specified
  95868. * @param channel The channel the texture should be bound to
  95869. * @param postProcess The post process which's output should be bound
  95870. */
  95871. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95872. /**
  95873. * Unbind all textures from the webGL context
  95874. */
  95875. unbindAllTextures(): void;
  95876. /**
  95877. * Sets a texture to the according uniform.
  95878. * @param channel The texture channel
  95879. * @param uniform The uniform to set
  95880. * @param texture The texture to apply
  95881. */
  95882. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95883. /**
  95884. * Sets a depth stencil texture from a render target to the according uniform.
  95885. * @param channel The texture channel
  95886. * @param uniform The uniform to set
  95887. * @param texture The render target texture containing the depth stencil texture to apply
  95888. */
  95889. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95890. private _bindSamplerUniformToChannel;
  95891. private _getTextureWrapMode;
  95892. private _setTexture;
  95893. /**
  95894. * Sets an array of texture to the webGL context
  95895. * @param channel defines the channel where the texture array must be set
  95896. * @param uniform defines the associated uniform location
  95897. * @param textures defines the array of textures to bind
  95898. */
  95899. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95900. /** @hidden */
  95901. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95902. private _setTextureParameterFloat;
  95903. private _setTextureParameterInteger;
  95904. /**
  95905. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95906. * @param x defines the x coordinate of the rectangle where pixels must be read
  95907. * @param y defines the y coordinate of the rectangle where pixels must be read
  95908. * @param width defines the width of the rectangle where pixels must be read
  95909. * @param height defines the height of the rectangle where pixels must be read
  95910. * @returns a Uint8Array containing RGBA colors
  95911. */
  95912. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95913. /**
  95914. * Add an externaly attached data from its key.
  95915. * This method call will fail and return false, if such key already exists.
  95916. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95917. * @param key the unique key that identifies the data
  95918. * @param data the data object to associate to the key for this Engine instance
  95919. * @return true if no such key were already present and the data was added successfully, false otherwise
  95920. */
  95921. addExternalData<T>(key: string, data: T): boolean;
  95922. /**
  95923. * Get an externaly attached data from its key
  95924. * @param key the unique key that identifies the data
  95925. * @return the associated data, if present (can be null), or undefined if not present
  95926. */
  95927. getExternalData<T>(key: string): T;
  95928. /**
  95929. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95930. * @param key the unique key that identifies the data
  95931. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95932. * @return the associated data, can be null if the factory returned null.
  95933. */
  95934. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95935. /**
  95936. * Remove an externaly attached data from the Engine instance
  95937. * @param key the unique key that identifies the data
  95938. * @return true if the data was successfully removed, false if it doesn't exist
  95939. */
  95940. removeExternalData(key: string): boolean;
  95941. /**
  95942. * Unbind all vertex attributes from the webGL context
  95943. */
  95944. unbindAllAttributes(): void;
  95945. /**
  95946. * 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
  95947. */
  95948. releaseEffects(): void;
  95949. /**
  95950. * Dispose and release all associated resources
  95951. */
  95952. dispose(): void;
  95953. /**
  95954. * Display the loading screen
  95955. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95956. */
  95957. displayLoadingUI(): void;
  95958. /**
  95959. * Hide the loading screen
  95960. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95961. */
  95962. hideLoadingUI(): void;
  95963. /**
  95964. * Gets the current loading screen object
  95965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95966. */
  95967. /**
  95968. * Sets the current loading screen object
  95969. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95970. */
  95971. loadingScreen: ILoadingScreen;
  95972. /**
  95973. * Sets the current loading screen text
  95974. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95975. */
  95976. loadingUIText: string;
  95977. /**
  95978. * Sets the current loading screen background color
  95979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95980. */
  95981. loadingUIBackgroundColor: string;
  95982. /**
  95983. * Attach a new callback raised when context lost event is fired
  95984. * @param callback defines the callback to call
  95985. */
  95986. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95987. /**
  95988. * Attach a new callback raised when context restored event is fired
  95989. * @param callback defines the callback to call
  95990. */
  95991. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95992. /**
  95993. * Gets the source code of the vertex shader associated with a specific webGL program
  95994. * @param program defines the program to use
  95995. * @returns a string containing the source code of the vertex shader associated with the program
  95996. */
  95997. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95998. /**
  95999. * Gets the source code of the fragment shader associated with a specific webGL program
  96000. * @param program defines the program to use
  96001. * @returns a string containing the source code of the fragment shader associated with the program
  96002. */
  96003. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96004. /**
  96005. * Get the current error code of the webGL context
  96006. * @returns the error code
  96007. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96008. */
  96009. getError(): number;
  96010. /**
  96011. * Gets the current framerate
  96012. * @returns a number representing the framerate
  96013. */
  96014. getFps(): number;
  96015. /**
  96016. * Gets the time spent between current and previous frame
  96017. * @returns a number representing the delta time in ms
  96018. */
  96019. getDeltaTime(): number;
  96020. private _measureFps;
  96021. /** @hidden */
  96022. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96023. private _canRenderToFloatFramebuffer;
  96024. private _canRenderToHalfFloatFramebuffer;
  96025. private _canRenderToFramebuffer;
  96026. /** @hidden */
  96027. _getWebGLTextureType(type: number): number;
  96028. /** @hidden */
  96029. _getInternalFormat(format: number): number;
  96030. /** @hidden */
  96031. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96032. /** @hidden */
  96033. _getRGBAMultiSampleBufferFormat(type: number): number;
  96034. /** @hidden */
  96035. _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;
  96036. /** @hidden */
  96037. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96038. /**
  96039. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96040. * @returns true if the engine can be created
  96041. * @ignorenaming
  96042. */
  96043. static isSupported(): boolean;
  96044. /**
  96045. * Find the next highest power of two.
  96046. * @param x Number to start search from.
  96047. * @return Next highest power of two.
  96048. */
  96049. static CeilingPOT(x: number): number;
  96050. /**
  96051. * Find the next lowest power of two.
  96052. * @param x Number to start search from.
  96053. * @return Next lowest power of two.
  96054. */
  96055. static FloorPOT(x: number): number;
  96056. /**
  96057. * Find the nearest power of two.
  96058. * @param x Number to start search from.
  96059. * @return Next nearest power of two.
  96060. */
  96061. static NearestPOT(x: number): number;
  96062. /**
  96063. * Get the closest exponent of two
  96064. * @param value defines the value to approximate
  96065. * @param max defines the maximum value to return
  96066. * @param mode defines how to define the closest value
  96067. * @returns closest exponent of two of the given value
  96068. */
  96069. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96070. /**
  96071. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96072. * @param func - the function to be called
  96073. * @param requester - the object that will request the next frame. Falls back to window.
  96074. * @returns frame number
  96075. */
  96076. static QueueNewFrame(func: () => void, requester?: any): number;
  96077. /**
  96078. * Ask the browser to promote the current element to pointerlock mode
  96079. * @param element defines the DOM element to promote
  96080. */
  96081. static _RequestPointerlock(element: HTMLElement): void;
  96082. /**
  96083. * Asks the browser to exit pointerlock mode
  96084. */
  96085. static _ExitPointerlock(): void;
  96086. /**
  96087. * Ask the browser to promote the current element to fullscreen rendering mode
  96088. * @param element defines the DOM element to promote
  96089. */
  96090. static _RequestFullscreen(element: HTMLElement): void;
  96091. /**
  96092. * Asks the browser to exit fullscreen mode
  96093. */
  96094. static _ExitFullscreen(): void;
  96095. }
  96096. }
  96097. declare module BABYLON {
  96098. /**
  96099. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96100. * during the life time of the application.
  96101. */
  96102. export class EngineStore {
  96103. /** Gets the list of created engines */
  96104. static Instances: Engine[];
  96105. /** @hidden */
  96106. static _LastCreatedScene: Nullable<Scene>;
  96107. /**
  96108. * Gets the latest created engine
  96109. */
  96110. static readonly LastCreatedEngine: Nullable<Engine>;
  96111. /**
  96112. * Gets the latest created scene
  96113. */
  96114. static readonly LastCreatedScene: Nullable<Scene>;
  96115. /**
  96116. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96117. * @ignorenaming
  96118. */
  96119. static UseFallbackTexture: boolean;
  96120. /**
  96121. * Texture content used if a texture cannot loaded
  96122. * @ignorenaming
  96123. */
  96124. static FallbackTexture: string;
  96125. }
  96126. }
  96127. declare module BABYLON {
  96128. /**
  96129. * Helper class that provides a small promise polyfill
  96130. */
  96131. export class PromisePolyfill {
  96132. /**
  96133. * Static function used to check if the polyfill is required
  96134. * If this is the case then the function will inject the polyfill to window.Promise
  96135. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96136. */
  96137. static Apply(force?: boolean): void;
  96138. }
  96139. }
  96140. declare module BABYLON {
  96141. /**
  96142. * Interface for screenshot methods with describe argument called `size` as object with options
  96143. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96144. */
  96145. export interface IScreenshotSize {
  96146. /**
  96147. * number in pixels for canvas height
  96148. */
  96149. height?: number;
  96150. /**
  96151. * multiplier allowing render at a higher or lower resolution
  96152. * If value is defined then height and width will be ignored and taken from camera
  96153. */
  96154. precision?: number;
  96155. /**
  96156. * number in pixels for canvas width
  96157. */
  96158. width?: number;
  96159. }
  96160. }
  96161. declare module BABYLON {
  96162. interface IColor4Like {
  96163. r: float;
  96164. g: float;
  96165. b: float;
  96166. a: float;
  96167. }
  96168. /**
  96169. * Class containing a set of static utilities functions
  96170. */
  96171. export class Tools {
  96172. /**
  96173. * Gets or sets the base URL to use to load assets
  96174. */
  96175. static BaseUrl: string;
  96176. /**
  96177. * Enable/Disable Custom HTTP Request Headers globally.
  96178. * default = false
  96179. * @see CustomRequestHeaders
  96180. */
  96181. static UseCustomRequestHeaders: boolean;
  96182. /**
  96183. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96184. * i.e. when loading files, where the server/service expects an Authorization header
  96185. */
  96186. static CustomRequestHeaders: {
  96187. [key: string]: string;
  96188. };
  96189. /**
  96190. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96191. */
  96192. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96193. /**
  96194. * Default behaviour for cors in the application.
  96195. * It can be a string if the expected behavior is identical in the entire app.
  96196. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96197. */
  96198. static CorsBehavior: string | ((url: string | string[]) => string);
  96199. /**
  96200. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96201. * @ignorenaming
  96202. */
  96203. static UseFallbackTexture: boolean;
  96204. /**
  96205. * Use this object to register external classes like custom textures or material
  96206. * to allow the laoders to instantiate them
  96207. */
  96208. static RegisteredExternalClasses: {
  96209. [key: string]: Object;
  96210. };
  96211. /**
  96212. * Texture content used if a texture cannot loaded
  96213. * @ignorenaming
  96214. */
  96215. static fallbackTexture: string;
  96216. /**
  96217. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96218. * @param u defines the coordinate on X axis
  96219. * @param v defines the coordinate on Y axis
  96220. * @param width defines the width of the source data
  96221. * @param height defines the height of the source data
  96222. * @param pixels defines the source byte array
  96223. * @param color defines the output color
  96224. */
  96225. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96226. /**
  96227. * Interpolates between a and b via alpha
  96228. * @param a The lower value (returned when alpha = 0)
  96229. * @param b The upper value (returned when alpha = 1)
  96230. * @param alpha The interpolation-factor
  96231. * @return The mixed value
  96232. */
  96233. static Mix(a: number, b: number, alpha: number): number;
  96234. /**
  96235. * Tries to instantiate a new object from a given class name
  96236. * @param className defines the class name to instantiate
  96237. * @returns the new object or null if the system was not able to do the instantiation
  96238. */
  96239. static Instantiate(className: string): any;
  96240. /**
  96241. * Provides a slice function that will work even on IE
  96242. * @param data defines the array to slice
  96243. * @param start defines the start of the data (optional)
  96244. * @param end defines the end of the data (optional)
  96245. * @returns the new sliced array
  96246. */
  96247. static Slice<T>(data: T, start?: number, end?: number): T;
  96248. /**
  96249. * Polyfill for setImmediate
  96250. * @param action defines the action to execute after the current execution block
  96251. */
  96252. static SetImmediate(action: () => void): void;
  96253. /**
  96254. * Function indicating if a number is an exponent of 2
  96255. * @param value defines the value to test
  96256. * @returns true if the value is an exponent of 2
  96257. */
  96258. static IsExponentOfTwo(value: number): boolean;
  96259. private static _tmpFloatArray;
  96260. /**
  96261. * Returns the nearest 32-bit single precision float representation of a Number
  96262. * @param value A Number. If the parameter is of a different type, it will get converted
  96263. * to a number or to NaN if it cannot be converted
  96264. * @returns number
  96265. */
  96266. static FloatRound(value: number): number;
  96267. /**
  96268. * Extracts the filename from a path
  96269. * @param path defines the path to use
  96270. * @returns the filename
  96271. */
  96272. static GetFilename(path: string): string;
  96273. /**
  96274. * Extracts the "folder" part of a path (everything before the filename).
  96275. * @param uri The URI to extract the info from
  96276. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96277. * @returns The "folder" part of the path
  96278. */
  96279. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96280. /**
  96281. * Extracts text content from a DOM element hierarchy
  96282. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96283. */
  96284. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96285. /**
  96286. * Convert an angle in radians to degrees
  96287. * @param angle defines the angle to convert
  96288. * @returns the angle in degrees
  96289. */
  96290. static ToDegrees(angle: number): number;
  96291. /**
  96292. * Convert an angle in degrees to radians
  96293. * @param angle defines the angle to convert
  96294. * @returns the angle in radians
  96295. */
  96296. static ToRadians(angle: number): number;
  96297. /**
  96298. * Encode a buffer to a base64 string
  96299. * @param buffer defines the buffer to encode
  96300. * @returns the encoded string
  96301. */
  96302. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96303. /**
  96304. * Returns an array if obj is not an array
  96305. * @param obj defines the object to evaluate as an array
  96306. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96307. * @returns either obj directly if obj is an array or a new array containing obj
  96308. */
  96309. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96310. /**
  96311. * Gets the pointer prefix to use
  96312. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96313. */
  96314. static GetPointerPrefix(): string;
  96315. /**
  96316. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96317. * @param url define the url we are trying
  96318. * @param element define the dom element where to configure the cors policy
  96319. */
  96320. static SetCorsBehavior(url: string | string[], element: {
  96321. crossOrigin: string | null;
  96322. }): void;
  96323. /**
  96324. * Removes unwanted characters from an url
  96325. * @param url defines the url to clean
  96326. * @returns the cleaned url
  96327. */
  96328. static CleanUrl(url: string): string;
  96329. /**
  96330. * Gets or sets a function used to pre-process url before using them to load assets
  96331. */
  96332. static PreprocessUrl: (url: string) => string;
  96333. /**
  96334. * Loads an image as an HTMLImageElement.
  96335. * @param input url string, ArrayBuffer, or Blob to load
  96336. * @param onLoad callback called when the image successfully loads
  96337. * @param onError callback called when the image fails to load
  96338. * @param offlineProvider offline provider for caching
  96339. * @returns the HTMLImageElement of the loaded image
  96340. */
  96341. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96342. /**
  96343. * Loads a file
  96344. * @param url url string, ArrayBuffer, or Blob to load
  96345. * @param onSuccess callback called when the file successfully loads
  96346. * @param onProgress callback called while file is loading (if the server supports this mode)
  96347. * @param offlineProvider defines the offline provider for caching
  96348. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96349. * @param onError callback called when the file fails to load
  96350. * @returns a file request object
  96351. */
  96352. 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;
  96353. /**
  96354. * Loads a file from a url
  96355. * @param url the file url to load
  96356. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96357. */
  96358. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96359. /**
  96360. * Load a script (identified by an url). When the url returns, the
  96361. * content of this file is added into a new script element, attached to the DOM (body element)
  96362. * @param scriptUrl defines the url of the script to laod
  96363. * @param onSuccess defines the callback called when the script is loaded
  96364. * @param onError defines the callback to call if an error occurs
  96365. * @param scriptId defines the id of the script element
  96366. */
  96367. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96368. /**
  96369. * Load an asynchronous script (identified by an url). When the url returns, the
  96370. * content of this file is added into a new script element, attached to the DOM (body element)
  96371. * @param scriptUrl defines the url of the script to laod
  96372. * @param scriptId defines the id of the script element
  96373. * @returns a promise request object
  96374. */
  96375. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96376. /**
  96377. * Loads a file from a blob
  96378. * @param fileToLoad defines the blob to use
  96379. * @param callback defines the callback to call when data is loaded
  96380. * @param progressCallback defines the callback to call during loading process
  96381. * @returns a file request object
  96382. */
  96383. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96384. /**
  96385. * Loads a file
  96386. * @param fileToLoad defines the file to load
  96387. * @param callback defines the callback to call when data is loaded
  96388. * @param progressCallBack defines the callback to call during loading process
  96389. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96390. * @returns a file request object
  96391. */
  96392. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96393. /**
  96394. * Creates a data url from a given string content
  96395. * @param content defines the content to convert
  96396. * @returns the new data url link
  96397. */
  96398. static FileAsURL(content: string): string;
  96399. /**
  96400. * Format the given number to a specific decimal format
  96401. * @param value defines the number to format
  96402. * @param decimals defines the number of decimals to use
  96403. * @returns the formatted string
  96404. */
  96405. static Format(value: number, decimals?: number): string;
  96406. /**
  96407. * Tries to copy an object by duplicating every property
  96408. * @param source defines the source object
  96409. * @param destination defines the target object
  96410. * @param doNotCopyList defines a list of properties to avoid
  96411. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96412. */
  96413. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96414. /**
  96415. * Gets a boolean indicating if the given object has no own property
  96416. * @param obj defines the object to test
  96417. * @returns true if object has no own property
  96418. */
  96419. static IsEmpty(obj: any): boolean;
  96420. /**
  96421. * Function used to register events at window level
  96422. * @param windowElement defines the Window object to use
  96423. * @param events defines the events to register
  96424. */
  96425. static RegisterTopRootEvents(windowElement: Window, events: {
  96426. name: string;
  96427. handler: Nullable<(e: FocusEvent) => any>;
  96428. }[]): void;
  96429. /**
  96430. * Function used to unregister events from window level
  96431. * @param windowElement defines the Window object to use
  96432. * @param events defines the events to unregister
  96433. */
  96434. static UnregisterTopRootEvents(windowElement: Window, events: {
  96435. name: string;
  96436. handler: Nullable<(e: FocusEvent) => any>;
  96437. }[]): void;
  96438. /**
  96439. * @ignore
  96440. */
  96441. static _ScreenshotCanvas: HTMLCanvasElement;
  96442. /**
  96443. * Dumps the current bound framebuffer
  96444. * @param width defines the rendering width
  96445. * @param height defines the rendering height
  96446. * @param engine defines the hosting engine
  96447. * @param successCallback defines the callback triggered once the data are available
  96448. * @param mimeType defines the mime type of the result
  96449. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96450. */
  96451. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96452. /**
  96453. * Converts the canvas data to blob.
  96454. * This acts as a polyfill for browsers not supporting the to blob function.
  96455. * @param canvas Defines the canvas to extract the data from
  96456. * @param successCallback Defines the callback triggered once the data are available
  96457. * @param mimeType Defines the mime type of the result
  96458. */
  96459. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96460. /**
  96461. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96462. * @param successCallback defines the callback triggered once the data are available
  96463. * @param mimeType defines the mime type of the result
  96464. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96465. */
  96466. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96467. /**
  96468. * Downloads a blob in the browser
  96469. * @param blob defines the blob to download
  96470. * @param fileName defines the name of the downloaded file
  96471. */
  96472. static Download(blob: Blob, fileName: string): void;
  96473. /**
  96474. * Captures a screenshot of the current rendering
  96475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96476. * @param engine defines the rendering engine
  96477. * @param camera defines the source camera
  96478. * @param size This parameter can be set to a single number or to an object with the
  96479. * following (optional) properties: precision, width, height. If a single number is passed,
  96480. * it will be used for both width and height. If an object is passed, the screenshot size
  96481. * will be derived from the parameters. The precision property is a multiplier allowing
  96482. * rendering at a higher or lower resolution
  96483. * @param successCallback defines the callback receives a single parameter which contains the
  96484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96485. * src parameter of an <img> to display it
  96486. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96487. * Check your browser for supported MIME types
  96488. */
  96489. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96490. /**
  96491. * Captures a screenshot of the current rendering
  96492. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96493. * @param engine defines the rendering engine
  96494. * @param camera defines the source camera
  96495. * @param size This parameter can be set to a single number or to an object with the
  96496. * following (optional) properties: precision, width, height. If a single number is passed,
  96497. * it will be used for both width and height. If an object is passed, the screenshot size
  96498. * will be derived from the parameters. The precision property is a multiplier allowing
  96499. * rendering at a higher or lower resolution
  96500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96501. * Check your browser for supported MIME types
  96502. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96503. * to the src parameter of an <img> to display it
  96504. */
  96505. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96506. /**
  96507. * Generates an image screenshot from the specified camera.
  96508. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96509. * @param engine The engine to use for rendering
  96510. * @param camera The camera to use for rendering
  96511. * @param size This parameter can be set to a single number or to an object with the
  96512. * following (optional) properties: precision, width, height. If a single number is passed,
  96513. * it will be used for both width and height. If an object is passed, the screenshot size
  96514. * will be derived from the parameters. The precision property is a multiplier allowing
  96515. * rendering at a higher or lower resolution
  96516. * @param successCallback The callback receives a single parameter which contains the
  96517. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96518. * src parameter of an <img> to display it
  96519. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96520. * Check your browser for supported MIME types
  96521. * @param samples Texture samples (default: 1)
  96522. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96523. * @param fileName A name for for the downloaded file.
  96524. */
  96525. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96526. /**
  96527. * Generates an image screenshot from the specified camera.
  96528. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96529. * @param engine The engine to use for rendering
  96530. * @param camera The camera to use for rendering
  96531. * @param size This parameter can be set to a single number or to an object with the
  96532. * following (optional) properties: precision, width, height. If a single number is passed,
  96533. * it will be used for both width and height. If an object is passed, the screenshot size
  96534. * will be derived from the parameters. The precision property is a multiplier allowing
  96535. * rendering at a higher or lower resolution
  96536. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96537. * Check your browser for supported MIME types
  96538. * @param samples Texture samples (default: 1)
  96539. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96540. * @param fileName A name for for the downloaded file.
  96541. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96542. * to the src parameter of an <img> to display it
  96543. */
  96544. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96545. /**
  96546. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96547. * Be aware Math.random() could cause collisions, but:
  96548. * "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"
  96549. * @returns a pseudo random id
  96550. */
  96551. static RandomId(): string;
  96552. /**
  96553. * Test if the given uri is a base64 string
  96554. * @param uri The uri to test
  96555. * @return True if the uri is a base64 string or false otherwise
  96556. */
  96557. static IsBase64(uri: string): boolean;
  96558. /**
  96559. * Decode the given base64 uri.
  96560. * @param uri The uri to decode
  96561. * @return The decoded base64 data.
  96562. */
  96563. static DecodeBase64(uri: string): ArrayBuffer;
  96564. /**
  96565. * Gets the absolute url.
  96566. * @param url the input url
  96567. * @return the absolute url
  96568. */
  96569. static GetAbsoluteUrl(url: string): string;
  96570. /**
  96571. * No log
  96572. */
  96573. static readonly NoneLogLevel: number;
  96574. /**
  96575. * Only message logs
  96576. */
  96577. static readonly MessageLogLevel: number;
  96578. /**
  96579. * Only warning logs
  96580. */
  96581. static readonly WarningLogLevel: number;
  96582. /**
  96583. * Only error logs
  96584. */
  96585. static readonly ErrorLogLevel: number;
  96586. /**
  96587. * All logs
  96588. */
  96589. static readonly AllLogLevel: number;
  96590. /**
  96591. * Gets a value indicating the number of loading errors
  96592. * @ignorenaming
  96593. */
  96594. static readonly errorsCount: number;
  96595. /**
  96596. * Callback called when a new log is added
  96597. */
  96598. static OnNewCacheEntry: (entry: string) => void;
  96599. /**
  96600. * Log a message to the console
  96601. * @param message defines the message to log
  96602. */
  96603. static Log(message: string): void;
  96604. /**
  96605. * Write a warning message to the console
  96606. * @param message defines the message to log
  96607. */
  96608. static Warn(message: string): void;
  96609. /**
  96610. * Write an error message to the console
  96611. * @param message defines the message to log
  96612. */
  96613. static Error(message: string): void;
  96614. /**
  96615. * Gets current log cache (list of logs)
  96616. */
  96617. static readonly LogCache: string;
  96618. /**
  96619. * Clears the log cache
  96620. */
  96621. static ClearLogCache(): void;
  96622. /**
  96623. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96624. */
  96625. static LogLevels: number;
  96626. /**
  96627. * Checks if the window object exists
  96628. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96629. */
  96630. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96631. /**
  96632. * No performance log
  96633. */
  96634. static readonly PerformanceNoneLogLevel: number;
  96635. /**
  96636. * Use user marks to log performance
  96637. */
  96638. static readonly PerformanceUserMarkLogLevel: number;
  96639. /**
  96640. * Log performance to the console
  96641. */
  96642. static readonly PerformanceConsoleLogLevel: number;
  96643. private static _performance;
  96644. /**
  96645. * Sets the current performance log level
  96646. */
  96647. static PerformanceLogLevel: number;
  96648. private static _StartPerformanceCounterDisabled;
  96649. private static _EndPerformanceCounterDisabled;
  96650. private static _StartUserMark;
  96651. private static _EndUserMark;
  96652. private static _StartPerformanceConsole;
  96653. private static _EndPerformanceConsole;
  96654. /**
  96655. * Starts a performance counter
  96656. */
  96657. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96658. /**
  96659. * Ends a specific performance coutner
  96660. */
  96661. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96662. /**
  96663. * Gets either window.performance.now() if supported or Date.now() else
  96664. */
  96665. static readonly Now: number;
  96666. /**
  96667. * This method will return the name of the class used to create the instance of the given object.
  96668. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96669. * @param object the object to get the class name from
  96670. * @param isType defines if the object is actually a type
  96671. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96672. */
  96673. static GetClassName(object: any, isType?: boolean): string;
  96674. /**
  96675. * Gets the first element of an array satisfying a given predicate
  96676. * @param array defines the array to browse
  96677. * @param predicate defines the predicate to use
  96678. * @returns null if not found or the element
  96679. */
  96680. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96681. /**
  96682. * This method will return the name of the full name of the class, including its owning module (if any).
  96683. * 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).
  96684. * @param object the object to get the class name from
  96685. * @param isType defines if the object is actually a type
  96686. * @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.
  96687. * @ignorenaming
  96688. */
  96689. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96690. /**
  96691. * Returns a promise that resolves after the given amount of time.
  96692. * @param delay Number of milliseconds to delay
  96693. * @returns Promise that resolves after the given amount of time
  96694. */
  96695. static DelayAsync(delay: number): Promise<void>;
  96696. }
  96697. /**
  96698. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96699. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96700. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96701. * @param name The name of the class, case should be preserved
  96702. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96703. */
  96704. export function className(name: string, module?: string): (target: Object) => void;
  96705. /**
  96706. * An implementation of a loop for asynchronous functions.
  96707. */
  96708. export class AsyncLoop {
  96709. /**
  96710. * Defines the number of iterations for the loop
  96711. */
  96712. iterations: number;
  96713. /**
  96714. * Defines the current index of the loop.
  96715. */
  96716. index: number;
  96717. private _done;
  96718. private _fn;
  96719. private _successCallback;
  96720. /**
  96721. * Constructor.
  96722. * @param iterations the number of iterations.
  96723. * @param func the function to run each iteration
  96724. * @param successCallback the callback that will be called upon succesful execution
  96725. * @param offset starting offset.
  96726. */
  96727. constructor(
  96728. /**
  96729. * Defines the number of iterations for the loop
  96730. */
  96731. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96732. /**
  96733. * Execute the next iteration. Must be called after the last iteration was finished.
  96734. */
  96735. executeNext(): void;
  96736. /**
  96737. * Break the loop and run the success callback.
  96738. */
  96739. breakLoop(): void;
  96740. /**
  96741. * Create and run an async loop.
  96742. * @param iterations the number of iterations.
  96743. * @param fn the function to run each iteration
  96744. * @param successCallback the callback that will be called upon succesful execution
  96745. * @param offset starting offset.
  96746. * @returns the created async loop object
  96747. */
  96748. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96749. /**
  96750. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96751. * @param iterations total number of iterations
  96752. * @param syncedIterations number of synchronous iterations in each async iteration.
  96753. * @param fn the function to call each iteration.
  96754. * @param callback a success call back that will be called when iterating stops.
  96755. * @param breakFunction a break condition (optional)
  96756. * @param timeout timeout settings for the setTimeout function. default - 0.
  96757. * @returns the created async loop object
  96758. */
  96759. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96760. }
  96761. }
  96762. declare module BABYLON {
  96763. /** @hidden */
  96764. export interface ICollisionCoordinator {
  96765. createCollider(): Collider;
  96766. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96767. init(scene: Scene): void;
  96768. }
  96769. /** @hidden */
  96770. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96771. private _scene;
  96772. private _scaledPosition;
  96773. private _scaledVelocity;
  96774. private _finalPosition;
  96775. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96776. createCollider(): Collider;
  96777. init(scene: Scene): void;
  96778. private _collideWithWorld;
  96779. }
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * Class used to manage all inputs for the scene.
  96784. */
  96785. export class InputManager {
  96786. /** The distance in pixel that you have to move to prevent some events */
  96787. static DragMovementThreshold: number;
  96788. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96789. static LongPressDelay: number;
  96790. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96791. static DoubleClickDelay: number;
  96792. /** If you need to check double click without raising a single click at first click, enable this flag */
  96793. static ExclusiveDoubleClickMode: boolean;
  96794. private _wheelEventName;
  96795. private _onPointerMove;
  96796. private _onPointerDown;
  96797. private _onPointerUp;
  96798. private _initClickEvent;
  96799. private _initActionManager;
  96800. private _delayedSimpleClick;
  96801. private _delayedSimpleClickTimeout;
  96802. private _previousDelayedSimpleClickTimeout;
  96803. private _meshPickProceed;
  96804. private _previousButtonPressed;
  96805. private _currentPickResult;
  96806. private _previousPickResult;
  96807. private _totalPointersPressed;
  96808. private _doubleClickOccured;
  96809. private _pointerOverMesh;
  96810. private _pickedDownMesh;
  96811. private _pickedUpMesh;
  96812. private _pointerX;
  96813. private _pointerY;
  96814. private _unTranslatedPointerX;
  96815. private _unTranslatedPointerY;
  96816. private _startingPointerPosition;
  96817. private _previousStartingPointerPosition;
  96818. private _startingPointerTime;
  96819. private _previousStartingPointerTime;
  96820. private _pointerCaptures;
  96821. private _onKeyDown;
  96822. private _onKeyUp;
  96823. private _onCanvasFocusObserver;
  96824. private _onCanvasBlurObserver;
  96825. private _scene;
  96826. /**
  96827. * Creates a new InputManager
  96828. * @param scene defines the hosting scene
  96829. */
  96830. constructor(scene: Scene);
  96831. /**
  96832. * Gets the mesh that is currently under the pointer
  96833. */
  96834. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96835. /**
  96836. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96837. */
  96838. readonly unTranslatedPointer: Vector2;
  96839. /**
  96840. * Gets or sets the current on-screen X position of the pointer
  96841. */
  96842. pointerX: number;
  96843. /**
  96844. * Gets or sets the current on-screen Y position of the pointer
  96845. */
  96846. pointerY: number;
  96847. private _updatePointerPosition;
  96848. private _processPointerMove;
  96849. private _setRayOnPointerInfo;
  96850. private _checkPrePointerObservable;
  96851. /**
  96852. * Use this method to simulate a pointer move on a mesh
  96853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96856. */
  96857. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96858. /**
  96859. * Use this method to simulate a pointer down on a mesh
  96860. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96861. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96862. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96863. */
  96864. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96865. private _processPointerDown;
  96866. /** @hidden */
  96867. _isPointerSwiping(): boolean;
  96868. /**
  96869. * Use this method to simulate a pointer up on a mesh
  96870. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96871. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96872. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96873. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96874. */
  96875. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96876. private _processPointerUp;
  96877. /**
  96878. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96879. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96880. * @returns true if the pointer was captured
  96881. */
  96882. isPointerCaptured(pointerId?: number): boolean;
  96883. /**
  96884. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96885. * @param attachUp defines if you want to attach events to pointerup
  96886. * @param attachDown defines if you want to attach events to pointerdown
  96887. * @param attachMove defines if you want to attach events to pointermove
  96888. */
  96889. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96890. /**
  96891. * Detaches all event handlers
  96892. */
  96893. detachControl(): void;
  96894. /**
  96895. * Force the value of meshUnderPointer
  96896. * @param mesh defines the mesh to use
  96897. */
  96898. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96899. /**
  96900. * Gets the mesh under the pointer
  96901. * @returns a Mesh or null if no mesh is under the pointer
  96902. */
  96903. getPointerOverMesh(): Nullable<AbstractMesh>;
  96904. }
  96905. }
  96906. declare module BABYLON {
  96907. /**
  96908. * Helper class used to generate session unique ID
  96909. */
  96910. export class UniqueIdGenerator {
  96911. private static _UniqueIdCounter;
  96912. /**
  96913. * Gets an unique (relatively to the current scene) Id
  96914. */
  96915. static readonly UniqueId: number;
  96916. }
  96917. }
  96918. declare module BABYLON {
  96919. /**
  96920. * This class defines the direct association between an animation and a target
  96921. */
  96922. export class TargetedAnimation {
  96923. /**
  96924. * Animation to perform
  96925. */
  96926. animation: Animation;
  96927. /**
  96928. * Target to animate
  96929. */
  96930. target: any;
  96931. /**
  96932. * Serialize the object
  96933. * @returns the JSON object representing the current entity
  96934. */
  96935. serialize(): any;
  96936. }
  96937. /**
  96938. * Use this class to create coordinated animations on multiple targets
  96939. */
  96940. export class AnimationGroup implements IDisposable {
  96941. /** The name of the animation group */
  96942. name: string;
  96943. private _scene;
  96944. private _targetedAnimations;
  96945. private _animatables;
  96946. private _from;
  96947. private _to;
  96948. private _isStarted;
  96949. private _isPaused;
  96950. private _speedRatio;
  96951. private _loopAnimation;
  96952. /**
  96953. * Gets or sets the unique id of the node
  96954. */
  96955. uniqueId: number;
  96956. /**
  96957. * This observable will notify when one animation have ended
  96958. */
  96959. onAnimationEndObservable: Observable<TargetedAnimation>;
  96960. /**
  96961. * Observer raised when one animation loops
  96962. */
  96963. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96964. /**
  96965. * This observable will notify when all animations have ended.
  96966. */
  96967. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96968. /**
  96969. * This observable will notify when all animations have paused.
  96970. */
  96971. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96972. /**
  96973. * This observable will notify when all animations are playing.
  96974. */
  96975. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96976. /**
  96977. * Gets the first frame
  96978. */
  96979. readonly from: number;
  96980. /**
  96981. * Gets the last frame
  96982. */
  96983. readonly to: number;
  96984. /**
  96985. * Define if the animations are started
  96986. */
  96987. readonly isStarted: boolean;
  96988. /**
  96989. * Gets a value indicating that the current group is playing
  96990. */
  96991. readonly isPlaying: boolean;
  96992. /**
  96993. * Gets or sets the speed ratio to use for all animations
  96994. */
  96995. /**
  96996. * Gets or sets the speed ratio to use for all animations
  96997. */
  96998. speedRatio: number;
  96999. /**
  97000. * Gets or sets if all animations should loop or not
  97001. */
  97002. loopAnimation: boolean;
  97003. /**
  97004. * Gets the targeted animations for this animation group
  97005. */
  97006. readonly targetedAnimations: Array<TargetedAnimation>;
  97007. /**
  97008. * returning the list of animatables controlled by this animation group.
  97009. */
  97010. readonly animatables: Array<Animatable>;
  97011. /**
  97012. * Instantiates a new Animation Group.
  97013. * This helps managing several animations at once.
  97014. * @see http://doc.babylonjs.com/how_to/group
  97015. * @param name Defines the name of the group
  97016. * @param scene Defines the scene the group belongs to
  97017. */
  97018. constructor(
  97019. /** The name of the animation group */
  97020. name: string, scene?: Nullable<Scene>);
  97021. /**
  97022. * Add an animation (with its target) in the group
  97023. * @param animation defines the animation we want to add
  97024. * @param target defines the target of the animation
  97025. * @returns the TargetedAnimation object
  97026. */
  97027. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97028. /**
  97029. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97030. * It can add constant keys at begin or end
  97031. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97032. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97033. * @returns the animation group
  97034. */
  97035. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97036. /**
  97037. * Start all animations on given targets
  97038. * @param loop defines if animations must loop
  97039. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97040. * @param from defines the from key (optional)
  97041. * @param to defines the to key (optional)
  97042. * @returns the current animation group
  97043. */
  97044. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97045. /**
  97046. * Pause all animations
  97047. * @returns the animation group
  97048. */
  97049. pause(): AnimationGroup;
  97050. /**
  97051. * Play all animations to initial state
  97052. * This function will start() the animations if they were not started or will restart() them if they were paused
  97053. * @param loop defines if animations must loop
  97054. * @returns the animation group
  97055. */
  97056. play(loop?: boolean): AnimationGroup;
  97057. /**
  97058. * Reset all animations to initial state
  97059. * @returns the animation group
  97060. */
  97061. reset(): AnimationGroup;
  97062. /**
  97063. * Restart animations from key 0
  97064. * @returns the animation group
  97065. */
  97066. restart(): AnimationGroup;
  97067. /**
  97068. * Stop all animations
  97069. * @returns the animation group
  97070. */
  97071. stop(): AnimationGroup;
  97072. /**
  97073. * Set animation weight for all animatables
  97074. * @param weight defines the weight to use
  97075. * @return the animationGroup
  97076. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97077. */
  97078. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97079. /**
  97080. * Synchronize and normalize all animatables with a source animatable
  97081. * @param root defines the root animatable to synchronize with
  97082. * @return the animationGroup
  97083. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97084. */
  97085. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97086. /**
  97087. * Goes to a specific frame in this animation group
  97088. * @param frame the frame number to go to
  97089. * @return the animationGroup
  97090. */
  97091. goToFrame(frame: number): AnimationGroup;
  97092. /**
  97093. * Dispose all associated resources
  97094. */
  97095. dispose(): void;
  97096. private _checkAnimationGroupEnded;
  97097. /**
  97098. * Clone the current animation group and returns a copy
  97099. * @param newName defines the name of the new group
  97100. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97101. * @returns the new aniamtion group
  97102. */
  97103. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97104. /**
  97105. * Serializes the animationGroup to an object
  97106. * @returns Serialized object
  97107. */
  97108. serialize(): any;
  97109. /**
  97110. * Returns a new AnimationGroup object parsed from the source provided.
  97111. * @param parsedAnimationGroup defines the source
  97112. * @param scene defines the scene that will receive the animationGroup
  97113. * @returns a new AnimationGroup
  97114. */
  97115. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97116. /**
  97117. * Returns the string "AnimationGroup"
  97118. * @returns "AnimationGroup"
  97119. */
  97120. getClassName(): string;
  97121. /**
  97122. * Creates a detailled string about the object
  97123. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97124. * @returns a string representing the object
  97125. */
  97126. toString(fullDetails?: boolean): string;
  97127. }
  97128. }
  97129. declare module BABYLON {
  97130. /**
  97131. * Define an interface for all classes that will hold resources
  97132. */
  97133. export interface IDisposable {
  97134. /**
  97135. * Releases all held resources
  97136. */
  97137. dispose(): void;
  97138. }
  97139. /** Interface defining initialization parameters for Scene class */
  97140. export interface SceneOptions {
  97141. /**
  97142. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97143. * It will improve performance when the number of geometries becomes important.
  97144. */
  97145. useGeometryUniqueIdsMap?: boolean;
  97146. /**
  97147. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97148. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97149. */
  97150. useMaterialMeshMap?: boolean;
  97151. /**
  97152. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97153. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97154. */
  97155. useClonedMeshhMap?: boolean;
  97156. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97157. virtual?: boolean;
  97158. }
  97159. /**
  97160. * Represents a scene to be rendered by the engine.
  97161. * @see http://doc.babylonjs.com/features/scene
  97162. */
  97163. export class Scene extends AbstractScene implements IAnimatable {
  97164. /** The fog is deactivated */
  97165. static readonly FOGMODE_NONE: number;
  97166. /** The fog density is following an exponential function */
  97167. static readonly FOGMODE_EXP: number;
  97168. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97169. static readonly FOGMODE_EXP2: number;
  97170. /** The fog density is following a linear function. */
  97171. static readonly FOGMODE_LINEAR: number;
  97172. /**
  97173. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97175. */
  97176. static MinDeltaTime: number;
  97177. /**
  97178. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97180. */
  97181. static MaxDeltaTime: number;
  97182. /**
  97183. * Factory used to create the default material.
  97184. * @param name The name of the material to create
  97185. * @param scene The scene to create the material for
  97186. * @returns The default material
  97187. */
  97188. static DefaultMaterialFactory(scene: Scene): Material;
  97189. /**
  97190. * Factory used to create the a collision coordinator.
  97191. * @returns The collision coordinator
  97192. */
  97193. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97194. /** @hidden */
  97195. _inputManager: InputManager;
  97196. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97197. cameraToUseForPointers: Nullable<Camera>;
  97198. /** @hidden */
  97199. readonly _isScene: boolean;
  97200. /**
  97201. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97202. */
  97203. autoClear: boolean;
  97204. /**
  97205. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97206. */
  97207. autoClearDepthAndStencil: boolean;
  97208. /**
  97209. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97210. */
  97211. clearColor: Color4;
  97212. /**
  97213. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97214. */
  97215. ambientColor: Color3;
  97216. /**
  97217. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97218. * It should only be one of the following (if not the default embedded one):
  97219. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97220. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97221. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97222. * The material properties need to be setup according to the type of texture in use.
  97223. */
  97224. environmentBRDFTexture: BaseTexture;
  97225. /** @hidden */
  97226. protected _environmentTexture: Nullable<BaseTexture>;
  97227. /**
  97228. * Texture used in all pbr material as the reflection texture.
  97229. * As in the majority of the scene they are the same (exception for multi room and so on),
  97230. * this is easier to reference from here than from all the materials.
  97231. */
  97232. /**
  97233. * Texture used in all pbr material as the reflection texture.
  97234. * As in the majority of the scene they are the same (exception for multi room and so on),
  97235. * this is easier to set here than in all the materials.
  97236. */
  97237. environmentTexture: Nullable<BaseTexture>;
  97238. /** @hidden */
  97239. protected _environmentIntensity: number;
  97240. /**
  97241. * Intensity of the environment in all pbr material.
  97242. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97243. * As in the majority of the scene they are the same (exception for multi room and so on),
  97244. * this is easier to reference from here than from all the materials.
  97245. */
  97246. /**
  97247. * Intensity of the environment in all pbr material.
  97248. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97249. * As in the majority of the scene they are the same (exception for multi room and so on),
  97250. * this is easier to set here than in all the materials.
  97251. */
  97252. environmentIntensity: number;
  97253. /** @hidden */
  97254. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97255. /**
  97256. * Default image processing configuration used either in the rendering
  97257. * Forward main pass or through the imageProcessingPostProcess if present.
  97258. * As in the majority of the scene they are the same (exception for multi camera),
  97259. * this is easier to reference from here than from all the materials and post process.
  97260. *
  97261. * No setter as we it is a shared configuration, you can set the values instead.
  97262. */
  97263. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97264. private _forceWireframe;
  97265. /**
  97266. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97267. */
  97268. forceWireframe: boolean;
  97269. private _forcePointsCloud;
  97270. /**
  97271. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97272. */
  97273. forcePointsCloud: boolean;
  97274. /**
  97275. * Gets or sets the active clipplane 1
  97276. */
  97277. clipPlane: Nullable<Plane>;
  97278. /**
  97279. * Gets or sets the active clipplane 2
  97280. */
  97281. clipPlane2: Nullable<Plane>;
  97282. /**
  97283. * Gets or sets the active clipplane 3
  97284. */
  97285. clipPlane3: Nullable<Plane>;
  97286. /**
  97287. * Gets or sets the active clipplane 4
  97288. */
  97289. clipPlane4: Nullable<Plane>;
  97290. /**
  97291. * Gets or sets a boolean indicating if animations are enabled
  97292. */
  97293. animationsEnabled: boolean;
  97294. private _animationPropertiesOverride;
  97295. /**
  97296. * Gets or sets the animation properties override
  97297. */
  97298. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97299. /**
  97300. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97301. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97302. */
  97303. useConstantAnimationDeltaTime: boolean;
  97304. /**
  97305. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97306. * Please note that it requires to run a ray cast through the scene on every frame
  97307. */
  97308. constantlyUpdateMeshUnderPointer: boolean;
  97309. /**
  97310. * Defines the HTML cursor to use when hovering over interactive elements
  97311. */
  97312. hoverCursor: string;
  97313. /**
  97314. * Defines the HTML default cursor to use (empty by default)
  97315. */
  97316. defaultCursor: string;
  97317. /**
  97318. * This is used to call preventDefault() on pointer down
  97319. * in order to block unwanted artifacts like system double clicks
  97320. */
  97321. preventDefaultOnPointerDown: boolean;
  97322. /**
  97323. * This is used to call preventDefault() on pointer up
  97324. * in order to block unwanted artifacts like system double clicks
  97325. */
  97326. preventDefaultOnPointerUp: boolean;
  97327. /**
  97328. * Gets or sets user defined metadata
  97329. */
  97330. metadata: any;
  97331. /**
  97332. * For internal use only. Please do not use.
  97333. */
  97334. reservedDataStore: any;
  97335. /**
  97336. * Gets the name of the plugin used to load this scene (null by default)
  97337. */
  97338. loadingPluginName: string;
  97339. /**
  97340. * Use this array to add regular expressions used to disable offline support for specific urls
  97341. */
  97342. disableOfflineSupportExceptionRules: RegExp[];
  97343. /**
  97344. * An event triggered when the scene is disposed.
  97345. */
  97346. onDisposeObservable: Observable<Scene>;
  97347. private _onDisposeObserver;
  97348. /** Sets a function to be executed when this scene is disposed. */
  97349. onDispose: () => void;
  97350. /**
  97351. * An event triggered before rendering the scene (right after animations and physics)
  97352. */
  97353. onBeforeRenderObservable: Observable<Scene>;
  97354. private _onBeforeRenderObserver;
  97355. /** Sets a function to be executed before rendering this scene */
  97356. beforeRender: Nullable<() => void>;
  97357. /**
  97358. * An event triggered after rendering the scene
  97359. */
  97360. onAfterRenderObservable: Observable<Scene>;
  97361. /**
  97362. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97363. */
  97364. onAfterRenderCameraObservable: Observable<Camera>;
  97365. private _onAfterRenderObserver;
  97366. /** Sets a function to be executed after rendering this scene */
  97367. afterRender: Nullable<() => void>;
  97368. /**
  97369. * An event triggered before animating the scene
  97370. */
  97371. onBeforeAnimationsObservable: Observable<Scene>;
  97372. /**
  97373. * An event triggered after animations processing
  97374. */
  97375. onAfterAnimationsObservable: Observable<Scene>;
  97376. /**
  97377. * An event triggered before draw calls are ready to be sent
  97378. */
  97379. onBeforeDrawPhaseObservable: Observable<Scene>;
  97380. /**
  97381. * An event triggered after draw calls have been sent
  97382. */
  97383. onAfterDrawPhaseObservable: Observable<Scene>;
  97384. /**
  97385. * An event triggered when the scene is ready
  97386. */
  97387. onReadyObservable: Observable<Scene>;
  97388. /**
  97389. * An event triggered before rendering a camera
  97390. */
  97391. onBeforeCameraRenderObservable: Observable<Camera>;
  97392. private _onBeforeCameraRenderObserver;
  97393. /** Sets a function to be executed before rendering a camera*/
  97394. beforeCameraRender: () => void;
  97395. /**
  97396. * An event triggered after rendering a camera
  97397. */
  97398. onAfterCameraRenderObservable: Observable<Camera>;
  97399. private _onAfterCameraRenderObserver;
  97400. /** Sets a function to be executed after rendering a camera*/
  97401. afterCameraRender: () => void;
  97402. /**
  97403. * An event triggered when active meshes evaluation is about to start
  97404. */
  97405. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97406. /**
  97407. * An event triggered when active meshes evaluation is done
  97408. */
  97409. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97410. /**
  97411. * An event triggered when particles rendering is about to start
  97412. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97413. */
  97414. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97415. /**
  97416. * An event triggered when particles rendering is done
  97417. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97418. */
  97419. onAfterParticlesRenderingObservable: Observable<Scene>;
  97420. /**
  97421. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97422. */
  97423. onDataLoadedObservable: Observable<Scene>;
  97424. /**
  97425. * An event triggered when a camera is created
  97426. */
  97427. onNewCameraAddedObservable: Observable<Camera>;
  97428. /**
  97429. * An event triggered when a camera is removed
  97430. */
  97431. onCameraRemovedObservable: Observable<Camera>;
  97432. /**
  97433. * An event triggered when a light is created
  97434. */
  97435. onNewLightAddedObservable: Observable<Light>;
  97436. /**
  97437. * An event triggered when a light is removed
  97438. */
  97439. onLightRemovedObservable: Observable<Light>;
  97440. /**
  97441. * An event triggered when a geometry is created
  97442. */
  97443. onNewGeometryAddedObservable: Observable<Geometry>;
  97444. /**
  97445. * An event triggered when a geometry is removed
  97446. */
  97447. onGeometryRemovedObservable: Observable<Geometry>;
  97448. /**
  97449. * An event triggered when a transform node is created
  97450. */
  97451. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97452. /**
  97453. * An event triggered when a transform node is removed
  97454. */
  97455. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97456. /**
  97457. * An event triggered when a mesh is created
  97458. */
  97459. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97460. /**
  97461. * An event triggered when a mesh is removed
  97462. */
  97463. onMeshRemovedObservable: Observable<AbstractMesh>;
  97464. /**
  97465. * An event triggered when a skeleton is created
  97466. */
  97467. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97468. /**
  97469. * An event triggered when a skeleton is removed
  97470. */
  97471. onSkeletonRemovedObservable: Observable<Skeleton>;
  97472. /**
  97473. * An event triggered when a material is created
  97474. */
  97475. onNewMaterialAddedObservable: Observable<Material>;
  97476. /**
  97477. * An event triggered when a material is removed
  97478. */
  97479. onMaterialRemovedObservable: Observable<Material>;
  97480. /**
  97481. * An event triggered when a texture is created
  97482. */
  97483. onNewTextureAddedObservable: Observable<BaseTexture>;
  97484. /**
  97485. * An event triggered when a texture is removed
  97486. */
  97487. onTextureRemovedObservable: Observable<BaseTexture>;
  97488. /**
  97489. * An event triggered when render targets are about to be rendered
  97490. * Can happen multiple times per frame.
  97491. */
  97492. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97493. /**
  97494. * An event triggered when render targets were rendered.
  97495. * Can happen multiple times per frame.
  97496. */
  97497. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97498. /**
  97499. * An event triggered before calculating deterministic simulation step
  97500. */
  97501. onBeforeStepObservable: Observable<Scene>;
  97502. /**
  97503. * An event triggered after calculating deterministic simulation step
  97504. */
  97505. onAfterStepObservable: Observable<Scene>;
  97506. /**
  97507. * An event triggered when the activeCamera property is updated
  97508. */
  97509. onActiveCameraChanged: Observable<Scene>;
  97510. /**
  97511. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97512. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97513. * 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)
  97514. */
  97515. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97516. /**
  97517. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97518. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97519. * 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)
  97520. */
  97521. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97522. /**
  97523. * This Observable will when a mesh has been imported into the scene.
  97524. */
  97525. onMeshImportedObservable: Observable<AbstractMesh>;
  97526. /**
  97527. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97528. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97529. */
  97530. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97531. /** @hidden */
  97532. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97533. /**
  97534. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97535. */
  97536. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97537. /**
  97538. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97539. */
  97540. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97541. /**
  97542. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97543. */
  97544. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97545. /** Callback called when a pointer move is detected */
  97546. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97547. /** Callback called when a pointer down is detected */
  97548. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97549. /** Callback called when a pointer up is detected */
  97550. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97551. /** Callback called when a pointer pick is detected */
  97552. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97553. /**
  97554. * 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).
  97555. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97556. */
  97557. onPrePointerObservable: Observable<PointerInfoPre>;
  97558. /**
  97559. * Observable event triggered each time an input event is received from the rendering canvas
  97560. */
  97561. onPointerObservable: Observable<PointerInfo>;
  97562. /**
  97563. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97564. */
  97565. readonly unTranslatedPointer: Vector2;
  97566. /**
  97567. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97568. */
  97569. static DragMovementThreshold: number;
  97570. /**
  97571. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97572. */
  97573. static LongPressDelay: number;
  97574. /**
  97575. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97576. */
  97577. static DoubleClickDelay: number;
  97578. /** If you need to check double click without raising a single click at first click, enable this flag */
  97579. static ExclusiveDoubleClickMode: boolean;
  97580. /** @hidden */
  97581. _mirroredCameraPosition: Nullable<Vector3>;
  97582. /**
  97583. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97584. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97585. */
  97586. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97587. /**
  97588. * Observable event triggered each time an keyboard event is received from the hosting window
  97589. */
  97590. onKeyboardObservable: Observable<KeyboardInfo>;
  97591. private _useRightHandedSystem;
  97592. /**
  97593. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97594. */
  97595. useRightHandedSystem: boolean;
  97596. private _timeAccumulator;
  97597. private _currentStepId;
  97598. private _currentInternalStep;
  97599. /**
  97600. * Sets the step Id used by deterministic lock step
  97601. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97602. * @param newStepId defines the step Id
  97603. */
  97604. setStepId(newStepId: number): void;
  97605. /**
  97606. * Gets the step Id used by deterministic lock step
  97607. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97608. * @returns the step Id
  97609. */
  97610. getStepId(): number;
  97611. /**
  97612. * Gets the internal step used by deterministic lock step
  97613. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97614. * @returns the internal step
  97615. */
  97616. getInternalStep(): number;
  97617. private _fogEnabled;
  97618. /**
  97619. * Gets or sets a boolean indicating if fog is enabled on this scene
  97620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97621. * (Default is true)
  97622. */
  97623. fogEnabled: boolean;
  97624. private _fogMode;
  97625. /**
  97626. * Gets or sets the fog mode to use
  97627. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97628. * | mode | value |
  97629. * | --- | --- |
  97630. * | FOGMODE_NONE | 0 |
  97631. * | FOGMODE_EXP | 1 |
  97632. * | FOGMODE_EXP2 | 2 |
  97633. * | FOGMODE_LINEAR | 3 |
  97634. */
  97635. fogMode: number;
  97636. /**
  97637. * Gets or sets the fog color to use
  97638. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97639. * (Default is Color3(0.2, 0.2, 0.3))
  97640. */
  97641. fogColor: Color3;
  97642. /**
  97643. * Gets or sets the fog density to use
  97644. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97645. * (Default is 0.1)
  97646. */
  97647. fogDensity: number;
  97648. /**
  97649. * Gets or sets the fog start distance to use
  97650. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97651. * (Default is 0)
  97652. */
  97653. fogStart: number;
  97654. /**
  97655. * Gets or sets the fog end distance to use
  97656. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97657. * (Default is 1000)
  97658. */
  97659. fogEnd: number;
  97660. private _shadowsEnabled;
  97661. /**
  97662. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97663. */
  97664. shadowsEnabled: boolean;
  97665. private _lightsEnabled;
  97666. /**
  97667. * Gets or sets a boolean indicating if lights are enabled on this scene
  97668. */
  97669. lightsEnabled: boolean;
  97670. /** All of the active cameras added to this scene. */
  97671. activeCameras: Camera[];
  97672. /** @hidden */
  97673. _activeCamera: Nullable<Camera>;
  97674. /** Gets or sets the current active camera */
  97675. activeCamera: Nullable<Camera>;
  97676. private _defaultMaterial;
  97677. /** The default material used on meshes when no material is affected */
  97678. /** The default material used on meshes when no material is affected */
  97679. defaultMaterial: Material;
  97680. private _texturesEnabled;
  97681. /**
  97682. * Gets or sets a boolean indicating if textures are enabled on this scene
  97683. */
  97684. texturesEnabled: boolean;
  97685. /**
  97686. * Gets or sets a boolean indicating if particles are enabled on this scene
  97687. */
  97688. particlesEnabled: boolean;
  97689. /**
  97690. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97691. */
  97692. spritesEnabled: boolean;
  97693. private _skeletonsEnabled;
  97694. /**
  97695. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97696. */
  97697. skeletonsEnabled: boolean;
  97698. /**
  97699. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97700. */
  97701. lensFlaresEnabled: boolean;
  97702. /**
  97703. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97705. */
  97706. collisionsEnabled: boolean;
  97707. private _collisionCoordinator;
  97708. /** @hidden */
  97709. readonly collisionCoordinator: ICollisionCoordinator;
  97710. /**
  97711. * Defines the gravity applied to this scene (used only for collisions)
  97712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97713. */
  97714. gravity: Vector3;
  97715. /**
  97716. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97717. */
  97718. postProcessesEnabled: boolean;
  97719. /**
  97720. * The list of postprocesses added to the scene
  97721. */
  97722. postProcesses: PostProcess[];
  97723. /**
  97724. * Gets the current postprocess manager
  97725. */
  97726. postProcessManager: PostProcessManager;
  97727. /**
  97728. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97729. */
  97730. renderTargetsEnabled: boolean;
  97731. /**
  97732. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97733. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97734. */
  97735. dumpNextRenderTargets: boolean;
  97736. /**
  97737. * The list of user defined render targets added to the scene
  97738. */
  97739. customRenderTargets: RenderTargetTexture[];
  97740. /**
  97741. * Defines if texture loading must be delayed
  97742. * If true, textures will only be loaded when they need to be rendered
  97743. */
  97744. useDelayedTextureLoading: boolean;
  97745. /**
  97746. * Gets the list of meshes imported to the scene through SceneLoader
  97747. */
  97748. importedMeshesFiles: String[];
  97749. /**
  97750. * Gets or sets a boolean indicating if probes are enabled on this scene
  97751. */
  97752. probesEnabled: boolean;
  97753. /**
  97754. * Gets or sets the current offline provider to use to store scene data
  97755. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97756. */
  97757. offlineProvider: IOfflineProvider;
  97758. /**
  97759. * Gets or sets the action manager associated with the scene
  97760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97761. */
  97762. actionManager: AbstractActionManager;
  97763. private _meshesForIntersections;
  97764. /**
  97765. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97766. */
  97767. proceduralTexturesEnabled: boolean;
  97768. private _engine;
  97769. private _totalVertices;
  97770. /** @hidden */
  97771. _activeIndices: PerfCounter;
  97772. /** @hidden */
  97773. _activeParticles: PerfCounter;
  97774. /** @hidden */
  97775. _activeBones: PerfCounter;
  97776. private _animationRatio;
  97777. /** @hidden */
  97778. _animationTimeLast: number;
  97779. /** @hidden */
  97780. _animationTime: number;
  97781. /**
  97782. * Gets or sets a general scale for animation speed
  97783. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97784. */
  97785. animationTimeScale: number;
  97786. /** @hidden */
  97787. _cachedMaterial: Nullable<Material>;
  97788. /** @hidden */
  97789. _cachedEffect: Nullable<Effect>;
  97790. /** @hidden */
  97791. _cachedVisibility: Nullable<number>;
  97792. private _renderId;
  97793. private _frameId;
  97794. private _executeWhenReadyTimeoutId;
  97795. private _intermediateRendering;
  97796. private _viewUpdateFlag;
  97797. private _projectionUpdateFlag;
  97798. /** @hidden */
  97799. _toBeDisposed: Nullable<IDisposable>[];
  97800. private _activeRequests;
  97801. /** @hidden */
  97802. _pendingData: any[];
  97803. private _isDisposed;
  97804. /**
  97805. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97806. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97807. */
  97808. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97809. private _activeMeshes;
  97810. private _processedMaterials;
  97811. private _renderTargets;
  97812. /** @hidden */
  97813. _activeParticleSystems: SmartArray<IParticleSystem>;
  97814. private _activeSkeletons;
  97815. private _softwareSkinnedMeshes;
  97816. private _renderingManager;
  97817. /** @hidden */
  97818. _activeAnimatables: Animatable[];
  97819. private _transformMatrix;
  97820. private _sceneUbo;
  97821. /** @hidden */
  97822. _viewMatrix: Matrix;
  97823. private _projectionMatrix;
  97824. /** @hidden */
  97825. _forcedViewPosition: Nullable<Vector3>;
  97826. /** @hidden */
  97827. _frustumPlanes: Plane[];
  97828. /**
  97829. * Gets the list of frustum planes (built from the active camera)
  97830. */
  97831. readonly frustumPlanes: Plane[];
  97832. /**
  97833. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97834. * This is useful if there are more lights that the maximum simulteanous authorized
  97835. */
  97836. requireLightSorting: boolean;
  97837. /** @hidden */
  97838. readonly useMaterialMeshMap: boolean;
  97839. /** @hidden */
  97840. readonly useClonedMeshhMap: boolean;
  97841. private _externalData;
  97842. private _uid;
  97843. /**
  97844. * @hidden
  97845. * Backing store of defined scene components.
  97846. */
  97847. _components: ISceneComponent[];
  97848. /**
  97849. * @hidden
  97850. * Backing store of defined scene components.
  97851. */
  97852. _serializableComponents: ISceneSerializableComponent[];
  97853. /**
  97854. * List of components to register on the next registration step.
  97855. */
  97856. private _transientComponents;
  97857. /**
  97858. * Registers the transient components if needed.
  97859. */
  97860. private _registerTransientComponents;
  97861. /**
  97862. * @hidden
  97863. * Add a component to the scene.
  97864. * Note that the ccomponent could be registered on th next frame if this is called after
  97865. * the register component stage.
  97866. * @param component Defines the component to add to the scene
  97867. */
  97868. _addComponent(component: ISceneComponent): void;
  97869. /**
  97870. * @hidden
  97871. * Gets a component from the scene.
  97872. * @param name defines the name of the component to retrieve
  97873. * @returns the component or null if not present
  97874. */
  97875. _getComponent(name: string): Nullable<ISceneComponent>;
  97876. /**
  97877. * @hidden
  97878. * Defines the actions happening before camera updates.
  97879. */
  97880. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97881. /**
  97882. * @hidden
  97883. * Defines the actions happening before clear the canvas.
  97884. */
  97885. _beforeClearStage: Stage<SimpleStageAction>;
  97886. /**
  97887. * @hidden
  97888. * Defines the actions when collecting render targets for the frame.
  97889. */
  97890. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97891. /**
  97892. * @hidden
  97893. * Defines the actions happening for one camera in the frame.
  97894. */
  97895. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97896. /**
  97897. * @hidden
  97898. * Defines the actions happening during the per mesh ready checks.
  97899. */
  97900. _isReadyForMeshStage: Stage<MeshStageAction>;
  97901. /**
  97902. * @hidden
  97903. * Defines the actions happening before evaluate active mesh checks.
  97904. */
  97905. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97906. /**
  97907. * @hidden
  97908. * Defines the actions happening during the evaluate sub mesh checks.
  97909. */
  97910. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97911. /**
  97912. * @hidden
  97913. * Defines the actions happening during the active mesh stage.
  97914. */
  97915. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97916. /**
  97917. * @hidden
  97918. * Defines the actions happening during the per camera render target step.
  97919. */
  97920. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97921. /**
  97922. * @hidden
  97923. * Defines the actions happening just before the active camera is drawing.
  97924. */
  97925. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97926. /**
  97927. * @hidden
  97928. * Defines the actions happening just before a render target is drawing.
  97929. */
  97930. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97931. /**
  97932. * @hidden
  97933. * Defines the actions happening just before a rendering group is drawing.
  97934. */
  97935. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97936. /**
  97937. * @hidden
  97938. * Defines the actions happening just before a mesh is drawing.
  97939. */
  97940. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97941. /**
  97942. * @hidden
  97943. * Defines the actions happening just after a mesh has been drawn.
  97944. */
  97945. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97946. /**
  97947. * @hidden
  97948. * Defines the actions happening just after a rendering group has been drawn.
  97949. */
  97950. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97951. /**
  97952. * @hidden
  97953. * Defines the actions happening just after the active camera has been drawn.
  97954. */
  97955. _afterCameraDrawStage: Stage<CameraStageAction>;
  97956. /**
  97957. * @hidden
  97958. * Defines the actions happening just after a render target has been drawn.
  97959. */
  97960. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97961. /**
  97962. * @hidden
  97963. * Defines the actions happening just after rendering all cameras and computing intersections.
  97964. */
  97965. _afterRenderStage: Stage<SimpleStageAction>;
  97966. /**
  97967. * @hidden
  97968. * Defines the actions happening when a pointer move event happens.
  97969. */
  97970. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97971. /**
  97972. * @hidden
  97973. * Defines the actions happening when a pointer down event happens.
  97974. */
  97975. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97976. /**
  97977. * @hidden
  97978. * Defines the actions happening when a pointer up event happens.
  97979. */
  97980. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97981. /**
  97982. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97983. */
  97984. private geometriesByUniqueId;
  97985. /**
  97986. * Creates a new Scene
  97987. * @param engine defines the engine to use to render this scene
  97988. * @param options defines the scene options
  97989. */
  97990. constructor(engine: Engine, options?: SceneOptions);
  97991. /**
  97992. * Gets a string idenfifying the name of the class
  97993. * @returns "Scene" string
  97994. */
  97995. getClassName(): string;
  97996. private _defaultMeshCandidates;
  97997. /**
  97998. * @hidden
  97999. */
  98000. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98001. private _defaultSubMeshCandidates;
  98002. /**
  98003. * @hidden
  98004. */
  98005. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98006. /**
  98007. * Sets the default candidate providers for the scene.
  98008. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98009. * and getCollidingSubMeshCandidates to their default function
  98010. */
  98011. setDefaultCandidateProviders(): void;
  98012. /**
  98013. * Gets the mesh that is currently under the pointer
  98014. */
  98015. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98016. /**
  98017. * Gets or sets the current on-screen X position of the pointer
  98018. */
  98019. pointerX: number;
  98020. /**
  98021. * Gets or sets the current on-screen Y position of the pointer
  98022. */
  98023. pointerY: number;
  98024. /**
  98025. * Gets the cached material (ie. the latest rendered one)
  98026. * @returns the cached material
  98027. */
  98028. getCachedMaterial(): Nullable<Material>;
  98029. /**
  98030. * Gets the cached effect (ie. the latest rendered one)
  98031. * @returns the cached effect
  98032. */
  98033. getCachedEffect(): Nullable<Effect>;
  98034. /**
  98035. * Gets the cached visibility state (ie. the latest rendered one)
  98036. * @returns the cached visibility state
  98037. */
  98038. getCachedVisibility(): Nullable<number>;
  98039. /**
  98040. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98041. * @param material defines the current material
  98042. * @param effect defines the current effect
  98043. * @param visibility defines the current visibility state
  98044. * @returns true if one parameter is not cached
  98045. */
  98046. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98047. /**
  98048. * Gets the engine associated with the scene
  98049. * @returns an Engine
  98050. */
  98051. getEngine(): Engine;
  98052. /**
  98053. * Gets the total number of vertices rendered per frame
  98054. * @returns the total number of vertices rendered per frame
  98055. */
  98056. getTotalVertices(): number;
  98057. /**
  98058. * Gets the performance counter for total vertices
  98059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98060. */
  98061. readonly totalVerticesPerfCounter: PerfCounter;
  98062. /**
  98063. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98064. * @returns the total number of active indices rendered per frame
  98065. */
  98066. getActiveIndices(): number;
  98067. /**
  98068. * Gets the performance counter for active indices
  98069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98070. */
  98071. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98072. /**
  98073. * Gets the total number of active particles rendered per frame
  98074. * @returns the total number of active particles rendered per frame
  98075. */
  98076. getActiveParticles(): number;
  98077. /**
  98078. * Gets the performance counter for active particles
  98079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98080. */
  98081. readonly activeParticlesPerfCounter: PerfCounter;
  98082. /**
  98083. * Gets the total number of active bones rendered per frame
  98084. * @returns the total number of active bones rendered per frame
  98085. */
  98086. getActiveBones(): number;
  98087. /**
  98088. * Gets the performance counter for active bones
  98089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98090. */
  98091. readonly activeBonesPerfCounter: PerfCounter;
  98092. /**
  98093. * Gets the array of active meshes
  98094. * @returns an array of AbstractMesh
  98095. */
  98096. getActiveMeshes(): SmartArray<AbstractMesh>;
  98097. /**
  98098. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98099. * @returns a number
  98100. */
  98101. getAnimationRatio(): number;
  98102. /**
  98103. * Gets an unique Id for the current render phase
  98104. * @returns a number
  98105. */
  98106. getRenderId(): number;
  98107. /**
  98108. * Gets an unique Id for the current frame
  98109. * @returns a number
  98110. */
  98111. getFrameId(): number;
  98112. /** Call this function if you want to manually increment the render Id*/
  98113. incrementRenderId(): void;
  98114. private _createUbo;
  98115. /**
  98116. * Use this method to simulate a pointer move on a mesh
  98117. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98118. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98119. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98120. * @returns the current scene
  98121. */
  98122. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98123. /**
  98124. * Use this method to simulate a pointer down on a mesh
  98125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98128. * @returns the current scene
  98129. */
  98130. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98131. /**
  98132. * Use this method to simulate a pointer up on a mesh
  98133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98136. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98137. * @returns the current scene
  98138. */
  98139. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98140. /**
  98141. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98142. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98143. * @returns true if the pointer was captured
  98144. */
  98145. isPointerCaptured(pointerId?: number): boolean;
  98146. /**
  98147. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98148. * @param attachUp defines if you want to attach events to pointerup
  98149. * @param attachDown defines if you want to attach events to pointerdown
  98150. * @param attachMove defines if you want to attach events to pointermove
  98151. */
  98152. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98153. /** Detaches all event handlers*/
  98154. detachControl(): void;
  98155. /**
  98156. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98157. * Delay loaded resources are not taking in account
  98158. * @return true if all required resources are ready
  98159. */
  98160. isReady(): boolean;
  98161. /** Resets all cached information relative to material (including effect and visibility) */
  98162. resetCachedMaterial(): void;
  98163. /**
  98164. * Registers a function to be called before every frame render
  98165. * @param func defines the function to register
  98166. */
  98167. registerBeforeRender(func: () => void): void;
  98168. /**
  98169. * Unregisters a function called before every frame render
  98170. * @param func defines the function to unregister
  98171. */
  98172. unregisterBeforeRender(func: () => void): void;
  98173. /**
  98174. * Registers a function to be called after every frame render
  98175. * @param func defines the function to register
  98176. */
  98177. registerAfterRender(func: () => void): void;
  98178. /**
  98179. * Unregisters a function called after every frame render
  98180. * @param func defines the function to unregister
  98181. */
  98182. unregisterAfterRender(func: () => void): void;
  98183. private _executeOnceBeforeRender;
  98184. /**
  98185. * The provided function will run before render once and will be disposed afterwards.
  98186. * A timeout delay can be provided so that the function will be executed in N ms.
  98187. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98188. * @param func The function to be executed.
  98189. * @param timeout optional delay in ms
  98190. */
  98191. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98192. /** @hidden */
  98193. _addPendingData(data: any): void;
  98194. /** @hidden */
  98195. _removePendingData(data: any): void;
  98196. /**
  98197. * Returns the number of items waiting to be loaded
  98198. * @returns the number of items waiting to be loaded
  98199. */
  98200. getWaitingItemsCount(): number;
  98201. /**
  98202. * Returns a boolean indicating if the scene is still loading data
  98203. */
  98204. readonly isLoading: boolean;
  98205. /**
  98206. * Registers a function to be executed when the scene is ready
  98207. * @param {Function} func - the function to be executed
  98208. */
  98209. executeWhenReady(func: () => void): void;
  98210. /**
  98211. * Returns a promise that resolves when the scene is ready
  98212. * @returns A promise that resolves when the scene is ready
  98213. */
  98214. whenReadyAsync(): Promise<void>;
  98215. /** @hidden */
  98216. _checkIsReady(): void;
  98217. /**
  98218. * Gets all animatable attached to the scene
  98219. */
  98220. readonly animatables: Animatable[];
  98221. /**
  98222. * Resets the last animation time frame.
  98223. * Useful to override when animations start running when loading a scene for the first time.
  98224. */
  98225. resetLastAnimationTimeFrame(): void;
  98226. /**
  98227. * Gets the current view matrix
  98228. * @returns a Matrix
  98229. */
  98230. getViewMatrix(): Matrix;
  98231. /**
  98232. * Gets the current projection matrix
  98233. * @returns a Matrix
  98234. */
  98235. getProjectionMatrix(): Matrix;
  98236. /**
  98237. * Gets the current transform matrix
  98238. * @returns a Matrix made of View * Projection
  98239. */
  98240. getTransformMatrix(): Matrix;
  98241. /**
  98242. * Sets the current transform matrix
  98243. * @param viewL defines the View matrix to use
  98244. * @param projectionL defines the Projection matrix to use
  98245. * @param viewR defines the right View matrix to use (if provided)
  98246. * @param projectionR defines the right Projection matrix to use (if provided)
  98247. */
  98248. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98249. /**
  98250. * Gets the uniform buffer used to store scene data
  98251. * @returns a UniformBuffer
  98252. */
  98253. getSceneUniformBuffer(): UniformBuffer;
  98254. /**
  98255. * Gets an unique (relatively to the current scene) Id
  98256. * @returns an unique number for the scene
  98257. */
  98258. getUniqueId(): number;
  98259. /**
  98260. * Add a mesh to the list of scene's meshes
  98261. * @param newMesh defines the mesh to add
  98262. * @param recursive if all child meshes should also be added to the scene
  98263. */
  98264. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98265. /**
  98266. * Remove a mesh for the list of scene's meshes
  98267. * @param toRemove defines the mesh to remove
  98268. * @param recursive if all child meshes should also be removed from the scene
  98269. * @returns the index where the mesh was in the mesh list
  98270. */
  98271. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98272. /**
  98273. * Add a transform node to the list of scene's transform nodes
  98274. * @param newTransformNode defines the transform node to add
  98275. */
  98276. addTransformNode(newTransformNode: TransformNode): void;
  98277. /**
  98278. * Remove a transform node for the list of scene's transform nodes
  98279. * @param toRemove defines the transform node to remove
  98280. * @returns the index where the transform node was in the transform node list
  98281. */
  98282. removeTransformNode(toRemove: TransformNode): number;
  98283. /**
  98284. * Remove a skeleton for the list of scene's skeletons
  98285. * @param toRemove defines the skeleton to remove
  98286. * @returns the index where the skeleton was in the skeleton list
  98287. */
  98288. removeSkeleton(toRemove: Skeleton): number;
  98289. /**
  98290. * Remove a morph target for the list of scene's morph targets
  98291. * @param toRemove defines the morph target to remove
  98292. * @returns the index where the morph target was in the morph target list
  98293. */
  98294. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98295. /**
  98296. * Remove a light for the list of scene's lights
  98297. * @param toRemove defines the light to remove
  98298. * @returns the index where the light was in the light list
  98299. */
  98300. removeLight(toRemove: Light): number;
  98301. /**
  98302. * Remove a camera for the list of scene's cameras
  98303. * @param toRemove defines the camera to remove
  98304. * @returns the index where the camera was in the camera list
  98305. */
  98306. removeCamera(toRemove: Camera): number;
  98307. /**
  98308. * Remove a particle system for the list of scene's particle systems
  98309. * @param toRemove defines the particle system to remove
  98310. * @returns the index where the particle system was in the particle system list
  98311. */
  98312. removeParticleSystem(toRemove: IParticleSystem): number;
  98313. /**
  98314. * Remove a animation for the list of scene's animations
  98315. * @param toRemove defines the animation to remove
  98316. * @returns the index where the animation was in the animation list
  98317. */
  98318. removeAnimation(toRemove: Animation): number;
  98319. /**
  98320. * Will stop the animation of the given target
  98321. * @param target - the target
  98322. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98323. * @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)
  98324. */
  98325. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98326. /**
  98327. * Removes the given animation group from this scene.
  98328. * @param toRemove The animation group to remove
  98329. * @returns The index of the removed animation group
  98330. */
  98331. removeAnimationGroup(toRemove: AnimationGroup): number;
  98332. /**
  98333. * Removes the given multi-material from this scene.
  98334. * @param toRemove The multi-material to remove
  98335. * @returns The index of the removed multi-material
  98336. */
  98337. removeMultiMaterial(toRemove: MultiMaterial): number;
  98338. /**
  98339. * Removes the given material from this scene.
  98340. * @param toRemove The material to remove
  98341. * @returns The index of the removed material
  98342. */
  98343. removeMaterial(toRemove: Material): number;
  98344. /**
  98345. * Removes the given action manager from this scene.
  98346. * @param toRemove The action manager to remove
  98347. * @returns The index of the removed action manager
  98348. */
  98349. removeActionManager(toRemove: AbstractActionManager): number;
  98350. /**
  98351. * Removes the given texture from this scene.
  98352. * @param toRemove The texture to remove
  98353. * @returns The index of the removed texture
  98354. */
  98355. removeTexture(toRemove: BaseTexture): number;
  98356. /**
  98357. * Adds the given light to this scene
  98358. * @param newLight The light to add
  98359. */
  98360. addLight(newLight: Light): void;
  98361. /**
  98362. * Sorts the list list based on light priorities
  98363. */
  98364. sortLightsByPriority(): void;
  98365. /**
  98366. * Adds the given camera to this scene
  98367. * @param newCamera The camera to add
  98368. */
  98369. addCamera(newCamera: Camera): void;
  98370. /**
  98371. * Adds the given skeleton to this scene
  98372. * @param newSkeleton The skeleton to add
  98373. */
  98374. addSkeleton(newSkeleton: Skeleton): void;
  98375. /**
  98376. * Adds the given particle system to this scene
  98377. * @param newParticleSystem The particle system to add
  98378. */
  98379. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98380. /**
  98381. * Adds the given animation to this scene
  98382. * @param newAnimation The animation to add
  98383. */
  98384. addAnimation(newAnimation: Animation): void;
  98385. /**
  98386. * Adds the given animation group to this scene.
  98387. * @param newAnimationGroup The animation group to add
  98388. */
  98389. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98390. /**
  98391. * Adds the given multi-material to this scene
  98392. * @param newMultiMaterial The multi-material to add
  98393. */
  98394. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98395. /**
  98396. * Adds the given material to this scene
  98397. * @param newMaterial The material to add
  98398. */
  98399. addMaterial(newMaterial: Material): void;
  98400. /**
  98401. * Adds the given morph target to this scene
  98402. * @param newMorphTargetManager The morph target to add
  98403. */
  98404. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98405. /**
  98406. * Adds the given geometry to this scene
  98407. * @param newGeometry The geometry to add
  98408. */
  98409. addGeometry(newGeometry: Geometry): void;
  98410. /**
  98411. * Adds the given action manager to this scene
  98412. * @param newActionManager The action manager to add
  98413. */
  98414. addActionManager(newActionManager: AbstractActionManager): void;
  98415. /**
  98416. * Adds the given texture to this scene.
  98417. * @param newTexture The texture to add
  98418. */
  98419. addTexture(newTexture: BaseTexture): void;
  98420. /**
  98421. * Switch active camera
  98422. * @param newCamera defines the new active camera
  98423. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98424. */
  98425. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98426. /**
  98427. * sets the active camera of the scene using its ID
  98428. * @param id defines the camera's ID
  98429. * @return the new active camera or null if none found.
  98430. */
  98431. setActiveCameraByID(id: string): Nullable<Camera>;
  98432. /**
  98433. * sets the active camera of the scene using its name
  98434. * @param name defines the camera's name
  98435. * @returns the new active camera or null if none found.
  98436. */
  98437. setActiveCameraByName(name: string): Nullable<Camera>;
  98438. /**
  98439. * get an animation group using its name
  98440. * @param name defines the material's name
  98441. * @return the animation group or null if none found.
  98442. */
  98443. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98444. /**
  98445. * Get a material using its unique id
  98446. * @param uniqueId defines the material's unique id
  98447. * @return the material or null if none found.
  98448. */
  98449. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98450. /**
  98451. * get a material using its id
  98452. * @param id defines the material's ID
  98453. * @return the material or null if none found.
  98454. */
  98455. getMaterialByID(id: string): Nullable<Material>;
  98456. /**
  98457. * Gets a the last added material using a given id
  98458. * @param id defines the material's ID
  98459. * @return the last material with the given id or null if none found.
  98460. */
  98461. getLastMaterialByID(id: string): Nullable<Material>;
  98462. /**
  98463. * Gets a material using its name
  98464. * @param name defines the material's name
  98465. * @return the material or null if none found.
  98466. */
  98467. getMaterialByName(name: string): Nullable<Material>;
  98468. /**
  98469. * Get a texture using its unique id
  98470. * @param uniqueId defines the texture's unique id
  98471. * @return the texture or null if none found.
  98472. */
  98473. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98474. /**
  98475. * Gets a camera using its id
  98476. * @param id defines the id to look for
  98477. * @returns the camera or null if not found
  98478. */
  98479. getCameraByID(id: string): Nullable<Camera>;
  98480. /**
  98481. * Gets a camera using its unique id
  98482. * @param uniqueId defines the unique id to look for
  98483. * @returns the camera or null if not found
  98484. */
  98485. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98486. /**
  98487. * Gets a camera using its name
  98488. * @param name defines the camera's name
  98489. * @return the camera or null if none found.
  98490. */
  98491. getCameraByName(name: string): Nullable<Camera>;
  98492. /**
  98493. * Gets a bone using its id
  98494. * @param id defines the bone's id
  98495. * @return the bone or null if not found
  98496. */
  98497. getBoneByID(id: string): Nullable<Bone>;
  98498. /**
  98499. * Gets a bone using its id
  98500. * @param name defines the bone's name
  98501. * @return the bone or null if not found
  98502. */
  98503. getBoneByName(name: string): Nullable<Bone>;
  98504. /**
  98505. * Gets a light node using its name
  98506. * @param name defines the the light's name
  98507. * @return the light or null if none found.
  98508. */
  98509. getLightByName(name: string): Nullable<Light>;
  98510. /**
  98511. * Gets a light node using its id
  98512. * @param id defines the light's id
  98513. * @return the light or null if none found.
  98514. */
  98515. getLightByID(id: string): Nullable<Light>;
  98516. /**
  98517. * Gets a light node using its scene-generated unique ID
  98518. * @param uniqueId defines the light's unique id
  98519. * @return the light or null if none found.
  98520. */
  98521. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98522. /**
  98523. * Gets a particle system by id
  98524. * @param id defines the particle system id
  98525. * @return the corresponding system or null if none found
  98526. */
  98527. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98528. /**
  98529. * Gets a geometry using its ID
  98530. * @param id defines the geometry's id
  98531. * @return the geometry or null if none found.
  98532. */
  98533. getGeometryByID(id: string): Nullable<Geometry>;
  98534. private _getGeometryByUniqueID;
  98535. /**
  98536. * Add a new geometry to this scene
  98537. * @param geometry defines the geometry to be added to the scene.
  98538. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98539. * @return a boolean defining if the geometry was added or not
  98540. */
  98541. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98542. /**
  98543. * Removes an existing geometry
  98544. * @param geometry defines the geometry to be removed from the scene
  98545. * @return a boolean defining if the geometry was removed or not
  98546. */
  98547. removeGeometry(geometry: Geometry): boolean;
  98548. /**
  98549. * Gets the list of geometries attached to the scene
  98550. * @returns an array of Geometry
  98551. */
  98552. getGeometries(): Geometry[];
  98553. /**
  98554. * Gets the first added mesh found of a given ID
  98555. * @param id defines the id to search for
  98556. * @return the mesh found or null if not found at all
  98557. */
  98558. getMeshByID(id: string): Nullable<AbstractMesh>;
  98559. /**
  98560. * Gets a list of meshes using their id
  98561. * @param id defines the id to search for
  98562. * @returns a list of meshes
  98563. */
  98564. getMeshesByID(id: string): Array<AbstractMesh>;
  98565. /**
  98566. * Gets the first added transform node found of a given ID
  98567. * @param id defines the id to search for
  98568. * @return the found transform node or null if not found at all.
  98569. */
  98570. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98571. /**
  98572. * Gets a transform node with its auto-generated unique id
  98573. * @param uniqueId efines the unique id to search for
  98574. * @return the found transform node or null if not found at all.
  98575. */
  98576. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98577. /**
  98578. * Gets a list of transform nodes using their id
  98579. * @param id defines the id to search for
  98580. * @returns a list of transform nodes
  98581. */
  98582. getTransformNodesByID(id: string): Array<TransformNode>;
  98583. /**
  98584. * Gets a mesh with its auto-generated unique id
  98585. * @param uniqueId defines the unique id to search for
  98586. * @return the found mesh or null if not found at all.
  98587. */
  98588. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98589. /**
  98590. * Gets a the last added mesh using a given id
  98591. * @param id defines the id to search for
  98592. * @return the found mesh or null if not found at all.
  98593. */
  98594. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98595. /**
  98596. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98597. * @param id defines the id to search for
  98598. * @return the found node or null if not found at all
  98599. */
  98600. getLastEntryByID(id: string): Nullable<Node>;
  98601. /**
  98602. * Gets a node (Mesh, Camera, Light) using a given id
  98603. * @param id defines the id to search for
  98604. * @return the found node or null if not found at all
  98605. */
  98606. getNodeByID(id: string): Nullable<Node>;
  98607. /**
  98608. * Gets a node (Mesh, Camera, Light) using a given name
  98609. * @param name defines the name to search for
  98610. * @return the found node or null if not found at all.
  98611. */
  98612. getNodeByName(name: string): Nullable<Node>;
  98613. /**
  98614. * Gets a mesh using a given name
  98615. * @param name defines the name to search for
  98616. * @return the found mesh or null if not found at all.
  98617. */
  98618. getMeshByName(name: string): Nullable<AbstractMesh>;
  98619. /**
  98620. * Gets a transform node using a given name
  98621. * @param name defines the name to search for
  98622. * @return the found transform node or null if not found at all.
  98623. */
  98624. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98625. /**
  98626. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98627. * @param id defines the id to search for
  98628. * @return the found skeleton or null if not found at all.
  98629. */
  98630. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98631. /**
  98632. * Gets a skeleton using a given auto generated unique id
  98633. * @param uniqueId defines the unique id to search for
  98634. * @return the found skeleton or null if not found at all.
  98635. */
  98636. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98637. /**
  98638. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98639. * @param id defines the id to search for
  98640. * @return the found skeleton or null if not found at all.
  98641. */
  98642. getSkeletonById(id: string): Nullable<Skeleton>;
  98643. /**
  98644. * Gets a skeleton using a given name
  98645. * @param name defines the name to search for
  98646. * @return the found skeleton or null if not found at all.
  98647. */
  98648. getSkeletonByName(name: string): Nullable<Skeleton>;
  98649. /**
  98650. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98651. * @param id defines the id to search for
  98652. * @return the found morph target manager or null if not found at all.
  98653. */
  98654. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98655. /**
  98656. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98657. * @param id defines the id to search for
  98658. * @return the found morph target or null if not found at all.
  98659. */
  98660. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98661. /**
  98662. * Gets a boolean indicating if the given mesh is active
  98663. * @param mesh defines the mesh to look for
  98664. * @returns true if the mesh is in the active list
  98665. */
  98666. isActiveMesh(mesh: AbstractMesh): boolean;
  98667. /**
  98668. * Return a unique id as a string which can serve as an identifier for the scene
  98669. */
  98670. readonly uid: string;
  98671. /**
  98672. * Add an externaly attached data from its key.
  98673. * This method call will fail and return false, if such key already exists.
  98674. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98675. * @param key the unique key that identifies the data
  98676. * @param data the data object to associate to the key for this Engine instance
  98677. * @return true if no such key were already present and the data was added successfully, false otherwise
  98678. */
  98679. addExternalData<T>(key: string, data: T): boolean;
  98680. /**
  98681. * Get an externaly attached data from its key
  98682. * @param key the unique key that identifies the data
  98683. * @return the associated data, if present (can be null), or undefined if not present
  98684. */
  98685. getExternalData<T>(key: string): Nullable<T>;
  98686. /**
  98687. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98688. * @param key the unique key that identifies the data
  98689. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98690. * @return the associated data, can be null if the factory returned null.
  98691. */
  98692. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98693. /**
  98694. * Remove an externaly attached data from the Engine instance
  98695. * @param key the unique key that identifies the data
  98696. * @return true if the data was successfully removed, false if it doesn't exist
  98697. */
  98698. removeExternalData(key: string): boolean;
  98699. private _evaluateSubMesh;
  98700. /**
  98701. * Clear the processed materials smart array preventing retention point in material dispose.
  98702. */
  98703. freeProcessedMaterials(): void;
  98704. private _preventFreeActiveMeshesAndRenderingGroups;
  98705. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98706. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98707. * when disposing several meshes in a row or a hierarchy of meshes.
  98708. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98709. */
  98710. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98711. /**
  98712. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98713. */
  98714. freeActiveMeshes(): void;
  98715. /**
  98716. * Clear the info related to rendering groups preventing retention points during dispose.
  98717. */
  98718. freeRenderingGroups(): void;
  98719. /** @hidden */
  98720. _isInIntermediateRendering(): boolean;
  98721. /**
  98722. * Lambda returning the list of potentially active meshes.
  98723. */
  98724. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98725. /**
  98726. * Lambda returning the list of potentially active sub meshes.
  98727. */
  98728. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98729. /**
  98730. * Lambda returning the list of potentially intersecting sub meshes.
  98731. */
  98732. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98733. /**
  98734. * Lambda returning the list of potentially colliding sub meshes.
  98735. */
  98736. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98737. private _activeMeshesFrozen;
  98738. /**
  98739. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98740. * @returns the current scene
  98741. */
  98742. freezeActiveMeshes(): Scene;
  98743. /**
  98744. * Use this function to restart evaluating active meshes on every frame
  98745. * @returns the current scene
  98746. */
  98747. unfreezeActiveMeshes(): Scene;
  98748. private _evaluateActiveMeshes;
  98749. private _activeMesh;
  98750. /**
  98751. * Update the transform matrix to update from the current active camera
  98752. * @param force defines a boolean used to force the update even if cache is up to date
  98753. */
  98754. updateTransformMatrix(force?: boolean): void;
  98755. private _bindFrameBuffer;
  98756. /** @hidden */
  98757. _allowPostProcessClearColor: boolean;
  98758. /** @hidden */
  98759. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98760. private _processSubCameras;
  98761. private _checkIntersections;
  98762. /** @hidden */
  98763. _advancePhysicsEngineStep(step: number): void;
  98764. /**
  98765. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98766. */
  98767. getDeterministicFrameTime: () => number;
  98768. /** @hidden */
  98769. _animate(): void;
  98770. /** Execute all animations (for a frame) */
  98771. animate(): void;
  98772. /**
  98773. * Render the scene
  98774. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98775. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98776. */
  98777. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98778. /**
  98779. * Freeze all materials
  98780. * A frozen material will not be updatable but should be faster to render
  98781. */
  98782. freezeMaterials(): void;
  98783. /**
  98784. * Unfreeze all materials
  98785. * A frozen material will not be updatable but should be faster to render
  98786. */
  98787. unfreezeMaterials(): void;
  98788. /**
  98789. * Releases all held ressources
  98790. */
  98791. dispose(): void;
  98792. /**
  98793. * Gets if the scene is already disposed
  98794. */
  98795. readonly isDisposed: boolean;
  98796. /**
  98797. * Call this function to reduce memory footprint of the scene.
  98798. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98799. */
  98800. clearCachedVertexData(): void;
  98801. /**
  98802. * This function will remove the local cached buffer data from texture.
  98803. * It will save memory but will prevent the texture from being rebuilt
  98804. */
  98805. cleanCachedTextureBuffer(): void;
  98806. /**
  98807. * Get the world extend vectors with an optional filter
  98808. *
  98809. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98810. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98811. */
  98812. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98813. min: Vector3;
  98814. max: Vector3;
  98815. };
  98816. /**
  98817. * Creates a ray that can be used to pick in the scene
  98818. * @param x defines the x coordinate of the origin (on-screen)
  98819. * @param y defines the y coordinate of the origin (on-screen)
  98820. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98821. * @param camera defines the camera to use for the picking
  98822. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98823. * @returns a Ray
  98824. */
  98825. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98826. /**
  98827. * Creates a ray that can be used to pick in the scene
  98828. * @param x defines the x coordinate of the origin (on-screen)
  98829. * @param y defines the y coordinate of the origin (on-screen)
  98830. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98831. * @param result defines the ray where to store the picking ray
  98832. * @param camera defines the camera to use for the picking
  98833. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98834. * @returns the current scene
  98835. */
  98836. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98837. /**
  98838. * Creates a ray that can be used to pick in the scene
  98839. * @param x defines the x coordinate of the origin (on-screen)
  98840. * @param y defines the y coordinate of the origin (on-screen)
  98841. * @param camera defines the camera to use for the picking
  98842. * @returns a Ray
  98843. */
  98844. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98845. /**
  98846. * Creates a ray that can be used to pick in the scene
  98847. * @param x defines the x coordinate of the origin (on-screen)
  98848. * @param y defines the y coordinate of the origin (on-screen)
  98849. * @param result defines the ray where to store the picking ray
  98850. * @param camera defines the camera to use for the picking
  98851. * @returns the current scene
  98852. */
  98853. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98854. /** Launch a ray to try to pick a mesh in the scene
  98855. * @param x position on screen
  98856. * @param y position on screen
  98857. * @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
  98858. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98859. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98861. * @returns a PickingInfo
  98862. */
  98863. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98864. /** Use the given ray to pick a mesh in the scene
  98865. * @param ray The ray to use to pick meshes
  98866. * @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
  98867. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98868. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98869. * @returns a PickingInfo
  98870. */
  98871. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98872. /**
  98873. * Launch a ray to try to pick a mesh in the scene
  98874. * @param x X position on screen
  98875. * @param y Y position on screen
  98876. * @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
  98877. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98879. * @returns an array of PickingInfo
  98880. */
  98881. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98882. /**
  98883. * Launch a ray to try to pick a mesh in the scene
  98884. * @param ray Ray to use
  98885. * @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
  98886. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98887. * @returns an array of PickingInfo
  98888. */
  98889. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98890. /**
  98891. * Force the value of meshUnderPointer
  98892. * @param mesh defines the mesh to use
  98893. */
  98894. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98895. /**
  98896. * Gets the mesh under the pointer
  98897. * @returns a Mesh or null if no mesh is under the pointer
  98898. */
  98899. getPointerOverMesh(): Nullable<AbstractMesh>;
  98900. /** @hidden */
  98901. _rebuildGeometries(): void;
  98902. /** @hidden */
  98903. _rebuildTextures(): void;
  98904. private _getByTags;
  98905. /**
  98906. * Get a list of meshes by tags
  98907. * @param tagsQuery defines the tags query to use
  98908. * @param forEach defines a predicate used to filter results
  98909. * @returns an array of Mesh
  98910. */
  98911. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98912. /**
  98913. * Get a list of cameras by tags
  98914. * @param tagsQuery defines the tags query to use
  98915. * @param forEach defines a predicate used to filter results
  98916. * @returns an array of Camera
  98917. */
  98918. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98919. /**
  98920. * Get a list of lights by tags
  98921. * @param tagsQuery defines the tags query to use
  98922. * @param forEach defines a predicate used to filter results
  98923. * @returns an array of Light
  98924. */
  98925. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98926. /**
  98927. * Get a list of materials by tags
  98928. * @param tagsQuery defines the tags query to use
  98929. * @param forEach defines a predicate used to filter results
  98930. * @returns an array of Material
  98931. */
  98932. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98933. /**
  98934. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98935. * This allowed control for front to back rendering or reversly depending of the special needs.
  98936. *
  98937. * @param renderingGroupId The rendering group id corresponding to its index
  98938. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98939. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98940. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98941. */
  98942. 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;
  98943. /**
  98944. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98945. *
  98946. * @param renderingGroupId The rendering group id corresponding to its index
  98947. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98948. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98949. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98950. */
  98951. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98952. /**
  98953. * Gets the current auto clear configuration for one rendering group of the rendering
  98954. * manager.
  98955. * @param index the rendering group index to get the information for
  98956. * @returns The auto clear setup for the requested rendering group
  98957. */
  98958. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98959. private _blockMaterialDirtyMechanism;
  98960. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98961. blockMaterialDirtyMechanism: boolean;
  98962. /**
  98963. * Will flag all materials as dirty to trigger new shader compilation
  98964. * @param flag defines the flag used to specify which material part must be marked as dirty
  98965. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98966. */
  98967. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98968. /** @hidden */
  98969. _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;
  98970. /** @hidden */
  98971. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98972. }
  98973. }
  98974. declare module BABYLON {
  98975. /**
  98976. * Set of assets to keep when moving a scene into an asset container.
  98977. */
  98978. export class KeepAssets extends AbstractScene {
  98979. }
  98980. /**
  98981. * Container with a set of assets that can be added or removed from a scene.
  98982. */
  98983. export class AssetContainer extends AbstractScene {
  98984. /**
  98985. * The scene the AssetContainer belongs to.
  98986. */
  98987. scene: Scene;
  98988. /**
  98989. * Instantiates an AssetContainer.
  98990. * @param scene The scene the AssetContainer belongs to.
  98991. */
  98992. constructor(scene: Scene);
  98993. /**
  98994. * Adds all the assets from the container to the scene.
  98995. */
  98996. addAllToScene(): void;
  98997. /**
  98998. * Removes all the assets in the container from the scene
  98999. */
  99000. removeAllFromScene(): void;
  99001. /**
  99002. * Disposes all the assets in the container
  99003. */
  99004. dispose(): void;
  99005. private _moveAssets;
  99006. /**
  99007. * Removes all the assets contained in the scene and adds them to the container.
  99008. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99009. */
  99010. moveAllFromScene(keepAssets?: KeepAssets): void;
  99011. /**
  99012. * 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.
  99013. * @returns the root mesh
  99014. */
  99015. createRootMesh(): Mesh;
  99016. }
  99017. }
  99018. declare module BABYLON {
  99019. /**
  99020. * Defines how the parser contract is defined.
  99021. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99022. */
  99023. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99024. /**
  99025. * Defines how the individual parser contract is defined.
  99026. * These parser can parse an individual asset
  99027. */
  99028. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99029. /**
  99030. * Base class of the scene acting as a container for the different elements composing a scene.
  99031. * This class is dynamically extended by the different components of the scene increasing
  99032. * flexibility and reducing coupling
  99033. */
  99034. export abstract class AbstractScene {
  99035. /**
  99036. * Stores the list of available parsers in the application.
  99037. */
  99038. private static _BabylonFileParsers;
  99039. /**
  99040. * Stores the list of available individual parsers in the application.
  99041. */
  99042. private static _IndividualBabylonFileParsers;
  99043. /**
  99044. * Adds a parser in the list of available ones
  99045. * @param name Defines the name of the parser
  99046. * @param parser Defines the parser to add
  99047. */
  99048. static AddParser(name: string, parser: BabylonFileParser): void;
  99049. /**
  99050. * Gets a general parser from the list of avaialble ones
  99051. * @param name Defines the name of the parser
  99052. * @returns the requested parser or null
  99053. */
  99054. static GetParser(name: string): Nullable<BabylonFileParser>;
  99055. /**
  99056. * Adds n individual parser in the list of available ones
  99057. * @param name Defines the name of the parser
  99058. * @param parser Defines the parser to add
  99059. */
  99060. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99061. /**
  99062. * Gets an individual parser from the list of avaialble ones
  99063. * @param name Defines the name of the parser
  99064. * @returns the requested parser or null
  99065. */
  99066. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99067. /**
  99068. * Parser json data and populate both a scene and its associated container object
  99069. * @param jsonData Defines the data to parse
  99070. * @param scene Defines the scene to parse the data for
  99071. * @param container Defines the container attached to the parsing sequence
  99072. * @param rootUrl Defines the root url of the data
  99073. */
  99074. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99075. /**
  99076. * Gets the list of root nodes (ie. nodes with no parent)
  99077. */
  99078. rootNodes: Node[];
  99079. /** All of the cameras added to this scene
  99080. * @see http://doc.babylonjs.com/babylon101/cameras
  99081. */
  99082. cameras: Camera[];
  99083. /**
  99084. * All of the lights added to this scene
  99085. * @see http://doc.babylonjs.com/babylon101/lights
  99086. */
  99087. lights: Light[];
  99088. /**
  99089. * All of the (abstract) meshes added to this scene
  99090. */
  99091. meshes: AbstractMesh[];
  99092. /**
  99093. * The list of skeletons added to the scene
  99094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99095. */
  99096. skeletons: Skeleton[];
  99097. /**
  99098. * All of the particle systems added to this scene
  99099. * @see http://doc.babylonjs.com/babylon101/particles
  99100. */
  99101. particleSystems: IParticleSystem[];
  99102. /**
  99103. * Gets a list of Animations associated with the scene
  99104. */
  99105. animations: Animation[];
  99106. /**
  99107. * All of the animation groups added to this scene
  99108. * @see http://doc.babylonjs.com/how_to/group
  99109. */
  99110. animationGroups: AnimationGroup[];
  99111. /**
  99112. * All of the multi-materials added to this scene
  99113. * @see http://doc.babylonjs.com/how_to/multi_materials
  99114. */
  99115. multiMaterials: MultiMaterial[];
  99116. /**
  99117. * All of the materials added to this scene
  99118. * In the context of a Scene, it is not supposed to be modified manually.
  99119. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99120. * Note also that the order of the Material wihin the array is not significant and might change.
  99121. * @see http://doc.babylonjs.com/babylon101/materials
  99122. */
  99123. materials: Material[];
  99124. /**
  99125. * The list of morph target managers added to the scene
  99126. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99127. */
  99128. morphTargetManagers: MorphTargetManager[];
  99129. /**
  99130. * The list of geometries used in the scene.
  99131. */
  99132. geometries: Geometry[];
  99133. /**
  99134. * All of the tranform nodes added to this scene
  99135. * In the context of a Scene, it is not supposed to be modified manually.
  99136. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99137. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99138. * @see http://doc.babylonjs.com/how_to/transformnode
  99139. */
  99140. transformNodes: TransformNode[];
  99141. /**
  99142. * ActionManagers available on the scene.
  99143. */
  99144. actionManagers: AbstractActionManager[];
  99145. /**
  99146. * Textures to keep.
  99147. */
  99148. textures: BaseTexture[];
  99149. /**
  99150. * Environment texture for the scene
  99151. */
  99152. environmentTexture: Nullable<BaseTexture>;
  99153. }
  99154. }
  99155. declare module BABYLON {
  99156. /**
  99157. * Interface used to define options for Sound class
  99158. */
  99159. export interface ISoundOptions {
  99160. /**
  99161. * Does the sound autoplay once loaded.
  99162. */
  99163. autoplay?: boolean;
  99164. /**
  99165. * Does the sound loop after it finishes playing once.
  99166. */
  99167. loop?: boolean;
  99168. /**
  99169. * Sound's volume
  99170. */
  99171. volume?: number;
  99172. /**
  99173. * Is it a spatial sound?
  99174. */
  99175. spatialSound?: boolean;
  99176. /**
  99177. * Maximum distance to hear that sound
  99178. */
  99179. maxDistance?: number;
  99180. /**
  99181. * Uses user defined attenuation function
  99182. */
  99183. useCustomAttenuation?: boolean;
  99184. /**
  99185. * Define the roll off factor of spatial sounds.
  99186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99187. */
  99188. rolloffFactor?: number;
  99189. /**
  99190. * Define the reference distance the sound should be heard perfectly.
  99191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99192. */
  99193. refDistance?: number;
  99194. /**
  99195. * Define the distance attenuation model the sound will follow.
  99196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99197. */
  99198. distanceModel?: string;
  99199. /**
  99200. * Defines the playback speed (1 by default)
  99201. */
  99202. playbackRate?: number;
  99203. /**
  99204. * Defines if the sound is from a streaming source
  99205. */
  99206. streaming?: boolean;
  99207. /**
  99208. * Defines an optional length (in seconds) inside the sound file
  99209. */
  99210. length?: number;
  99211. /**
  99212. * Defines an optional offset (in seconds) inside the sound file
  99213. */
  99214. offset?: number;
  99215. /**
  99216. * If true, URLs will not be required to state the audio file codec to use.
  99217. */
  99218. skipCodecCheck?: boolean;
  99219. }
  99220. /**
  99221. * Defines a sound that can be played in the application.
  99222. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99224. */
  99225. export class Sound {
  99226. /**
  99227. * The name of the sound in the scene.
  99228. */
  99229. name: string;
  99230. /**
  99231. * Does the sound autoplay once loaded.
  99232. */
  99233. autoplay: boolean;
  99234. /**
  99235. * Does the sound loop after it finishes playing once.
  99236. */
  99237. loop: boolean;
  99238. /**
  99239. * Does the sound use a custom attenuation curve to simulate the falloff
  99240. * happening when the source gets further away from the camera.
  99241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99242. */
  99243. useCustomAttenuation: boolean;
  99244. /**
  99245. * The sound track id this sound belongs to.
  99246. */
  99247. soundTrackId: number;
  99248. /**
  99249. * Is this sound currently played.
  99250. */
  99251. isPlaying: boolean;
  99252. /**
  99253. * Is this sound currently paused.
  99254. */
  99255. isPaused: boolean;
  99256. /**
  99257. * Does this sound enables spatial sound.
  99258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99259. */
  99260. spatialSound: boolean;
  99261. /**
  99262. * Define the reference distance the sound should be heard perfectly.
  99263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99264. */
  99265. refDistance: number;
  99266. /**
  99267. * Define the roll off factor of spatial sounds.
  99268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99269. */
  99270. rolloffFactor: number;
  99271. /**
  99272. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99274. */
  99275. maxDistance: number;
  99276. /**
  99277. * Define the distance attenuation model the sound will follow.
  99278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99279. */
  99280. distanceModel: string;
  99281. /**
  99282. * @hidden
  99283. * Back Compat
  99284. **/
  99285. onended: () => any;
  99286. /**
  99287. * Observable event when the current playing sound finishes.
  99288. */
  99289. onEndedObservable: Observable<Sound>;
  99290. private _panningModel;
  99291. private _playbackRate;
  99292. private _streaming;
  99293. private _startTime;
  99294. private _startOffset;
  99295. private _position;
  99296. /** @hidden */
  99297. _positionInEmitterSpace: boolean;
  99298. private _localDirection;
  99299. private _volume;
  99300. private _isReadyToPlay;
  99301. private _isDirectional;
  99302. private _readyToPlayCallback;
  99303. private _audioBuffer;
  99304. private _soundSource;
  99305. private _streamingSource;
  99306. private _soundPanner;
  99307. private _soundGain;
  99308. private _inputAudioNode;
  99309. private _outputAudioNode;
  99310. private _coneInnerAngle;
  99311. private _coneOuterAngle;
  99312. private _coneOuterGain;
  99313. private _scene;
  99314. private _connectedTransformNode;
  99315. private _customAttenuationFunction;
  99316. private _registerFunc;
  99317. private _isOutputConnected;
  99318. private _htmlAudioElement;
  99319. private _urlType;
  99320. private _length?;
  99321. private _offset?;
  99322. /** @hidden */
  99323. static _SceneComponentInitialization: (scene: Scene) => void;
  99324. /**
  99325. * Create a sound and attach it to a scene
  99326. * @param name Name of your sound
  99327. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99328. * @param scene defines the scene the sound belongs to
  99329. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99330. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99331. */
  99332. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99333. /**
  99334. * Release the sound and its associated resources
  99335. */
  99336. dispose(): void;
  99337. /**
  99338. * Gets if the sounds is ready to be played or not.
  99339. * @returns true if ready, otherwise false
  99340. */
  99341. isReady(): boolean;
  99342. private _soundLoaded;
  99343. /**
  99344. * Sets the data of the sound from an audiobuffer
  99345. * @param audioBuffer The audioBuffer containing the data
  99346. */
  99347. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99348. /**
  99349. * Updates the current sounds options such as maxdistance, loop...
  99350. * @param options A JSON object containing values named as the object properties
  99351. */
  99352. updateOptions(options: ISoundOptions): void;
  99353. private _createSpatialParameters;
  99354. private _updateSpatialParameters;
  99355. /**
  99356. * Switch the panning model to HRTF:
  99357. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99359. */
  99360. switchPanningModelToHRTF(): void;
  99361. /**
  99362. * Switch the panning model to Equal Power:
  99363. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99365. */
  99366. switchPanningModelToEqualPower(): void;
  99367. private _switchPanningModel;
  99368. /**
  99369. * Connect this sound to a sound track audio node like gain...
  99370. * @param soundTrackAudioNode the sound track audio node to connect to
  99371. */
  99372. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99373. /**
  99374. * Transform this sound into a directional source
  99375. * @param coneInnerAngle Size of the inner cone in degree
  99376. * @param coneOuterAngle Size of the outer cone in degree
  99377. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99378. */
  99379. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99380. /**
  99381. * Gets or sets the inner angle for the directional cone.
  99382. */
  99383. /**
  99384. * Gets or sets the inner angle for the directional cone.
  99385. */
  99386. directionalConeInnerAngle: number;
  99387. /**
  99388. * Gets or sets the outer angle for the directional cone.
  99389. */
  99390. /**
  99391. * Gets or sets the outer angle for the directional cone.
  99392. */
  99393. directionalConeOuterAngle: number;
  99394. /**
  99395. * Sets the position of the emitter if spatial sound is enabled
  99396. * @param newPosition Defines the new posisiton
  99397. */
  99398. setPosition(newPosition: Vector3): void;
  99399. /**
  99400. * Sets the local direction of the emitter if spatial sound is enabled
  99401. * @param newLocalDirection Defines the new local direction
  99402. */
  99403. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99404. private _updateDirection;
  99405. /** @hidden */
  99406. updateDistanceFromListener(): void;
  99407. /**
  99408. * Sets a new custom attenuation function for the sound.
  99409. * @param callback Defines the function used for the attenuation
  99410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99411. */
  99412. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99413. /**
  99414. * Play the sound
  99415. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99416. * @param offset (optional) Start the sound at a specific time in seconds
  99417. * @param length (optional) Sound duration (in seconds)
  99418. */
  99419. play(time?: number, offset?: number, length?: number): void;
  99420. private _onended;
  99421. /**
  99422. * Stop the sound
  99423. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99424. */
  99425. stop(time?: number): void;
  99426. /**
  99427. * Put the sound in pause
  99428. */
  99429. pause(): void;
  99430. /**
  99431. * Sets a dedicated volume for this sounds
  99432. * @param newVolume Define the new volume of the sound
  99433. * @param time Define time for gradual change to new volume
  99434. */
  99435. setVolume(newVolume: number, time?: number): void;
  99436. /**
  99437. * Set the sound play back rate
  99438. * @param newPlaybackRate Define the playback rate the sound should be played at
  99439. */
  99440. setPlaybackRate(newPlaybackRate: number): void;
  99441. /**
  99442. * Gets the volume of the sound.
  99443. * @returns the volume of the sound
  99444. */
  99445. getVolume(): number;
  99446. /**
  99447. * Attach the sound to a dedicated mesh
  99448. * @param transformNode The transform node to connect the sound with
  99449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99450. */
  99451. attachToMesh(transformNode: TransformNode): void;
  99452. /**
  99453. * Detach the sound from the previously attached mesh
  99454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99455. */
  99456. detachFromMesh(): void;
  99457. private _onRegisterAfterWorldMatrixUpdate;
  99458. /**
  99459. * Clone the current sound in the scene.
  99460. * @returns the new sound clone
  99461. */
  99462. clone(): Nullable<Sound>;
  99463. /**
  99464. * Gets the current underlying audio buffer containing the data
  99465. * @returns the audio buffer
  99466. */
  99467. getAudioBuffer(): Nullable<AudioBuffer>;
  99468. /**
  99469. * Serializes the Sound in a JSON representation
  99470. * @returns the JSON representation of the sound
  99471. */
  99472. serialize(): any;
  99473. /**
  99474. * Parse a JSON representation of a sound to innstantiate in a given scene
  99475. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99476. * @param scene Define the scene the new parsed sound should be created in
  99477. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99478. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99479. * @returns the newly parsed sound
  99480. */
  99481. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99482. }
  99483. }
  99484. declare module BABYLON {
  99485. /**
  99486. * This defines an action helpful to play a defined sound on a triggered action.
  99487. */
  99488. export class PlaySoundAction extends Action {
  99489. private _sound;
  99490. /**
  99491. * Instantiate the action
  99492. * @param triggerOptions defines the trigger options
  99493. * @param sound defines the sound to play
  99494. * @param condition defines the trigger related conditions
  99495. */
  99496. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99497. /** @hidden */
  99498. _prepare(): void;
  99499. /**
  99500. * Execute the action and play the sound.
  99501. */
  99502. execute(): void;
  99503. /**
  99504. * Serializes the actions and its related information.
  99505. * @param parent defines the object to serialize in
  99506. * @returns the serialized object
  99507. */
  99508. serialize(parent: any): any;
  99509. }
  99510. /**
  99511. * This defines an action helpful to stop a defined sound on a triggered action.
  99512. */
  99513. export class StopSoundAction extends Action {
  99514. private _sound;
  99515. /**
  99516. * Instantiate the action
  99517. * @param triggerOptions defines the trigger options
  99518. * @param sound defines the sound to stop
  99519. * @param condition defines the trigger related conditions
  99520. */
  99521. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99522. /** @hidden */
  99523. _prepare(): void;
  99524. /**
  99525. * Execute the action and stop the sound.
  99526. */
  99527. execute(): void;
  99528. /**
  99529. * Serializes the actions and its related information.
  99530. * @param parent defines the object to serialize in
  99531. * @returns the serialized object
  99532. */
  99533. serialize(parent: any): any;
  99534. }
  99535. }
  99536. declare module BABYLON {
  99537. /**
  99538. * This defines an action responsible to change the value of a property
  99539. * by interpolating between its current value and the newly set one once triggered.
  99540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99541. */
  99542. export class InterpolateValueAction extends Action {
  99543. /**
  99544. * Defines the path of the property where the value should be interpolated
  99545. */
  99546. propertyPath: string;
  99547. /**
  99548. * Defines the target value at the end of the interpolation.
  99549. */
  99550. value: any;
  99551. /**
  99552. * Defines the time it will take for the property to interpolate to the value.
  99553. */
  99554. duration: number;
  99555. /**
  99556. * Defines if the other scene animations should be stopped when the action has been triggered
  99557. */
  99558. stopOtherAnimations?: boolean;
  99559. /**
  99560. * Defines a callback raised once the interpolation animation has been done.
  99561. */
  99562. onInterpolationDone?: () => void;
  99563. /**
  99564. * Observable triggered once the interpolation animation has been done.
  99565. */
  99566. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99567. private _target;
  99568. private _effectiveTarget;
  99569. private _property;
  99570. /**
  99571. * Instantiate the action
  99572. * @param triggerOptions defines the trigger options
  99573. * @param target defines the object containing the value to interpolate
  99574. * @param propertyPath defines the path to the property in the target object
  99575. * @param value defines the target value at the end of the interpolation
  99576. * @param duration deines the time it will take for the property to interpolate to the value.
  99577. * @param condition defines the trigger related conditions
  99578. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99579. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99580. */
  99581. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99582. /** @hidden */
  99583. _prepare(): void;
  99584. /**
  99585. * Execute the action starts the value interpolation.
  99586. */
  99587. execute(): void;
  99588. /**
  99589. * Serializes the actions and its related information.
  99590. * @param parent defines the object to serialize in
  99591. * @returns the serialized object
  99592. */
  99593. serialize(parent: any): any;
  99594. }
  99595. }
  99596. declare module BABYLON {
  99597. /**
  99598. * Options allowed during the creation of a sound track.
  99599. */
  99600. export interface ISoundTrackOptions {
  99601. /**
  99602. * The volume the sound track should take during creation
  99603. */
  99604. volume?: number;
  99605. /**
  99606. * Define if the sound track is the main sound track of the scene
  99607. */
  99608. mainTrack?: boolean;
  99609. }
  99610. /**
  99611. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99612. * It will be also used in a future release to apply effects on a specific track.
  99613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99614. */
  99615. export class SoundTrack {
  99616. /**
  99617. * The unique identifier of the sound track in the scene.
  99618. */
  99619. id: number;
  99620. /**
  99621. * The list of sounds included in the sound track.
  99622. */
  99623. soundCollection: Array<Sound>;
  99624. private _outputAudioNode;
  99625. private _scene;
  99626. private _isMainTrack;
  99627. private _connectedAnalyser;
  99628. private _options;
  99629. private _isInitialized;
  99630. /**
  99631. * Creates a new sound track.
  99632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99633. * @param scene Define the scene the sound track belongs to
  99634. * @param options
  99635. */
  99636. constructor(scene: Scene, options?: ISoundTrackOptions);
  99637. private _initializeSoundTrackAudioGraph;
  99638. /**
  99639. * Release the sound track and its associated resources
  99640. */
  99641. dispose(): void;
  99642. /**
  99643. * Adds a sound to this sound track
  99644. * @param sound define the cound to add
  99645. * @ignoreNaming
  99646. */
  99647. AddSound(sound: Sound): void;
  99648. /**
  99649. * Removes a sound to this sound track
  99650. * @param sound define the cound to remove
  99651. * @ignoreNaming
  99652. */
  99653. RemoveSound(sound: Sound): void;
  99654. /**
  99655. * Set a global volume for the full sound track.
  99656. * @param newVolume Define the new volume of the sound track
  99657. */
  99658. setVolume(newVolume: number): void;
  99659. /**
  99660. * Switch the panning model to HRTF:
  99661. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99663. */
  99664. switchPanningModelToHRTF(): void;
  99665. /**
  99666. * Switch the panning model to Equal Power:
  99667. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99669. */
  99670. switchPanningModelToEqualPower(): void;
  99671. /**
  99672. * Connect the sound track to an audio analyser allowing some amazing
  99673. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99675. * @param analyser The analyser to connect to the engine
  99676. */
  99677. connectToAnalyser(analyser: Analyser): void;
  99678. }
  99679. }
  99680. declare module BABYLON {
  99681. interface AbstractScene {
  99682. /**
  99683. * The list of sounds used in the scene.
  99684. */
  99685. sounds: Nullable<Array<Sound>>;
  99686. }
  99687. interface Scene {
  99688. /**
  99689. * @hidden
  99690. * Backing field
  99691. */
  99692. _mainSoundTrack: SoundTrack;
  99693. /**
  99694. * The main sound track played by the scene.
  99695. * It cotains your primary collection of sounds.
  99696. */
  99697. mainSoundTrack: SoundTrack;
  99698. /**
  99699. * The list of sound tracks added to the scene
  99700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99701. */
  99702. soundTracks: Nullable<Array<SoundTrack>>;
  99703. /**
  99704. * Gets a sound using a given name
  99705. * @param name defines the name to search for
  99706. * @return the found sound or null if not found at all.
  99707. */
  99708. getSoundByName(name: string): Nullable<Sound>;
  99709. /**
  99710. * Gets or sets if audio support is enabled
  99711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99712. */
  99713. audioEnabled: boolean;
  99714. /**
  99715. * Gets or sets if audio will be output to headphones
  99716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99717. */
  99718. headphone: boolean;
  99719. }
  99720. /**
  99721. * Defines the sound scene component responsible to manage any sounds
  99722. * in a given scene.
  99723. */
  99724. export class AudioSceneComponent implements ISceneSerializableComponent {
  99725. /**
  99726. * The component name helpfull to identify the component in the list of scene components.
  99727. */
  99728. readonly name: string;
  99729. /**
  99730. * The scene the component belongs to.
  99731. */
  99732. scene: Scene;
  99733. private _audioEnabled;
  99734. /**
  99735. * Gets whether audio is enabled or not.
  99736. * Please use related enable/disable method to switch state.
  99737. */
  99738. readonly audioEnabled: boolean;
  99739. private _headphone;
  99740. /**
  99741. * Gets whether audio is outputing to headphone or not.
  99742. * Please use the according Switch methods to change output.
  99743. */
  99744. readonly headphone: boolean;
  99745. /**
  99746. * Creates a new instance of the component for the given scene
  99747. * @param scene Defines the scene to register the component in
  99748. */
  99749. constructor(scene: Scene);
  99750. /**
  99751. * Registers the component in a given scene
  99752. */
  99753. register(): void;
  99754. /**
  99755. * Rebuilds the elements related to this component in case of
  99756. * context lost for instance.
  99757. */
  99758. rebuild(): void;
  99759. /**
  99760. * Serializes the component data to the specified json object
  99761. * @param serializationObject The object to serialize to
  99762. */
  99763. serialize(serializationObject: any): void;
  99764. /**
  99765. * Adds all the elements from the container to the scene
  99766. * @param container the container holding the elements
  99767. */
  99768. addFromContainer(container: AbstractScene): void;
  99769. /**
  99770. * Removes all the elements in the container from the scene
  99771. * @param container contains the elements to remove
  99772. * @param dispose if the removed element should be disposed (default: false)
  99773. */
  99774. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99775. /**
  99776. * Disposes the component and the associated ressources.
  99777. */
  99778. dispose(): void;
  99779. /**
  99780. * Disables audio in the associated scene.
  99781. */
  99782. disableAudio(): void;
  99783. /**
  99784. * Enables audio in the associated scene.
  99785. */
  99786. enableAudio(): void;
  99787. /**
  99788. * Switch audio to headphone output.
  99789. */
  99790. switchAudioModeForHeadphones(): void;
  99791. /**
  99792. * Switch audio to normal speakers.
  99793. */
  99794. switchAudioModeForNormalSpeakers(): void;
  99795. private _afterRender;
  99796. }
  99797. }
  99798. declare module BABYLON {
  99799. /**
  99800. * Wraps one or more Sound objects and selects one with random weight for playback.
  99801. */
  99802. export class WeightedSound {
  99803. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99804. loop: boolean;
  99805. private _coneInnerAngle;
  99806. private _coneOuterAngle;
  99807. private _volume;
  99808. /** A Sound is currently playing. */
  99809. isPlaying: boolean;
  99810. /** A Sound is currently paused. */
  99811. isPaused: boolean;
  99812. private _sounds;
  99813. private _weights;
  99814. private _currentIndex?;
  99815. /**
  99816. * Creates a new WeightedSound from the list of sounds given.
  99817. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99818. * @param sounds Array of Sounds that will be selected from.
  99819. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99820. */
  99821. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99822. /**
  99823. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99824. */
  99825. /**
  99826. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99827. */
  99828. directionalConeInnerAngle: number;
  99829. /**
  99830. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99831. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99832. */
  99833. /**
  99834. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99835. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99836. */
  99837. directionalConeOuterAngle: number;
  99838. /**
  99839. * Playback volume.
  99840. */
  99841. /**
  99842. * Playback volume.
  99843. */
  99844. volume: number;
  99845. private _onended;
  99846. /**
  99847. * Suspend playback
  99848. */
  99849. pause(): void;
  99850. /**
  99851. * Stop playback
  99852. */
  99853. stop(): void;
  99854. /**
  99855. * Start playback.
  99856. * @param startOffset Position the clip head at a specific time in seconds.
  99857. */
  99858. play(startOffset?: number): void;
  99859. }
  99860. }
  99861. declare module BABYLON {
  99862. /**
  99863. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99864. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99865. */
  99866. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99867. /**
  99868. * Gets the name of the behavior.
  99869. */
  99870. readonly name: string;
  99871. /**
  99872. * The easing function used by animations
  99873. */
  99874. static EasingFunction: BackEase;
  99875. /**
  99876. * The easing mode used by animations
  99877. */
  99878. static EasingMode: number;
  99879. /**
  99880. * The duration of the animation, in milliseconds
  99881. */
  99882. transitionDuration: number;
  99883. /**
  99884. * Length of the distance animated by the transition when lower radius is reached
  99885. */
  99886. lowerRadiusTransitionRange: number;
  99887. /**
  99888. * Length of the distance animated by the transition when upper radius is reached
  99889. */
  99890. upperRadiusTransitionRange: number;
  99891. private _autoTransitionRange;
  99892. /**
  99893. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99894. */
  99895. /**
  99896. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99897. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99898. */
  99899. autoTransitionRange: boolean;
  99900. private _attachedCamera;
  99901. private _onAfterCheckInputsObserver;
  99902. private _onMeshTargetChangedObserver;
  99903. /**
  99904. * Initializes the behavior.
  99905. */
  99906. init(): void;
  99907. /**
  99908. * Attaches the behavior to its arc rotate camera.
  99909. * @param camera Defines the camera to attach the behavior to
  99910. */
  99911. attach(camera: ArcRotateCamera): void;
  99912. /**
  99913. * Detaches the behavior from its current arc rotate camera.
  99914. */
  99915. detach(): void;
  99916. private _radiusIsAnimating;
  99917. private _radiusBounceTransition;
  99918. private _animatables;
  99919. private _cachedWheelPrecision;
  99920. /**
  99921. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99922. * @param radiusLimit The limit to check against.
  99923. * @return Bool to indicate if at limit.
  99924. */
  99925. private _isRadiusAtLimit;
  99926. /**
  99927. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99928. * @param radiusDelta The delta by which to animate to. Can be negative.
  99929. */
  99930. private _applyBoundRadiusAnimation;
  99931. /**
  99932. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99933. */
  99934. protected _clearAnimationLocks(): void;
  99935. /**
  99936. * Stops and removes all animations that have been applied to the camera
  99937. */
  99938. stopAllAnimations(): void;
  99939. }
  99940. }
  99941. declare module BABYLON {
  99942. /**
  99943. * 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.
  99944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99945. */
  99946. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99947. /**
  99948. * Gets the name of the behavior.
  99949. */
  99950. readonly name: string;
  99951. private _mode;
  99952. private _radiusScale;
  99953. private _positionScale;
  99954. private _defaultElevation;
  99955. private _elevationReturnTime;
  99956. private _elevationReturnWaitTime;
  99957. private _zoomStopsAnimation;
  99958. private _framingTime;
  99959. /**
  99960. * The easing function used by animations
  99961. */
  99962. static EasingFunction: ExponentialEase;
  99963. /**
  99964. * The easing mode used by animations
  99965. */
  99966. static EasingMode: number;
  99967. /**
  99968. * Sets the current mode used by the behavior
  99969. */
  99970. /**
  99971. * Gets current mode used by the behavior.
  99972. */
  99973. mode: number;
  99974. /**
  99975. * Sets the scale applied to the radius (1 by default)
  99976. */
  99977. /**
  99978. * Gets the scale applied to the radius
  99979. */
  99980. radiusScale: number;
  99981. /**
  99982. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99983. */
  99984. /**
  99985. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99986. */
  99987. positionScale: number;
  99988. /**
  99989. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99990. * behaviour is triggered, in radians.
  99991. */
  99992. /**
  99993. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99994. * behaviour is triggered, in radians.
  99995. */
  99996. defaultElevation: number;
  99997. /**
  99998. * Sets the time (in milliseconds) taken to return to the default beta position.
  99999. * Negative value indicates camera should not return to default.
  100000. */
  100001. /**
  100002. * Gets the time (in milliseconds) taken to return to the default beta position.
  100003. * Negative value indicates camera should not return to default.
  100004. */
  100005. elevationReturnTime: number;
  100006. /**
  100007. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100008. */
  100009. /**
  100010. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100011. */
  100012. elevationReturnWaitTime: number;
  100013. /**
  100014. * Sets the flag that indicates if user zooming should stop animation.
  100015. */
  100016. /**
  100017. * Gets the flag that indicates if user zooming should stop animation.
  100018. */
  100019. zoomStopsAnimation: boolean;
  100020. /**
  100021. * Sets the transition time when framing the mesh, in milliseconds
  100022. */
  100023. /**
  100024. * Gets the transition time when framing the mesh, in milliseconds
  100025. */
  100026. framingTime: number;
  100027. /**
  100028. * Define if the behavior should automatically change the configured
  100029. * camera limits and sensibilities.
  100030. */
  100031. autoCorrectCameraLimitsAndSensibility: boolean;
  100032. private _onPrePointerObservableObserver;
  100033. private _onAfterCheckInputsObserver;
  100034. private _onMeshTargetChangedObserver;
  100035. private _attachedCamera;
  100036. private _isPointerDown;
  100037. private _lastInteractionTime;
  100038. /**
  100039. * Initializes the behavior.
  100040. */
  100041. init(): void;
  100042. /**
  100043. * Attaches the behavior to its arc rotate camera.
  100044. * @param camera Defines the camera to attach the behavior to
  100045. */
  100046. attach(camera: ArcRotateCamera): void;
  100047. /**
  100048. * Detaches the behavior from its current arc rotate camera.
  100049. */
  100050. detach(): void;
  100051. private _animatables;
  100052. private _betaIsAnimating;
  100053. private _betaTransition;
  100054. private _radiusTransition;
  100055. private _vectorTransition;
  100056. /**
  100057. * Targets the given mesh and updates zoom level accordingly.
  100058. * @param mesh The mesh to target.
  100059. * @param radius Optional. If a cached radius position already exists, overrides default.
  100060. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100061. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100062. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100063. */
  100064. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100065. /**
  100066. * Targets the given mesh with its children and updates zoom level accordingly.
  100067. * @param mesh The mesh to target.
  100068. * @param radius Optional. If a cached radius position already exists, overrides default.
  100069. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100070. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100071. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100072. */
  100073. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100074. /**
  100075. * Targets the given meshes with their children and updates zoom level accordingly.
  100076. * @param meshes The mesh to target.
  100077. * @param radius Optional. If a cached radius position already exists, overrides default.
  100078. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100079. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100080. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100081. */
  100082. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100083. /**
  100084. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100085. * @param minimumWorld Determines the smaller position of the bounding box extend
  100086. * @param maximumWorld Determines the bigger position of the bounding box extend
  100087. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100088. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100089. */
  100090. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100091. /**
  100092. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100093. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100094. * frustum width.
  100095. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100096. * to fully enclose the mesh in the viewing frustum.
  100097. */
  100098. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100099. /**
  100100. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100101. * is automatically returned to its default position (expected to be above ground plane).
  100102. */
  100103. private _maintainCameraAboveGround;
  100104. /**
  100105. * Returns the frustum slope based on the canvas ratio and camera FOV
  100106. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100107. */
  100108. private _getFrustumSlope;
  100109. /**
  100110. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100111. */
  100112. private _clearAnimationLocks;
  100113. /**
  100114. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100115. */
  100116. private _applyUserInteraction;
  100117. /**
  100118. * Stops and removes all animations that have been applied to the camera
  100119. */
  100120. stopAllAnimations(): void;
  100121. /**
  100122. * Gets a value indicating if the user is moving the camera
  100123. */
  100124. readonly isUserIsMoving: boolean;
  100125. /**
  100126. * The camera can move all the way towards the mesh.
  100127. */
  100128. static IgnoreBoundsSizeMode: number;
  100129. /**
  100130. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100131. */
  100132. static FitFrustumSidesMode: number;
  100133. }
  100134. }
  100135. declare module BABYLON {
  100136. /**
  100137. * Base class for Camera Pointer Inputs.
  100138. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100139. * for example usage.
  100140. */
  100141. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100142. /**
  100143. * Defines the camera the input is attached to.
  100144. */
  100145. abstract camera: Camera;
  100146. /**
  100147. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100148. */
  100149. protected _altKey: boolean;
  100150. protected _ctrlKey: boolean;
  100151. protected _metaKey: boolean;
  100152. protected _shiftKey: boolean;
  100153. /**
  100154. * Which mouse buttons were pressed at time of last mouse event.
  100155. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100156. */
  100157. protected _buttonsPressed: number;
  100158. /**
  100159. * Defines the buttons associated with the input to handle camera move.
  100160. */
  100161. buttons: number[];
  100162. /**
  100163. * Attach the input controls to a specific dom element to get the input from.
  100164. * @param element Defines the element the controls should be listened from
  100165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100166. */
  100167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100168. /**
  100169. * Detach the current controls from the specified dom element.
  100170. * @param element Defines the element to stop listening the inputs from
  100171. */
  100172. detachControl(element: Nullable<HTMLElement>): void;
  100173. /**
  100174. * Gets the class name of the current input.
  100175. * @returns the class name
  100176. */
  100177. getClassName(): string;
  100178. /**
  100179. * Get the friendly name associated with the input class.
  100180. * @returns the input friendly name
  100181. */
  100182. getSimpleName(): string;
  100183. /**
  100184. * Called on pointer POINTERDOUBLETAP event.
  100185. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100186. */
  100187. protected onDoubleTap(type: string): void;
  100188. /**
  100189. * Called on pointer POINTERMOVE event if only a single touch is active.
  100190. * Override this method to provide functionality.
  100191. */
  100192. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100193. /**
  100194. * Called on pointer POINTERMOVE event if multiple touches are active.
  100195. * Override this method to provide functionality.
  100196. */
  100197. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100198. /**
  100199. * Called on JS contextmenu event.
  100200. * Override this method to provide functionality.
  100201. */
  100202. protected onContextMenu(evt: PointerEvent): void;
  100203. /**
  100204. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100205. * press.
  100206. * Override this method to provide functionality.
  100207. */
  100208. protected onButtonDown(evt: PointerEvent): void;
  100209. /**
  100210. * Called each time a new POINTERUP event occurs. Ie, for each button
  100211. * release.
  100212. * Override this method to provide functionality.
  100213. */
  100214. protected onButtonUp(evt: PointerEvent): void;
  100215. /**
  100216. * Called when window becomes inactive.
  100217. * Override this method to provide functionality.
  100218. */
  100219. protected onLostFocus(): void;
  100220. private _pointerInput;
  100221. private _observer;
  100222. private _onLostFocus;
  100223. private pointA;
  100224. private pointB;
  100225. }
  100226. }
  100227. declare module BABYLON {
  100228. /**
  100229. * Manage the pointers inputs to control an arc rotate camera.
  100230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100231. */
  100232. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100233. /**
  100234. * Defines the camera the input is attached to.
  100235. */
  100236. camera: ArcRotateCamera;
  100237. /**
  100238. * Gets the class name of the current input.
  100239. * @returns the class name
  100240. */
  100241. getClassName(): string;
  100242. /**
  100243. * Defines the buttons associated with the input to handle camera move.
  100244. */
  100245. buttons: number[];
  100246. /**
  100247. * Defines the pointer angular sensibility along the X axis or how fast is
  100248. * the camera rotating.
  100249. */
  100250. angularSensibilityX: number;
  100251. /**
  100252. * Defines the pointer angular sensibility along the Y axis or how fast is
  100253. * the camera rotating.
  100254. */
  100255. angularSensibilityY: number;
  100256. /**
  100257. * Defines the pointer pinch precision or how fast is the camera zooming.
  100258. */
  100259. pinchPrecision: number;
  100260. /**
  100261. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100262. * from 0.
  100263. * It defines the percentage of current camera.radius to use as delta when
  100264. * pinch zoom is used.
  100265. */
  100266. pinchDeltaPercentage: number;
  100267. /**
  100268. * Defines the pointer panning sensibility or how fast is the camera moving.
  100269. */
  100270. panningSensibility: number;
  100271. /**
  100272. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100273. */
  100274. multiTouchPanning: boolean;
  100275. /**
  100276. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100277. * zoom (pinch) through multitouch.
  100278. */
  100279. multiTouchPanAndZoom: boolean;
  100280. /**
  100281. * Revers pinch action direction.
  100282. */
  100283. pinchInwards: boolean;
  100284. private _isPanClick;
  100285. private _twoFingerActivityCount;
  100286. private _isPinching;
  100287. /**
  100288. * Called on pointer POINTERMOVE event if only a single touch is active.
  100289. */
  100290. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100291. /**
  100292. * Called on pointer POINTERDOUBLETAP event.
  100293. */
  100294. protected onDoubleTap(type: string): void;
  100295. /**
  100296. * Called on pointer POINTERMOVE event if multiple touches are active.
  100297. */
  100298. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100299. /**
  100300. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100301. * press.
  100302. */
  100303. protected onButtonDown(evt: PointerEvent): void;
  100304. /**
  100305. * Called each time a new POINTERUP event occurs. Ie, for each button
  100306. * release.
  100307. */
  100308. protected onButtonUp(evt: PointerEvent): void;
  100309. /**
  100310. * Called when window becomes inactive.
  100311. */
  100312. protected onLostFocus(): void;
  100313. }
  100314. }
  100315. declare module BABYLON {
  100316. /**
  100317. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100319. */
  100320. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100321. /**
  100322. * Defines the camera the input is attached to.
  100323. */
  100324. camera: ArcRotateCamera;
  100325. /**
  100326. * Defines the list of key codes associated with the up action (increase alpha)
  100327. */
  100328. keysUp: number[];
  100329. /**
  100330. * Defines the list of key codes associated with the down action (decrease alpha)
  100331. */
  100332. keysDown: number[];
  100333. /**
  100334. * Defines the list of key codes associated with the left action (increase beta)
  100335. */
  100336. keysLeft: number[];
  100337. /**
  100338. * Defines the list of key codes associated with the right action (decrease beta)
  100339. */
  100340. keysRight: number[];
  100341. /**
  100342. * Defines the list of key codes associated with the reset action.
  100343. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100344. */
  100345. keysReset: number[];
  100346. /**
  100347. * Defines the panning sensibility of the inputs.
  100348. * (How fast is the camera paning)
  100349. */
  100350. panningSensibility: number;
  100351. /**
  100352. * Defines the zooming sensibility of the inputs.
  100353. * (How fast is the camera zooming)
  100354. */
  100355. zoomingSensibility: number;
  100356. /**
  100357. * Defines wether maintaining the alt key down switch the movement mode from
  100358. * orientation to zoom.
  100359. */
  100360. useAltToZoom: boolean;
  100361. /**
  100362. * Rotation speed of the camera
  100363. */
  100364. angularSpeed: number;
  100365. private _keys;
  100366. private _ctrlPressed;
  100367. private _altPressed;
  100368. private _onCanvasBlurObserver;
  100369. private _onKeyboardObserver;
  100370. private _engine;
  100371. private _scene;
  100372. /**
  100373. * Attach the input controls to a specific dom element to get the input from.
  100374. * @param element Defines the element the controls should be listened from
  100375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100376. */
  100377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100378. /**
  100379. * Detach the current controls from the specified dom element.
  100380. * @param element Defines the element to stop listening the inputs from
  100381. */
  100382. detachControl(element: Nullable<HTMLElement>): void;
  100383. /**
  100384. * Update the current camera state depending on the inputs that have been used this frame.
  100385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100386. */
  100387. checkInputs(): void;
  100388. /**
  100389. * Gets the class name of the current intput.
  100390. * @returns the class name
  100391. */
  100392. getClassName(): string;
  100393. /**
  100394. * Get the friendly name associated with the input class.
  100395. * @returns the input friendly name
  100396. */
  100397. getSimpleName(): string;
  100398. }
  100399. }
  100400. declare module BABYLON {
  100401. /**
  100402. * Manage the mouse wheel inputs to control an arc rotate camera.
  100403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100404. */
  100405. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100406. /**
  100407. * Defines the camera the input is attached to.
  100408. */
  100409. camera: ArcRotateCamera;
  100410. /**
  100411. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100412. */
  100413. wheelPrecision: number;
  100414. /**
  100415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100417. */
  100418. wheelDeltaPercentage: number;
  100419. private _wheel;
  100420. private _observer;
  100421. private computeDeltaFromMouseWheelLegacyEvent;
  100422. /**
  100423. * Attach the input controls to a specific dom element to get the input from.
  100424. * @param element Defines the element the controls should be listened from
  100425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100426. */
  100427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100428. /**
  100429. * Detach the current controls from the specified dom element.
  100430. * @param element Defines the element to stop listening the inputs from
  100431. */
  100432. detachControl(element: Nullable<HTMLElement>): void;
  100433. /**
  100434. * Gets the class name of the current intput.
  100435. * @returns the class name
  100436. */
  100437. getClassName(): string;
  100438. /**
  100439. * Get the friendly name associated with the input class.
  100440. * @returns the input friendly name
  100441. */
  100442. getSimpleName(): string;
  100443. }
  100444. }
  100445. declare module BABYLON {
  100446. /**
  100447. * Default Inputs manager for the ArcRotateCamera.
  100448. * It groups all the default supported inputs for ease of use.
  100449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100450. */
  100451. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100452. /**
  100453. * Instantiates a new ArcRotateCameraInputsManager.
  100454. * @param camera Defines the camera the inputs belong to
  100455. */
  100456. constructor(camera: ArcRotateCamera);
  100457. /**
  100458. * Add mouse wheel input support to the input manager.
  100459. * @returns the current input manager
  100460. */
  100461. addMouseWheel(): ArcRotateCameraInputsManager;
  100462. /**
  100463. * Add pointers input support to the input manager.
  100464. * @returns the current input manager
  100465. */
  100466. addPointers(): ArcRotateCameraInputsManager;
  100467. /**
  100468. * Add keyboard input support to the input manager.
  100469. * @returns the current input manager
  100470. */
  100471. addKeyboard(): ArcRotateCameraInputsManager;
  100472. }
  100473. }
  100474. declare module BABYLON {
  100475. /**
  100476. * This represents an orbital type of camera.
  100477. *
  100478. * 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.
  100479. * 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.
  100480. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100481. */
  100482. export class ArcRotateCamera extends TargetCamera {
  100483. /**
  100484. * Defines the rotation angle of the camera along the longitudinal axis.
  100485. */
  100486. alpha: number;
  100487. /**
  100488. * Defines the rotation angle of the camera along the latitudinal axis.
  100489. */
  100490. beta: number;
  100491. /**
  100492. * Defines the radius of the camera from it s target point.
  100493. */
  100494. radius: number;
  100495. protected _target: Vector3;
  100496. protected _targetHost: Nullable<AbstractMesh>;
  100497. /**
  100498. * Defines the target point of the camera.
  100499. * The camera looks towards it form the radius distance.
  100500. */
  100501. target: Vector3;
  100502. /**
  100503. * Define the current local position of the camera in the scene
  100504. */
  100505. position: Vector3;
  100506. protected _upVector: Vector3;
  100507. protected _upToYMatrix: Matrix;
  100508. protected _YToUpMatrix: Matrix;
  100509. /**
  100510. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100511. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100512. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100513. */
  100514. upVector: Vector3;
  100515. /**
  100516. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100517. */
  100518. setMatUp(): void;
  100519. /**
  100520. * Current inertia value on the longitudinal axis.
  100521. * The bigger this number the longer it will take for the camera to stop.
  100522. */
  100523. inertialAlphaOffset: number;
  100524. /**
  100525. * Current inertia value on the latitudinal axis.
  100526. * The bigger this number the longer it will take for the camera to stop.
  100527. */
  100528. inertialBetaOffset: number;
  100529. /**
  100530. * Current inertia value on the radius axis.
  100531. * The bigger this number the longer it will take for the camera to stop.
  100532. */
  100533. inertialRadiusOffset: number;
  100534. /**
  100535. * Minimum allowed angle on the longitudinal axis.
  100536. * This can help limiting how the Camera is able to move in the scene.
  100537. */
  100538. lowerAlphaLimit: Nullable<number>;
  100539. /**
  100540. * Maximum allowed angle on the longitudinal axis.
  100541. * This can help limiting how the Camera is able to move in the scene.
  100542. */
  100543. upperAlphaLimit: Nullable<number>;
  100544. /**
  100545. * Minimum allowed angle on the latitudinal axis.
  100546. * This can help limiting how the Camera is able to move in the scene.
  100547. */
  100548. lowerBetaLimit: number;
  100549. /**
  100550. * Maximum allowed angle on the latitudinal axis.
  100551. * This can help limiting how the Camera is able to move in the scene.
  100552. */
  100553. upperBetaLimit: number;
  100554. /**
  100555. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100556. * This can help limiting how the Camera is able to move in the scene.
  100557. */
  100558. lowerRadiusLimit: Nullable<number>;
  100559. /**
  100560. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100561. * This can help limiting how the Camera is able to move in the scene.
  100562. */
  100563. upperRadiusLimit: Nullable<number>;
  100564. /**
  100565. * Defines the current inertia value used during panning of the camera along the X axis.
  100566. */
  100567. inertialPanningX: number;
  100568. /**
  100569. * Defines the current inertia value used during panning of the camera along the Y axis.
  100570. */
  100571. inertialPanningY: number;
  100572. /**
  100573. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100574. * Basically if your fingers moves away from more than this distance you will be considered
  100575. * in pinch mode.
  100576. */
  100577. pinchToPanMaxDistance: number;
  100578. /**
  100579. * Defines the maximum distance the camera can pan.
  100580. * This could help keeping the cammera always in your scene.
  100581. */
  100582. panningDistanceLimit: Nullable<number>;
  100583. /**
  100584. * Defines the target of the camera before paning.
  100585. */
  100586. panningOriginTarget: Vector3;
  100587. /**
  100588. * Defines the value of the inertia used during panning.
  100589. * 0 would mean stop inertia and one would mean no decelleration at all.
  100590. */
  100591. panningInertia: number;
  100592. /**
  100593. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100594. */
  100595. angularSensibilityX: number;
  100596. /**
  100597. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100598. */
  100599. angularSensibilityY: number;
  100600. /**
  100601. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100602. */
  100603. pinchPrecision: number;
  100604. /**
  100605. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100606. * It will be used instead of pinchDeltaPrecision if different from 0.
  100607. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100608. */
  100609. pinchDeltaPercentage: number;
  100610. /**
  100611. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100612. */
  100613. panningSensibility: number;
  100614. /**
  100615. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100616. */
  100617. keysUp: number[];
  100618. /**
  100619. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100620. */
  100621. keysDown: number[];
  100622. /**
  100623. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100624. */
  100625. keysLeft: number[];
  100626. /**
  100627. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100628. */
  100629. keysRight: number[];
  100630. /**
  100631. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100632. */
  100633. wheelPrecision: number;
  100634. /**
  100635. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100636. * It will be used instead of pinchDeltaPrecision if different from 0.
  100637. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100638. */
  100639. wheelDeltaPercentage: number;
  100640. /**
  100641. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100642. */
  100643. zoomOnFactor: number;
  100644. /**
  100645. * Defines a screen offset for the camera position.
  100646. */
  100647. targetScreenOffset: Vector2;
  100648. /**
  100649. * Allows the camera to be completely reversed.
  100650. * If false the camera can not arrive upside down.
  100651. */
  100652. allowUpsideDown: boolean;
  100653. /**
  100654. * Define if double tap/click is used to restore the previously saved state of the camera.
  100655. */
  100656. useInputToRestoreState: boolean;
  100657. /** @hidden */
  100658. _viewMatrix: Matrix;
  100659. /** @hidden */
  100660. _useCtrlForPanning: boolean;
  100661. /** @hidden */
  100662. _panningMouseButton: number;
  100663. /**
  100664. * Defines the input associated to the camera.
  100665. */
  100666. inputs: ArcRotateCameraInputsManager;
  100667. /** @hidden */
  100668. _reset: () => void;
  100669. /**
  100670. * Defines the allowed panning axis.
  100671. */
  100672. panningAxis: Vector3;
  100673. protected _localDirection: Vector3;
  100674. protected _transformedDirection: Vector3;
  100675. private _bouncingBehavior;
  100676. /**
  100677. * Gets the bouncing behavior of the camera if it has been enabled.
  100678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100679. */
  100680. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100681. /**
  100682. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100684. */
  100685. useBouncingBehavior: boolean;
  100686. private _framingBehavior;
  100687. /**
  100688. * Gets the framing behavior of the camera if it has been enabled.
  100689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100690. */
  100691. readonly framingBehavior: Nullable<FramingBehavior>;
  100692. /**
  100693. * Defines if the framing behavior of the camera is enabled on the camera.
  100694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100695. */
  100696. useFramingBehavior: boolean;
  100697. private _autoRotationBehavior;
  100698. /**
  100699. * Gets the auto rotation behavior of the camera if it has been enabled.
  100700. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100701. */
  100702. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100703. /**
  100704. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100705. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100706. */
  100707. useAutoRotationBehavior: boolean;
  100708. /**
  100709. * Observable triggered when the mesh target has been changed on the camera.
  100710. */
  100711. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100712. /**
  100713. * Event raised when the camera is colliding with a mesh.
  100714. */
  100715. onCollide: (collidedMesh: AbstractMesh) => void;
  100716. /**
  100717. * Defines whether the camera should check collision with the objects oh the scene.
  100718. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100719. */
  100720. checkCollisions: boolean;
  100721. /**
  100722. * Defines the collision radius of the camera.
  100723. * This simulates a sphere around the camera.
  100724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100725. */
  100726. collisionRadius: Vector3;
  100727. protected _collider: Collider;
  100728. protected _previousPosition: Vector3;
  100729. protected _collisionVelocity: Vector3;
  100730. protected _newPosition: Vector3;
  100731. protected _previousAlpha: number;
  100732. protected _previousBeta: number;
  100733. protected _previousRadius: number;
  100734. protected _collisionTriggered: boolean;
  100735. protected _targetBoundingCenter: Nullable<Vector3>;
  100736. private _computationVector;
  100737. /**
  100738. * Instantiates a new ArcRotateCamera in a given scene
  100739. * @param name Defines the name of the camera
  100740. * @param alpha Defines the camera rotation along the logitudinal axis
  100741. * @param beta Defines the camera rotation along the latitudinal axis
  100742. * @param radius Defines the camera distance from its target
  100743. * @param target Defines the camera target
  100744. * @param scene Defines the scene the camera belongs to
  100745. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100746. */
  100747. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100748. /** @hidden */
  100749. _initCache(): void;
  100750. /** @hidden */
  100751. _updateCache(ignoreParentClass?: boolean): void;
  100752. protected _getTargetPosition(): Vector3;
  100753. private _storedAlpha;
  100754. private _storedBeta;
  100755. private _storedRadius;
  100756. private _storedTarget;
  100757. /**
  100758. * Stores the current state of the camera (alpha, beta, radius and target)
  100759. * @returns the camera itself
  100760. */
  100761. storeState(): Camera;
  100762. /**
  100763. * @hidden
  100764. * Restored camera state. You must call storeState() first
  100765. */
  100766. _restoreStateValues(): boolean;
  100767. /** @hidden */
  100768. _isSynchronizedViewMatrix(): boolean;
  100769. /**
  100770. * Attached controls to the current camera.
  100771. * @param element Defines the element the controls should be listened from
  100772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100773. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100774. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100775. */
  100776. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100777. /**
  100778. * Detach the current controls from the camera.
  100779. * The camera will stop reacting to inputs.
  100780. * @param element Defines the element to stop listening the inputs from
  100781. */
  100782. detachControl(element: HTMLElement): void;
  100783. /** @hidden */
  100784. _checkInputs(): void;
  100785. protected _checkLimits(): void;
  100786. /**
  100787. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100788. */
  100789. rebuildAnglesAndRadius(): void;
  100790. /**
  100791. * Use a position to define the current camera related information like aplha, beta and radius
  100792. * @param position Defines the position to set the camera at
  100793. */
  100794. setPosition(position: Vector3): void;
  100795. /**
  100796. * Defines the target the camera should look at.
  100797. * This will automatically adapt alpha beta and radius to fit within the new target.
  100798. * @param target Defines the new target as a Vector or a mesh
  100799. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100800. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100801. */
  100802. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100803. /** @hidden */
  100804. _getViewMatrix(): Matrix;
  100805. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100806. /**
  100807. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100808. * @param meshes Defines the mesh to zoom on
  100809. * @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)
  100810. */
  100811. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100812. /**
  100813. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100814. * The target will be changed but the radius
  100815. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100816. * @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)
  100817. */
  100818. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100819. min: Vector3;
  100820. max: Vector3;
  100821. distance: number;
  100822. }, doNotUpdateMaxZ?: boolean): void;
  100823. /**
  100824. * @override
  100825. * Override Camera.createRigCamera
  100826. */
  100827. createRigCamera(name: string, cameraIndex: number): Camera;
  100828. /**
  100829. * @hidden
  100830. * @override
  100831. * Override Camera._updateRigCameras
  100832. */
  100833. _updateRigCameras(): void;
  100834. /**
  100835. * Destroy the camera and release the current resources hold by it.
  100836. */
  100837. dispose(): void;
  100838. /**
  100839. * Gets the current object class name.
  100840. * @return the class name
  100841. */
  100842. getClassName(): string;
  100843. }
  100844. }
  100845. declare module BABYLON {
  100846. /**
  100847. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100848. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100849. */
  100850. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100851. /**
  100852. * Gets the name of the behavior.
  100853. */
  100854. readonly name: string;
  100855. private _zoomStopsAnimation;
  100856. private _idleRotationSpeed;
  100857. private _idleRotationWaitTime;
  100858. private _idleRotationSpinupTime;
  100859. /**
  100860. * Sets the flag that indicates if user zooming should stop animation.
  100861. */
  100862. /**
  100863. * Gets the flag that indicates if user zooming should stop animation.
  100864. */
  100865. zoomStopsAnimation: boolean;
  100866. /**
  100867. * Sets the default speed at which the camera rotates around the model.
  100868. */
  100869. /**
  100870. * Gets the default speed at which the camera rotates around the model.
  100871. */
  100872. idleRotationSpeed: number;
  100873. /**
  100874. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100875. */
  100876. /**
  100877. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100878. */
  100879. idleRotationWaitTime: number;
  100880. /**
  100881. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100882. */
  100883. /**
  100884. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100885. */
  100886. idleRotationSpinupTime: number;
  100887. /**
  100888. * Gets a value indicating if the camera is currently rotating because of this behavior
  100889. */
  100890. readonly rotationInProgress: boolean;
  100891. private _onPrePointerObservableObserver;
  100892. private _onAfterCheckInputsObserver;
  100893. private _attachedCamera;
  100894. private _isPointerDown;
  100895. private _lastFrameTime;
  100896. private _lastInteractionTime;
  100897. private _cameraRotationSpeed;
  100898. /**
  100899. * Initializes the behavior.
  100900. */
  100901. init(): void;
  100902. /**
  100903. * Attaches the behavior to its arc rotate camera.
  100904. * @param camera Defines the camera to attach the behavior to
  100905. */
  100906. attach(camera: ArcRotateCamera): void;
  100907. /**
  100908. * Detaches the behavior from its current arc rotate camera.
  100909. */
  100910. detach(): void;
  100911. /**
  100912. * Returns true if user is scrolling.
  100913. * @return true if user is scrolling.
  100914. */
  100915. private _userIsZooming;
  100916. private _lastFrameRadius;
  100917. private _shouldAnimationStopForInteraction;
  100918. /**
  100919. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100920. */
  100921. private _applyUserInteraction;
  100922. private _userIsMoving;
  100923. }
  100924. }
  100925. declare module BABYLON {
  100926. /**
  100927. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100928. */
  100929. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100930. private ui;
  100931. /**
  100932. * The name of the behavior
  100933. */
  100934. name: string;
  100935. /**
  100936. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100937. */
  100938. distanceAwayFromFace: number;
  100939. /**
  100940. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100941. */
  100942. distanceAwayFromBottomOfFace: number;
  100943. private _faceVectors;
  100944. private _target;
  100945. private _scene;
  100946. private _onRenderObserver;
  100947. private _tmpMatrix;
  100948. private _tmpVector;
  100949. /**
  100950. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100951. * @param ui The transform node that should be attched to the mesh
  100952. */
  100953. constructor(ui: TransformNode);
  100954. /**
  100955. * Initializes the behavior
  100956. */
  100957. init(): void;
  100958. private _closestFace;
  100959. private _zeroVector;
  100960. private _lookAtTmpMatrix;
  100961. private _lookAtToRef;
  100962. /**
  100963. * Attaches the AttachToBoxBehavior to the passed in mesh
  100964. * @param target The mesh that the specified node will be attached to
  100965. */
  100966. attach(target: Mesh): void;
  100967. /**
  100968. * Detaches the behavior from the mesh
  100969. */
  100970. detach(): void;
  100971. }
  100972. }
  100973. declare module BABYLON {
  100974. /**
  100975. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100976. */
  100977. export class FadeInOutBehavior implements Behavior<Mesh> {
  100978. /**
  100979. * Time in milliseconds to delay before fading in (Default: 0)
  100980. */
  100981. delay: number;
  100982. /**
  100983. * Time in milliseconds for the mesh to fade in (Default: 300)
  100984. */
  100985. fadeInTime: number;
  100986. private _millisecondsPerFrame;
  100987. private _hovered;
  100988. private _hoverValue;
  100989. private _ownerNode;
  100990. /**
  100991. * Instatiates the FadeInOutBehavior
  100992. */
  100993. constructor();
  100994. /**
  100995. * The name of the behavior
  100996. */
  100997. readonly name: string;
  100998. /**
  100999. * Initializes the behavior
  101000. */
  101001. init(): void;
  101002. /**
  101003. * Attaches the fade behavior on the passed in mesh
  101004. * @param ownerNode The mesh that will be faded in/out once attached
  101005. */
  101006. attach(ownerNode: Mesh): void;
  101007. /**
  101008. * Detaches the behavior from the mesh
  101009. */
  101010. detach(): void;
  101011. /**
  101012. * Triggers the mesh to begin fading in or out
  101013. * @param value if the object should fade in or out (true to fade in)
  101014. */
  101015. fadeIn(value: boolean): void;
  101016. private _update;
  101017. private _setAllVisibility;
  101018. }
  101019. }
  101020. declare module BABYLON {
  101021. /**
  101022. * Class containing a set of static utilities functions for managing Pivots
  101023. * @hidden
  101024. */
  101025. export class PivotTools {
  101026. private static _PivotCached;
  101027. private static _OldPivotPoint;
  101028. private static _PivotTranslation;
  101029. private static _PivotTmpVector;
  101030. /** @hidden */
  101031. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101032. /** @hidden */
  101033. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Class containing static functions to help procedurally build meshes
  101039. */
  101040. export class PlaneBuilder {
  101041. /**
  101042. * Creates a plane mesh
  101043. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101044. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101045. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101049. * @param name defines the name of the mesh
  101050. * @param options defines the options used to create the mesh
  101051. * @param scene defines the hosting scene
  101052. * @returns the plane mesh
  101053. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101054. */
  101055. static CreatePlane(name: string, options: {
  101056. size?: number;
  101057. width?: number;
  101058. height?: number;
  101059. sideOrientation?: number;
  101060. frontUVs?: Vector4;
  101061. backUVs?: Vector4;
  101062. updatable?: boolean;
  101063. sourcePlane?: Plane;
  101064. }, scene?: Nullable<Scene>): Mesh;
  101065. }
  101066. }
  101067. declare module BABYLON {
  101068. /**
  101069. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101070. */
  101071. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101072. private static _AnyMouseID;
  101073. /**
  101074. * Abstract mesh the behavior is set on
  101075. */
  101076. attachedNode: AbstractMesh;
  101077. private _dragPlane;
  101078. private _scene;
  101079. private _pointerObserver;
  101080. private _beforeRenderObserver;
  101081. private static _planeScene;
  101082. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101083. /**
  101084. * 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)
  101085. */
  101086. maxDragAngle: number;
  101087. /**
  101088. * @hidden
  101089. */
  101090. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101091. /**
  101092. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101093. */
  101094. currentDraggingPointerID: number;
  101095. /**
  101096. * The last position where the pointer hit the drag plane in world space
  101097. */
  101098. lastDragPosition: Vector3;
  101099. /**
  101100. * If the behavior is currently in a dragging state
  101101. */
  101102. dragging: boolean;
  101103. /**
  101104. * 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)
  101105. */
  101106. dragDeltaRatio: number;
  101107. /**
  101108. * If the drag plane orientation should be updated during the dragging (Default: true)
  101109. */
  101110. updateDragPlane: boolean;
  101111. private _debugMode;
  101112. private _moving;
  101113. /**
  101114. * Fires each time the attached mesh is dragged with the pointer
  101115. * * delta between last drag position and current drag position in world space
  101116. * * dragDistance along the drag axis
  101117. * * dragPlaneNormal normal of the current drag plane used during the drag
  101118. * * dragPlanePoint in world space where the drag intersects the drag plane
  101119. */
  101120. onDragObservable: Observable<{
  101121. delta: Vector3;
  101122. dragPlanePoint: Vector3;
  101123. dragPlaneNormal: Vector3;
  101124. dragDistance: number;
  101125. pointerId: number;
  101126. }>;
  101127. /**
  101128. * Fires each time a drag begins (eg. mouse down on mesh)
  101129. */
  101130. onDragStartObservable: Observable<{
  101131. dragPlanePoint: Vector3;
  101132. pointerId: number;
  101133. }>;
  101134. /**
  101135. * Fires each time a drag ends (eg. mouse release after drag)
  101136. */
  101137. onDragEndObservable: Observable<{
  101138. dragPlanePoint: Vector3;
  101139. pointerId: number;
  101140. }>;
  101141. /**
  101142. * If the attached mesh should be moved when dragged
  101143. */
  101144. moveAttached: boolean;
  101145. /**
  101146. * If the drag behavior will react to drag events (Default: true)
  101147. */
  101148. enabled: boolean;
  101149. /**
  101150. * If pointer events should start and release the drag (Default: true)
  101151. */
  101152. startAndReleaseDragOnPointerEvents: boolean;
  101153. /**
  101154. * If camera controls should be detached during the drag
  101155. */
  101156. detachCameraControls: boolean;
  101157. /**
  101158. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101159. */
  101160. useObjectOrienationForDragging: boolean;
  101161. private _options;
  101162. /**
  101163. * Creates a pointer drag behavior that can be attached to a mesh
  101164. * @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)
  101165. */
  101166. constructor(options?: {
  101167. dragAxis?: Vector3;
  101168. dragPlaneNormal?: Vector3;
  101169. });
  101170. /**
  101171. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101172. */
  101173. validateDrag: (targetPosition: Vector3) => boolean;
  101174. /**
  101175. * The name of the behavior
  101176. */
  101177. readonly name: string;
  101178. /**
  101179. * Initializes the behavior
  101180. */
  101181. init(): void;
  101182. private _tmpVector;
  101183. private _alternatePickedPoint;
  101184. private _worldDragAxis;
  101185. private _targetPosition;
  101186. private _attachedElement;
  101187. /**
  101188. * Attaches the drag behavior the passed in mesh
  101189. * @param ownerNode The mesh that will be dragged around once attached
  101190. */
  101191. attach(ownerNode: AbstractMesh): void;
  101192. /**
  101193. * Force relase the drag action by code.
  101194. */
  101195. releaseDrag(): void;
  101196. private _startDragRay;
  101197. private _lastPointerRay;
  101198. /**
  101199. * Simulates the start of a pointer drag event on the behavior
  101200. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101201. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101202. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101203. */
  101204. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101205. private _startDrag;
  101206. private _dragDelta;
  101207. private _moveDrag;
  101208. private _pickWithRayOnDragPlane;
  101209. private _pointA;
  101210. private _pointB;
  101211. private _pointC;
  101212. private _lineA;
  101213. private _lineB;
  101214. private _localAxis;
  101215. private _lookAt;
  101216. private _updateDragPlanePosition;
  101217. /**
  101218. * Detaches the behavior from the mesh
  101219. */
  101220. detach(): void;
  101221. }
  101222. }
  101223. declare module BABYLON {
  101224. /**
  101225. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101226. */
  101227. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101228. private _dragBehaviorA;
  101229. private _dragBehaviorB;
  101230. private _startDistance;
  101231. private _initialScale;
  101232. private _targetScale;
  101233. private _ownerNode;
  101234. private _sceneRenderObserver;
  101235. /**
  101236. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101237. */
  101238. constructor();
  101239. /**
  101240. * The name of the behavior
  101241. */
  101242. readonly name: string;
  101243. /**
  101244. * Initializes the behavior
  101245. */
  101246. init(): void;
  101247. private _getCurrentDistance;
  101248. /**
  101249. * Attaches the scale behavior the passed in mesh
  101250. * @param ownerNode The mesh that will be scaled around once attached
  101251. */
  101252. attach(ownerNode: Mesh): void;
  101253. /**
  101254. * Detaches the behavior from the mesh
  101255. */
  101256. detach(): void;
  101257. }
  101258. }
  101259. declare module BABYLON {
  101260. /**
  101261. * 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
  101262. */
  101263. export class SixDofDragBehavior implements Behavior<Mesh> {
  101264. private static _virtualScene;
  101265. private _ownerNode;
  101266. private _sceneRenderObserver;
  101267. private _scene;
  101268. private _targetPosition;
  101269. private _virtualOriginMesh;
  101270. private _virtualDragMesh;
  101271. private _pointerObserver;
  101272. private _moving;
  101273. private _startingOrientation;
  101274. /**
  101275. * 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)
  101276. */
  101277. private zDragFactor;
  101278. /**
  101279. * If the object should rotate to face the drag origin
  101280. */
  101281. rotateDraggedObject: boolean;
  101282. /**
  101283. * If the behavior is currently in a dragging state
  101284. */
  101285. dragging: boolean;
  101286. /**
  101287. * 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)
  101288. */
  101289. dragDeltaRatio: number;
  101290. /**
  101291. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101292. */
  101293. currentDraggingPointerID: number;
  101294. /**
  101295. * If camera controls should be detached during the drag
  101296. */
  101297. detachCameraControls: boolean;
  101298. /**
  101299. * Fires each time a drag starts
  101300. */
  101301. onDragStartObservable: Observable<{}>;
  101302. /**
  101303. * Fires each time a drag ends (eg. mouse release after drag)
  101304. */
  101305. onDragEndObservable: Observable<{}>;
  101306. /**
  101307. * 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
  101308. */
  101309. constructor();
  101310. /**
  101311. * The name of the behavior
  101312. */
  101313. readonly name: string;
  101314. /**
  101315. * Initializes the behavior
  101316. */
  101317. init(): void;
  101318. /**
  101319. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101320. */
  101321. private readonly _pointerCamera;
  101322. /**
  101323. * Attaches the scale behavior the passed in mesh
  101324. * @param ownerNode The mesh that will be scaled around once attached
  101325. */
  101326. attach(ownerNode: Mesh): void;
  101327. /**
  101328. * Detaches the behavior from the mesh
  101329. */
  101330. detach(): void;
  101331. }
  101332. }
  101333. declare module BABYLON {
  101334. /**
  101335. * Class used to apply inverse kinematics to bones
  101336. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101337. */
  101338. export class BoneIKController {
  101339. private static _tmpVecs;
  101340. private static _tmpQuat;
  101341. private static _tmpMats;
  101342. /**
  101343. * Gets or sets the target mesh
  101344. */
  101345. targetMesh: AbstractMesh;
  101346. /** Gets or sets the mesh used as pole */
  101347. poleTargetMesh: AbstractMesh;
  101348. /**
  101349. * Gets or sets the bone used as pole
  101350. */
  101351. poleTargetBone: Nullable<Bone>;
  101352. /**
  101353. * Gets or sets the target position
  101354. */
  101355. targetPosition: Vector3;
  101356. /**
  101357. * Gets or sets the pole target position
  101358. */
  101359. poleTargetPosition: Vector3;
  101360. /**
  101361. * Gets or sets the pole target local offset
  101362. */
  101363. poleTargetLocalOffset: Vector3;
  101364. /**
  101365. * Gets or sets the pole angle
  101366. */
  101367. poleAngle: number;
  101368. /**
  101369. * Gets or sets the mesh associated with the controller
  101370. */
  101371. mesh: AbstractMesh;
  101372. /**
  101373. * 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)
  101374. */
  101375. slerpAmount: number;
  101376. private _bone1Quat;
  101377. private _bone1Mat;
  101378. private _bone2Ang;
  101379. private _bone1;
  101380. private _bone2;
  101381. private _bone1Length;
  101382. private _bone2Length;
  101383. private _maxAngle;
  101384. private _maxReach;
  101385. private _rightHandedSystem;
  101386. private _bendAxis;
  101387. private _slerping;
  101388. private _adjustRoll;
  101389. /**
  101390. * Gets or sets maximum allowed angle
  101391. */
  101392. maxAngle: number;
  101393. /**
  101394. * Creates a new BoneIKController
  101395. * @param mesh defines the mesh to control
  101396. * @param bone defines the bone to control
  101397. * @param options defines options to set up the controller
  101398. */
  101399. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101400. targetMesh?: AbstractMesh;
  101401. poleTargetMesh?: AbstractMesh;
  101402. poleTargetBone?: Bone;
  101403. poleTargetLocalOffset?: Vector3;
  101404. poleAngle?: number;
  101405. bendAxis?: Vector3;
  101406. maxAngle?: number;
  101407. slerpAmount?: number;
  101408. });
  101409. private _setMaxAngle;
  101410. /**
  101411. * Force the controller to update the bones
  101412. */
  101413. update(): void;
  101414. }
  101415. }
  101416. declare module BABYLON {
  101417. /**
  101418. * Class used to make a bone look toward a point in space
  101419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101420. */
  101421. export class BoneLookController {
  101422. private static _tmpVecs;
  101423. private static _tmpQuat;
  101424. private static _tmpMats;
  101425. /**
  101426. * The target Vector3 that the bone will look at
  101427. */
  101428. target: Vector3;
  101429. /**
  101430. * The mesh that the bone is attached to
  101431. */
  101432. mesh: AbstractMesh;
  101433. /**
  101434. * The bone that will be looking to the target
  101435. */
  101436. bone: Bone;
  101437. /**
  101438. * The up axis of the coordinate system that is used when the bone is rotated
  101439. */
  101440. upAxis: Vector3;
  101441. /**
  101442. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101443. */
  101444. upAxisSpace: Space;
  101445. /**
  101446. * Used to make an adjustment to the yaw of the bone
  101447. */
  101448. adjustYaw: number;
  101449. /**
  101450. * Used to make an adjustment to the pitch of the bone
  101451. */
  101452. adjustPitch: number;
  101453. /**
  101454. * Used to make an adjustment to the roll of the bone
  101455. */
  101456. adjustRoll: number;
  101457. /**
  101458. * 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)
  101459. */
  101460. slerpAmount: number;
  101461. private _minYaw;
  101462. private _maxYaw;
  101463. private _minPitch;
  101464. private _maxPitch;
  101465. private _minYawSin;
  101466. private _minYawCos;
  101467. private _maxYawSin;
  101468. private _maxYawCos;
  101469. private _midYawConstraint;
  101470. private _minPitchTan;
  101471. private _maxPitchTan;
  101472. private _boneQuat;
  101473. private _slerping;
  101474. private _transformYawPitch;
  101475. private _transformYawPitchInv;
  101476. private _firstFrameSkipped;
  101477. private _yawRange;
  101478. private _fowardAxis;
  101479. /**
  101480. * Gets or sets the minimum yaw angle that the bone can look to
  101481. */
  101482. minYaw: number;
  101483. /**
  101484. * Gets or sets the maximum yaw angle that the bone can look to
  101485. */
  101486. maxYaw: number;
  101487. /**
  101488. * Gets or sets the minimum pitch angle that the bone can look to
  101489. */
  101490. minPitch: number;
  101491. /**
  101492. * Gets or sets the maximum pitch angle that the bone can look to
  101493. */
  101494. maxPitch: number;
  101495. /**
  101496. * Create a BoneLookController
  101497. * @param mesh the mesh that the bone belongs to
  101498. * @param bone the bone that will be looking to the target
  101499. * @param target the target Vector3 to look at
  101500. * @param options optional settings:
  101501. * * maxYaw: the maximum angle the bone will yaw to
  101502. * * minYaw: the minimum angle the bone will yaw to
  101503. * * maxPitch: the maximum angle the bone will pitch to
  101504. * * minPitch: the minimum angle the bone will yaw to
  101505. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101506. * * upAxis: the up axis of the coordinate system
  101507. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101508. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101509. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101510. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101511. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101512. * * adjustRoll: used to make an adjustment to the roll of the bone
  101513. **/
  101514. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101515. maxYaw?: number;
  101516. minYaw?: number;
  101517. maxPitch?: number;
  101518. minPitch?: number;
  101519. slerpAmount?: number;
  101520. upAxis?: Vector3;
  101521. upAxisSpace?: Space;
  101522. yawAxis?: Vector3;
  101523. pitchAxis?: Vector3;
  101524. adjustYaw?: number;
  101525. adjustPitch?: number;
  101526. adjustRoll?: number;
  101527. });
  101528. /**
  101529. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101530. */
  101531. update(): void;
  101532. private _getAngleDiff;
  101533. private _getAngleBetween;
  101534. private _isAngleBetween;
  101535. }
  101536. }
  101537. declare module BABYLON {
  101538. /**
  101539. * Manage the gamepad inputs to control an arc rotate camera.
  101540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101541. */
  101542. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101543. /**
  101544. * Defines the camera the input is attached to.
  101545. */
  101546. camera: ArcRotateCamera;
  101547. /**
  101548. * Defines the gamepad the input is gathering event from.
  101549. */
  101550. gamepad: Nullable<Gamepad>;
  101551. /**
  101552. * Defines the gamepad rotation sensiblity.
  101553. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101554. */
  101555. gamepadRotationSensibility: number;
  101556. /**
  101557. * Defines the gamepad move sensiblity.
  101558. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101559. */
  101560. gamepadMoveSensibility: number;
  101561. private _onGamepadConnectedObserver;
  101562. private _onGamepadDisconnectedObserver;
  101563. /**
  101564. * Attach the input controls to a specific dom element to get the input from.
  101565. * @param element Defines the element the controls should be listened from
  101566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101567. */
  101568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101569. /**
  101570. * Detach the current controls from the specified dom element.
  101571. * @param element Defines the element to stop listening the inputs from
  101572. */
  101573. detachControl(element: Nullable<HTMLElement>): void;
  101574. /**
  101575. * Update the current camera state depending on the inputs that have been used this frame.
  101576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101577. */
  101578. checkInputs(): void;
  101579. /**
  101580. * Gets the class name of the current intput.
  101581. * @returns the class name
  101582. */
  101583. getClassName(): string;
  101584. /**
  101585. * Get the friendly name associated with the input class.
  101586. * @returns the input friendly name
  101587. */
  101588. getSimpleName(): string;
  101589. }
  101590. }
  101591. declare module BABYLON {
  101592. interface ArcRotateCameraInputsManager {
  101593. /**
  101594. * Add orientation input support to the input manager.
  101595. * @returns the current input manager
  101596. */
  101597. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101598. }
  101599. /**
  101600. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101602. */
  101603. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101604. /**
  101605. * Defines the camera the input is attached to.
  101606. */
  101607. camera: ArcRotateCamera;
  101608. /**
  101609. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101610. */
  101611. alphaCorrection: number;
  101612. /**
  101613. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101614. */
  101615. gammaCorrection: number;
  101616. private _alpha;
  101617. private _gamma;
  101618. private _dirty;
  101619. private _deviceOrientationHandler;
  101620. /**
  101621. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101622. */
  101623. constructor();
  101624. /**
  101625. * Attach the input controls to a specific dom element to get the input from.
  101626. * @param element Defines the element the controls should be listened from
  101627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101628. */
  101629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101630. /** @hidden */
  101631. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101632. /**
  101633. * Update the current camera state depending on the inputs that have been used this frame.
  101634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101635. */
  101636. checkInputs(): void;
  101637. /**
  101638. * Detach the current controls from the specified dom element.
  101639. * @param element Defines the element to stop listening the inputs from
  101640. */
  101641. detachControl(element: Nullable<HTMLElement>): void;
  101642. /**
  101643. * Gets the class name of the current intput.
  101644. * @returns the class name
  101645. */
  101646. getClassName(): string;
  101647. /**
  101648. * Get the friendly name associated with the input class.
  101649. * @returns the input friendly name
  101650. */
  101651. getSimpleName(): string;
  101652. }
  101653. }
  101654. declare module BABYLON {
  101655. /**
  101656. * Listen to mouse events to control the camera.
  101657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101658. */
  101659. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101660. /**
  101661. * Defines the camera the input is attached to.
  101662. */
  101663. camera: FlyCamera;
  101664. /**
  101665. * Defines if touch is enabled. (Default is true.)
  101666. */
  101667. touchEnabled: boolean;
  101668. /**
  101669. * Defines the buttons associated with the input to handle camera rotation.
  101670. */
  101671. buttons: number[];
  101672. /**
  101673. * Assign buttons for Yaw control.
  101674. */
  101675. buttonsYaw: number[];
  101676. /**
  101677. * Assign buttons for Pitch control.
  101678. */
  101679. buttonsPitch: number[];
  101680. /**
  101681. * Assign buttons for Roll control.
  101682. */
  101683. buttonsRoll: number[];
  101684. /**
  101685. * Detect if any button is being pressed while mouse is moved.
  101686. * -1 = Mouse locked.
  101687. * 0 = Left button.
  101688. * 1 = Middle Button.
  101689. * 2 = Right Button.
  101690. */
  101691. activeButton: number;
  101692. /**
  101693. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101694. * Higher values reduce its sensitivity.
  101695. */
  101696. angularSensibility: number;
  101697. private _mousemoveCallback;
  101698. private _observer;
  101699. private _rollObserver;
  101700. private previousPosition;
  101701. private noPreventDefault;
  101702. private element;
  101703. /**
  101704. * Listen to mouse events to control the camera.
  101705. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101707. */
  101708. constructor(touchEnabled?: boolean);
  101709. /**
  101710. * Attach the mouse control to the HTML DOM element.
  101711. * @param element Defines the element that listens to the input events.
  101712. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101713. */
  101714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101715. /**
  101716. * Detach the current controls from the specified dom element.
  101717. * @param element Defines the element to stop listening the inputs from
  101718. */
  101719. detachControl(element: Nullable<HTMLElement>): void;
  101720. /**
  101721. * Gets the class name of the current input.
  101722. * @returns the class name.
  101723. */
  101724. getClassName(): string;
  101725. /**
  101726. * Get the friendly name associated with the input class.
  101727. * @returns the input's friendly name.
  101728. */
  101729. getSimpleName(): string;
  101730. private _pointerInput;
  101731. private _onMouseMove;
  101732. /**
  101733. * Rotate camera by mouse offset.
  101734. */
  101735. private rotateCamera;
  101736. }
  101737. }
  101738. declare module BABYLON {
  101739. /**
  101740. * Default Inputs manager for the FlyCamera.
  101741. * It groups all the default supported inputs for ease of use.
  101742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101743. */
  101744. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101745. /**
  101746. * Instantiates a new FlyCameraInputsManager.
  101747. * @param camera Defines the camera the inputs belong to.
  101748. */
  101749. constructor(camera: FlyCamera);
  101750. /**
  101751. * Add keyboard input support to the input manager.
  101752. * @returns the new FlyCameraKeyboardMoveInput().
  101753. */
  101754. addKeyboard(): FlyCameraInputsManager;
  101755. /**
  101756. * Add mouse input support to the input manager.
  101757. * @param touchEnabled Enable touch screen support.
  101758. * @returns the new FlyCameraMouseInput().
  101759. */
  101760. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101761. }
  101762. }
  101763. declare module BABYLON {
  101764. /**
  101765. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101766. * such as in a 3D Space Shooter or a Flight Simulator.
  101767. */
  101768. export class FlyCamera extends TargetCamera {
  101769. /**
  101770. * Define the collision ellipsoid of the camera.
  101771. * This is helpful for simulating a camera body, like a player's body.
  101772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101773. */
  101774. ellipsoid: Vector3;
  101775. /**
  101776. * Define an offset for the position of the ellipsoid around the camera.
  101777. * This can be helpful if the camera is attached away from the player's body center,
  101778. * such as at its head.
  101779. */
  101780. ellipsoidOffset: Vector3;
  101781. /**
  101782. * Enable or disable collisions of the camera with the rest of the scene objects.
  101783. */
  101784. checkCollisions: boolean;
  101785. /**
  101786. * Enable or disable gravity on the camera.
  101787. */
  101788. applyGravity: boolean;
  101789. /**
  101790. * Define the current direction the camera is moving to.
  101791. */
  101792. cameraDirection: Vector3;
  101793. /**
  101794. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101795. * This overrides and empties cameraRotation.
  101796. */
  101797. rotationQuaternion: Quaternion;
  101798. /**
  101799. * Track Roll to maintain the wanted Rolling when looking around.
  101800. */
  101801. _trackRoll: number;
  101802. /**
  101803. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101804. */
  101805. rollCorrect: number;
  101806. /**
  101807. * Mimic a banked turn, Rolling the camera when Yawing.
  101808. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101809. */
  101810. bankedTurn: boolean;
  101811. /**
  101812. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101813. */
  101814. bankedTurnLimit: number;
  101815. /**
  101816. * Value of 0 disables the banked Roll.
  101817. * Value of 1 is equal to the Yaw angle in radians.
  101818. */
  101819. bankedTurnMultiplier: number;
  101820. /**
  101821. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101822. */
  101823. inputs: FlyCameraInputsManager;
  101824. /**
  101825. * Gets the input sensibility for mouse input.
  101826. * Higher values reduce sensitivity.
  101827. */
  101828. /**
  101829. * Sets the input sensibility for a mouse input.
  101830. * Higher values reduce sensitivity.
  101831. */
  101832. angularSensibility: number;
  101833. /**
  101834. * Get the keys for camera movement forward.
  101835. */
  101836. /**
  101837. * Set the keys for camera movement forward.
  101838. */
  101839. keysForward: number[];
  101840. /**
  101841. * Get the keys for camera movement backward.
  101842. */
  101843. keysBackward: number[];
  101844. /**
  101845. * Get the keys for camera movement up.
  101846. */
  101847. /**
  101848. * Set the keys for camera movement up.
  101849. */
  101850. keysUp: number[];
  101851. /**
  101852. * Get the keys for camera movement down.
  101853. */
  101854. /**
  101855. * Set the keys for camera movement down.
  101856. */
  101857. keysDown: number[];
  101858. /**
  101859. * Get the keys for camera movement left.
  101860. */
  101861. /**
  101862. * Set the keys for camera movement left.
  101863. */
  101864. keysLeft: number[];
  101865. /**
  101866. * Set the keys for camera movement right.
  101867. */
  101868. /**
  101869. * Set the keys for camera movement right.
  101870. */
  101871. keysRight: number[];
  101872. /**
  101873. * Event raised when the camera collides with a mesh in the scene.
  101874. */
  101875. onCollide: (collidedMesh: AbstractMesh) => void;
  101876. private _collider;
  101877. private _needMoveForGravity;
  101878. private _oldPosition;
  101879. private _diffPosition;
  101880. private _newPosition;
  101881. /** @hidden */
  101882. _localDirection: Vector3;
  101883. /** @hidden */
  101884. _transformedDirection: Vector3;
  101885. /**
  101886. * Instantiates a FlyCamera.
  101887. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101888. * such as in a 3D Space Shooter or a Flight Simulator.
  101889. * @param name Define the name of the camera in the scene.
  101890. * @param position Define the starting position of the camera in the scene.
  101891. * @param scene Define the scene the camera belongs to.
  101892. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101893. */
  101894. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101895. /**
  101896. * Attach a control to the HTML DOM element.
  101897. * @param element Defines the element that listens to the input events.
  101898. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101899. */
  101900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101901. /**
  101902. * Detach a control from the HTML DOM element.
  101903. * The camera will stop reacting to that input.
  101904. * @param element Defines the element that listens to the input events.
  101905. */
  101906. detachControl(element: HTMLElement): void;
  101907. private _collisionMask;
  101908. /**
  101909. * Get the mask that the camera ignores in collision events.
  101910. */
  101911. /**
  101912. * Set the mask that the camera ignores in collision events.
  101913. */
  101914. collisionMask: number;
  101915. /** @hidden */
  101916. _collideWithWorld(displacement: Vector3): void;
  101917. /** @hidden */
  101918. private _onCollisionPositionChange;
  101919. /** @hidden */
  101920. _checkInputs(): void;
  101921. /** @hidden */
  101922. _decideIfNeedsToMove(): boolean;
  101923. /** @hidden */
  101924. _updatePosition(): void;
  101925. /**
  101926. * Restore the Roll to its target value at the rate specified.
  101927. * @param rate - Higher means slower restoring.
  101928. * @hidden
  101929. */
  101930. restoreRoll(rate: number): void;
  101931. /**
  101932. * Destroy the camera and release the current resources held by it.
  101933. */
  101934. dispose(): void;
  101935. /**
  101936. * Get the current object class name.
  101937. * @returns the class name.
  101938. */
  101939. getClassName(): string;
  101940. }
  101941. }
  101942. declare module BABYLON {
  101943. /**
  101944. * Listen to keyboard events to control the camera.
  101945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101946. */
  101947. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101948. /**
  101949. * Defines the camera the input is attached to.
  101950. */
  101951. camera: FlyCamera;
  101952. /**
  101953. * The list of keyboard keys used to control the forward move of the camera.
  101954. */
  101955. keysForward: number[];
  101956. /**
  101957. * The list of keyboard keys used to control the backward move of the camera.
  101958. */
  101959. keysBackward: number[];
  101960. /**
  101961. * The list of keyboard keys used to control the forward move of the camera.
  101962. */
  101963. keysUp: number[];
  101964. /**
  101965. * The list of keyboard keys used to control the backward move of the camera.
  101966. */
  101967. keysDown: number[];
  101968. /**
  101969. * The list of keyboard keys used to control the right strafe move of the camera.
  101970. */
  101971. keysRight: number[];
  101972. /**
  101973. * The list of keyboard keys used to control the left strafe move of the camera.
  101974. */
  101975. keysLeft: number[];
  101976. private _keys;
  101977. private _onCanvasBlurObserver;
  101978. private _onKeyboardObserver;
  101979. private _engine;
  101980. private _scene;
  101981. /**
  101982. * Attach the input controls to a specific dom element to get the input from.
  101983. * @param element Defines the element the controls should be listened from
  101984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101985. */
  101986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101987. /**
  101988. * Detach the current controls from the specified dom element.
  101989. * @param element Defines the element to stop listening the inputs from
  101990. */
  101991. detachControl(element: Nullable<HTMLElement>): void;
  101992. /**
  101993. * Gets the class name of the current intput.
  101994. * @returns the class name
  101995. */
  101996. getClassName(): string;
  101997. /** @hidden */
  101998. _onLostFocus(e: FocusEvent): void;
  101999. /**
  102000. * Get the friendly name associated with the input class.
  102001. * @returns the input friendly name
  102002. */
  102003. getSimpleName(): string;
  102004. /**
  102005. * Update the current camera state depending on the inputs that have been used this frame.
  102006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102007. */
  102008. checkInputs(): void;
  102009. }
  102010. }
  102011. declare module BABYLON {
  102012. /**
  102013. * Manage the mouse wheel inputs to control a follow camera.
  102014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102015. */
  102016. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102017. /**
  102018. * Defines the camera the input is attached to.
  102019. */
  102020. camera: FollowCamera;
  102021. /**
  102022. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102023. */
  102024. axisControlRadius: boolean;
  102025. /**
  102026. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102027. */
  102028. axisControlHeight: boolean;
  102029. /**
  102030. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102031. */
  102032. axisControlRotation: boolean;
  102033. /**
  102034. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102035. * relation to mouseWheel events.
  102036. */
  102037. wheelPrecision: number;
  102038. /**
  102039. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102040. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102041. */
  102042. wheelDeltaPercentage: number;
  102043. private _wheel;
  102044. private _observer;
  102045. /**
  102046. * Attach the input controls to a specific dom element to get the input from.
  102047. * @param element Defines the element the controls should be listened from
  102048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102049. */
  102050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102051. /**
  102052. * Detach the current controls from the specified dom element.
  102053. * @param element Defines the element to stop listening the inputs from
  102054. */
  102055. detachControl(element: Nullable<HTMLElement>): void;
  102056. /**
  102057. * Gets the class name of the current intput.
  102058. * @returns the class name
  102059. */
  102060. getClassName(): string;
  102061. /**
  102062. * Get the friendly name associated with the input class.
  102063. * @returns the input friendly name
  102064. */
  102065. getSimpleName(): string;
  102066. }
  102067. }
  102068. declare module BABYLON {
  102069. /**
  102070. * Manage the pointers inputs to control an follow camera.
  102071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102072. */
  102073. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102074. /**
  102075. * Defines the camera the input is attached to.
  102076. */
  102077. camera: FollowCamera;
  102078. /**
  102079. * Gets the class name of the current input.
  102080. * @returns the class name
  102081. */
  102082. getClassName(): string;
  102083. /**
  102084. * Defines the pointer angular sensibility along the X axis or how fast is
  102085. * the camera rotating.
  102086. * A negative number will reverse the axis direction.
  102087. */
  102088. angularSensibilityX: number;
  102089. /**
  102090. * Defines the pointer angular sensibility along the Y axis or how fast is
  102091. * the camera rotating.
  102092. * A negative number will reverse the axis direction.
  102093. */
  102094. angularSensibilityY: number;
  102095. /**
  102096. * Defines the pointer pinch precision or how fast is the camera zooming.
  102097. * A negative number will reverse the axis direction.
  102098. */
  102099. pinchPrecision: number;
  102100. /**
  102101. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102102. * from 0.
  102103. * It defines the percentage of current camera.radius to use as delta when
  102104. * pinch zoom is used.
  102105. */
  102106. pinchDeltaPercentage: number;
  102107. /**
  102108. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102109. */
  102110. axisXControlRadius: boolean;
  102111. /**
  102112. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102113. */
  102114. axisXControlHeight: boolean;
  102115. /**
  102116. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102117. */
  102118. axisXControlRotation: boolean;
  102119. /**
  102120. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102121. */
  102122. axisYControlRadius: boolean;
  102123. /**
  102124. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102125. */
  102126. axisYControlHeight: boolean;
  102127. /**
  102128. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102129. */
  102130. axisYControlRotation: boolean;
  102131. /**
  102132. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102133. */
  102134. axisPinchControlRadius: boolean;
  102135. /**
  102136. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102137. */
  102138. axisPinchControlHeight: boolean;
  102139. /**
  102140. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102141. */
  102142. axisPinchControlRotation: boolean;
  102143. /**
  102144. * Log error messages if basic misconfiguration has occurred.
  102145. */
  102146. warningEnable: boolean;
  102147. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102148. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102149. private _warningCounter;
  102150. private _warning;
  102151. }
  102152. }
  102153. declare module BABYLON {
  102154. /**
  102155. * Default Inputs manager for the FollowCamera.
  102156. * It groups all the default supported inputs for ease of use.
  102157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102158. */
  102159. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102160. /**
  102161. * Instantiates a new FollowCameraInputsManager.
  102162. * @param camera Defines the camera the inputs belong to
  102163. */
  102164. constructor(camera: FollowCamera);
  102165. /**
  102166. * Add keyboard input support to the input manager.
  102167. * @returns the current input manager
  102168. */
  102169. addKeyboard(): FollowCameraInputsManager;
  102170. /**
  102171. * Add mouse wheel input support to the input manager.
  102172. * @returns the current input manager
  102173. */
  102174. addMouseWheel(): FollowCameraInputsManager;
  102175. /**
  102176. * Add pointers input support to the input manager.
  102177. * @returns the current input manager
  102178. */
  102179. addPointers(): FollowCameraInputsManager;
  102180. /**
  102181. * Add orientation input support to the input manager.
  102182. * @returns the current input manager
  102183. */
  102184. addVRDeviceOrientation(): FollowCameraInputsManager;
  102185. }
  102186. }
  102187. declare module BABYLON {
  102188. /**
  102189. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102190. * an arc rotate version arcFollowCamera are available.
  102191. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102192. */
  102193. export class FollowCamera extends TargetCamera {
  102194. /**
  102195. * Distance the follow camera should follow an object at
  102196. */
  102197. radius: number;
  102198. /**
  102199. * Minimum allowed distance of the camera to the axis of rotation
  102200. * (The camera can not get closer).
  102201. * This can help limiting how the Camera is able to move in the scene.
  102202. */
  102203. lowerRadiusLimit: Nullable<number>;
  102204. /**
  102205. * Maximum allowed distance of the camera to the axis of rotation
  102206. * (The camera can not get further).
  102207. * This can help limiting how the Camera is able to move in the scene.
  102208. */
  102209. upperRadiusLimit: Nullable<number>;
  102210. /**
  102211. * Define a rotation offset between the camera and the object it follows
  102212. */
  102213. rotationOffset: number;
  102214. /**
  102215. * Minimum allowed angle to camera position relative to target object.
  102216. * This can help limiting how the Camera is able to move in the scene.
  102217. */
  102218. lowerRotationOffsetLimit: Nullable<number>;
  102219. /**
  102220. * Maximum allowed angle to camera position relative to target object.
  102221. * This can help limiting how the Camera is able to move in the scene.
  102222. */
  102223. upperRotationOffsetLimit: Nullable<number>;
  102224. /**
  102225. * Define a height offset between the camera and the object it follows.
  102226. * It can help following an object from the top (like a car chaing a plane)
  102227. */
  102228. heightOffset: number;
  102229. /**
  102230. * Minimum allowed height of camera position relative to target object.
  102231. * This can help limiting how the Camera is able to move in the scene.
  102232. */
  102233. lowerHeightOffsetLimit: Nullable<number>;
  102234. /**
  102235. * Maximum allowed height of camera position relative to target object.
  102236. * This can help limiting how the Camera is able to move in the scene.
  102237. */
  102238. upperHeightOffsetLimit: Nullable<number>;
  102239. /**
  102240. * Define how fast the camera can accelerate to follow it s target.
  102241. */
  102242. cameraAcceleration: number;
  102243. /**
  102244. * Define the speed limit of the camera following an object.
  102245. */
  102246. maxCameraSpeed: number;
  102247. /**
  102248. * Define the target of the camera.
  102249. */
  102250. lockedTarget: Nullable<AbstractMesh>;
  102251. /**
  102252. * Defines the input associated with the camera.
  102253. */
  102254. inputs: FollowCameraInputsManager;
  102255. /**
  102256. * Instantiates the follow camera.
  102257. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102258. * @param name Define the name of the camera in the scene
  102259. * @param position Define the position of the camera
  102260. * @param scene Define the scene the camera belong to
  102261. * @param lockedTarget Define the target of the camera
  102262. */
  102263. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102264. private _follow;
  102265. /**
  102266. * Attached controls to the current camera.
  102267. * @param element Defines the element the controls should be listened from
  102268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102269. */
  102270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102271. /**
  102272. * Detach the current controls from the camera.
  102273. * The camera will stop reacting to inputs.
  102274. * @param element Defines the element to stop listening the inputs from
  102275. */
  102276. detachControl(element: HTMLElement): void;
  102277. /** @hidden */
  102278. _checkInputs(): void;
  102279. private _checkLimits;
  102280. /**
  102281. * Gets the camera class name.
  102282. * @returns the class name
  102283. */
  102284. getClassName(): string;
  102285. }
  102286. /**
  102287. * Arc Rotate version of the follow camera.
  102288. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102289. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102290. */
  102291. export class ArcFollowCamera extends TargetCamera {
  102292. /** The longitudinal angle of the camera */
  102293. alpha: number;
  102294. /** The latitudinal angle of the camera */
  102295. beta: number;
  102296. /** The radius of the camera from its target */
  102297. radius: number;
  102298. /** Define the camera target (the messh it should follow) */
  102299. target: Nullable<AbstractMesh>;
  102300. private _cartesianCoordinates;
  102301. /**
  102302. * Instantiates a new ArcFollowCamera
  102303. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102304. * @param name Define the name of the camera
  102305. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102306. * @param beta Define the rotation angle of the camera around the elevation axis
  102307. * @param radius Define the radius of the camera from its target point
  102308. * @param target Define the target of the camera
  102309. * @param scene Define the scene the camera belongs to
  102310. */
  102311. constructor(name: string,
  102312. /** The longitudinal angle of the camera */
  102313. alpha: number,
  102314. /** The latitudinal angle of the camera */
  102315. beta: number,
  102316. /** The radius of the camera from its target */
  102317. radius: number,
  102318. /** Define the camera target (the messh it should follow) */
  102319. target: Nullable<AbstractMesh>, scene: Scene);
  102320. private _follow;
  102321. /** @hidden */
  102322. _checkInputs(): void;
  102323. /**
  102324. * Returns the class name of the object.
  102325. * It is mostly used internally for serialization purposes.
  102326. */
  102327. getClassName(): string;
  102328. }
  102329. }
  102330. declare module BABYLON {
  102331. /**
  102332. * Manage the keyboard inputs to control the movement of a follow camera.
  102333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102334. */
  102335. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102336. /**
  102337. * Defines the camera the input is attached to.
  102338. */
  102339. camera: FollowCamera;
  102340. /**
  102341. * Defines the list of key codes associated with the up action (increase heightOffset)
  102342. */
  102343. keysHeightOffsetIncr: number[];
  102344. /**
  102345. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102346. */
  102347. keysHeightOffsetDecr: number[];
  102348. /**
  102349. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102350. */
  102351. keysHeightOffsetModifierAlt: boolean;
  102352. /**
  102353. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102354. */
  102355. keysHeightOffsetModifierCtrl: boolean;
  102356. /**
  102357. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102358. */
  102359. keysHeightOffsetModifierShift: boolean;
  102360. /**
  102361. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102362. */
  102363. keysRotationOffsetIncr: number[];
  102364. /**
  102365. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102366. */
  102367. keysRotationOffsetDecr: number[];
  102368. /**
  102369. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102370. */
  102371. keysRotationOffsetModifierAlt: boolean;
  102372. /**
  102373. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102374. */
  102375. keysRotationOffsetModifierCtrl: boolean;
  102376. /**
  102377. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102378. */
  102379. keysRotationOffsetModifierShift: boolean;
  102380. /**
  102381. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102382. */
  102383. keysRadiusIncr: number[];
  102384. /**
  102385. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102386. */
  102387. keysRadiusDecr: number[];
  102388. /**
  102389. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102390. */
  102391. keysRadiusModifierAlt: boolean;
  102392. /**
  102393. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102394. */
  102395. keysRadiusModifierCtrl: boolean;
  102396. /**
  102397. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102398. */
  102399. keysRadiusModifierShift: boolean;
  102400. /**
  102401. * Defines the rate of change of heightOffset.
  102402. */
  102403. heightSensibility: number;
  102404. /**
  102405. * Defines the rate of change of rotationOffset.
  102406. */
  102407. rotationSensibility: number;
  102408. /**
  102409. * Defines the rate of change of radius.
  102410. */
  102411. radiusSensibility: number;
  102412. private _keys;
  102413. private _ctrlPressed;
  102414. private _altPressed;
  102415. private _shiftPressed;
  102416. private _onCanvasBlurObserver;
  102417. private _onKeyboardObserver;
  102418. private _engine;
  102419. private _scene;
  102420. /**
  102421. * Attach the input controls to a specific dom element to get the input from.
  102422. * @param element Defines the element the controls should be listened from
  102423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102424. */
  102425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102426. /**
  102427. * Detach the current controls from the specified dom element.
  102428. * @param element Defines the element to stop listening the inputs from
  102429. */
  102430. detachControl(element: Nullable<HTMLElement>): void;
  102431. /**
  102432. * Update the current camera state depending on the inputs that have been used this frame.
  102433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102434. */
  102435. checkInputs(): void;
  102436. /**
  102437. * Gets the class name of the current input.
  102438. * @returns the class name
  102439. */
  102440. getClassName(): string;
  102441. /**
  102442. * Get the friendly name associated with the input class.
  102443. * @returns the input friendly name
  102444. */
  102445. getSimpleName(): string;
  102446. /**
  102447. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102448. * allow modification of the heightOffset value.
  102449. */
  102450. private _modifierHeightOffset;
  102451. /**
  102452. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102453. * allow modification of the rotationOffset value.
  102454. */
  102455. private _modifierRotationOffset;
  102456. /**
  102457. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102458. * allow modification of the radius value.
  102459. */
  102460. private _modifierRadius;
  102461. }
  102462. }
  102463. declare module BABYLON {
  102464. interface FreeCameraInputsManager {
  102465. /**
  102466. * @hidden
  102467. */
  102468. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102469. /**
  102470. * Add orientation input support to the input manager.
  102471. * @returns the current input manager
  102472. */
  102473. addDeviceOrientation(): FreeCameraInputsManager;
  102474. }
  102475. /**
  102476. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102477. * Screen rotation is taken into account.
  102478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102479. */
  102480. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102481. private _camera;
  102482. private _screenOrientationAngle;
  102483. private _constantTranform;
  102484. private _screenQuaternion;
  102485. private _alpha;
  102486. private _beta;
  102487. private _gamma;
  102488. /**
  102489. * Can be used to detect if a device orientation sensor is availible on a device
  102490. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102491. * @returns a promise that will resolve on orientation change
  102492. */
  102493. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102494. /**
  102495. * @hidden
  102496. */
  102497. _onDeviceOrientationChangedObservable: Observable<void>;
  102498. /**
  102499. * Instantiates a new input
  102500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102501. */
  102502. constructor();
  102503. /**
  102504. * Define the camera controlled by the input.
  102505. */
  102506. camera: FreeCamera;
  102507. /**
  102508. * Attach the input controls to a specific dom element to get the input from.
  102509. * @param element Defines the element the controls should be listened from
  102510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102511. */
  102512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102513. private _orientationChanged;
  102514. private _deviceOrientation;
  102515. /**
  102516. * Detach the current controls from the specified dom element.
  102517. * @param element Defines the element to stop listening the inputs from
  102518. */
  102519. detachControl(element: Nullable<HTMLElement>): void;
  102520. /**
  102521. * Update the current camera state depending on the inputs that have been used this frame.
  102522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102523. */
  102524. checkInputs(): void;
  102525. /**
  102526. * Gets the class name of the current intput.
  102527. * @returns the class name
  102528. */
  102529. getClassName(): string;
  102530. /**
  102531. * Get the friendly name associated with the input class.
  102532. * @returns the input friendly name
  102533. */
  102534. getSimpleName(): string;
  102535. }
  102536. }
  102537. declare module BABYLON {
  102538. /**
  102539. * Manage the gamepad inputs to control a free camera.
  102540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102541. */
  102542. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102543. /**
  102544. * Define the camera the input is attached to.
  102545. */
  102546. camera: FreeCamera;
  102547. /**
  102548. * Define the Gamepad controlling the input
  102549. */
  102550. gamepad: Nullable<Gamepad>;
  102551. /**
  102552. * Defines the gamepad rotation sensiblity.
  102553. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102554. */
  102555. gamepadAngularSensibility: number;
  102556. /**
  102557. * Defines the gamepad move sensiblity.
  102558. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102559. */
  102560. gamepadMoveSensibility: number;
  102561. private _onGamepadConnectedObserver;
  102562. private _onGamepadDisconnectedObserver;
  102563. private _cameraTransform;
  102564. private _deltaTransform;
  102565. private _vector3;
  102566. private _vector2;
  102567. /**
  102568. * Attach the input controls to a specific dom element to get the input from.
  102569. * @param element Defines the element the controls should be listened from
  102570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102571. */
  102572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102573. /**
  102574. * Detach the current controls from the specified dom element.
  102575. * @param element Defines the element to stop listening the inputs from
  102576. */
  102577. detachControl(element: Nullable<HTMLElement>): void;
  102578. /**
  102579. * Update the current camera state depending on the inputs that have been used this frame.
  102580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102581. */
  102582. checkInputs(): void;
  102583. /**
  102584. * Gets the class name of the current intput.
  102585. * @returns the class name
  102586. */
  102587. getClassName(): string;
  102588. /**
  102589. * Get the friendly name associated with the input class.
  102590. * @returns the input friendly name
  102591. */
  102592. getSimpleName(): string;
  102593. }
  102594. }
  102595. declare module BABYLON {
  102596. /**
  102597. * Defines the potential axis of a Joystick
  102598. */
  102599. export enum JoystickAxis {
  102600. /** X axis */
  102601. X = 0,
  102602. /** Y axis */
  102603. Y = 1,
  102604. /** Z axis */
  102605. Z = 2
  102606. }
  102607. /**
  102608. * Class used to define virtual joystick (used in touch mode)
  102609. */
  102610. export class VirtualJoystick {
  102611. /**
  102612. * Gets or sets a boolean indicating that left and right values must be inverted
  102613. */
  102614. reverseLeftRight: boolean;
  102615. /**
  102616. * Gets or sets a boolean indicating that up and down values must be inverted
  102617. */
  102618. reverseUpDown: boolean;
  102619. /**
  102620. * Gets the offset value for the position (ie. the change of the position value)
  102621. */
  102622. deltaPosition: Vector3;
  102623. /**
  102624. * Gets a boolean indicating if the virtual joystick was pressed
  102625. */
  102626. pressed: boolean;
  102627. /**
  102628. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102629. */
  102630. static Canvas: Nullable<HTMLCanvasElement>;
  102631. private static _globalJoystickIndex;
  102632. private static vjCanvasContext;
  102633. private static vjCanvasWidth;
  102634. private static vjCanvasHeight;
  102635. private static halfWidth;
  102636. private _action;
  102637. private _axisTargetedByLeftAndRight;
  102638. private _axisTargetedByUpAndDown;
  102639. private _joystickSensibility;
  102640. private _inversedSensibility;
  102641. private _joystickPointerID;
  102642. private _joystickColor;
  102643. private _joystickPointerPos;
  102644. private _joystickPreviousPointerPos;
  102645. private _joystickPointerStartPos;
  102646. private _deltaJoystickVector;
  102647. private _leftJoystick;
  102648. private _touches;
  102649. private _onPointerDownHandlerRef;
  102650. private _onPointerMoveHandlerRef;
  102651. private _onPointerUpHandlerRef;
  102652. private _onResize;
  102653. /**
  102654. * Creates a new virtual joystick
  102655. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102656. */
  102657. constructor(leftJoystick?: boolean);
  102658. /**
  102659. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102660. * @param newJoystickSensibility defines the new sensibility
  102661. */
  102662. setJoystickSensibility(newJoystickSensibility: number): void;
  102663. private _onPointerDown;
  102664. private _onPointerMove;
  102665. private _onPointerUp;
  102666. /**
  102667. * Change the color of the virtual joystick
  102668. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102669. */
  102670. setJoystickColor(newColor: string): void;
  102671. /**
  102672. * Defines a callback to call when the joystick is touched
  102673. * @param action defines the callback
  102674. */
  102675. setActionOnTouch(action: () => any): void;
  102676. /**
  102677. * Defines which axis you'd like to control for left & right
  102678. * @param axis defines the axis to use
  102679. */
  102680. setAxisForLeftRight(axis: JoystickAxis): void;
  102681. /**
  102682. * Defines which axis you'd like to control for up & down
  102683. * @param axis defines the axis to use
  102684. */
  102685. setAxisForUpDown(axis: JoystickAxis): void;
  102686. private _drawVirtualJoystick;
  102687. /**
  102688. * Release internal HTML canvas
  102689. */
  102690. releaseCanvas(): void;
  102691. }
  102692. }
  102693. declare module BABYLON {
  102694. interface FreeCameraInputsManager {
  102695. /**
  102696. * Add virtual joystick input support to the input manager.
  102697. * @returns the current input manager
  102698. */
  102699. addVirtualJoystick(): FreeCameraInputsManager;
  102700. }
  102701. /**
  102702. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102704. */
  102705. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102706. /**
  102707. * Defines the camera the input is attached to.
  102708. */
  102709. camera: FreeCamera;
  102710. private _leftjoystick;
  102711. private _rightjoystick;
  102712. /**
  102713. * Gets the left stick of the virtual joystick.
  102714. * @returns The virtual Joystick
  102715. */
  102716. getLeftJoystick(): VirtualJoystick;
  102717. /**
  102718. * Gets the right stick of the virtual joystick.
  102719. * @returns The virtual Joystick
  102720. */
  102721. getRightJoystick(): VirtualJoystick;
  102722. /**
  102723. * Update the current camera state depending on the inputs that have been used this frame.
  102724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102725. */
  102726. checkInputs(): void;
  102727. /**
  102728. * Attach the input controls to a specific dom element to get the input from.
  102729. * @param element Defines the element the controls should be listened from
  102730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102731. */
  102732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102733. /**
  102734. * Detach the current controls from the specified dom element.
  102735. * @param element Defines the element to stop listening the inputs from
  102736. */
  102737. detachControl(element: Nullable<HTMLElement>): void;
  102738. /**
  102739. * Gets the class name of the current intput.
  102740. * @returns the class name
  102741. */
  102742. getClassName(): string;
  102743. /**
  102744. * Get the friendly name associated with the input class.
  102745. * @returns the input friendly name
  102746. */
  102747. getSimpleName(): string;
  102748. }
  102749. }
  102750. declare module BABYLON {
  102751. /**
  102752. * This represents a FPS type of camera controlled by touch.
  102753. * This is like a universal camera minus the Gamepad controls.
  102754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102755. */
  102756. export class TouchCamera extends FreeCamera {
  102757. /**
  102758. * Defines the touch sensibility for rotation.
  102759. * The higher the faster.
  102760. */
  102761. touchAngularSensibility: number;
  102762. /**
  102763. * Defines the touch sensibility for move.
  102764. * The higher the faster.
  102765. */
  102766. touchMoveSensibility: number;
  102767. /**
  102768. * Instantiates a new touch camera.
  102769. * This represents a FPS type of camera controlled by touch.
  102770. * This is like a universal camera minus the Gamepad controls.
  102771. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102772. * @param name Define the name of the camera in the scene
  102773. * @param position Define the start position of the camera in the scene
  102774. * @param scene Define the scene the camera belongs to
  102775. */
  102776. constructor(name: string, position: Vector3, scene: Scene);
  102777. /**
  102778. * Gets the current object class name.
  102779. * @return the class name
  102780. */
  102781. getClassName(): string;
  102782. /** @hidden */
  102783. _setupInputs(): void;
  102784. }
  102785. }
  102786. declare module BABYLON {
  102787. /**
  102788. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102789. * being tilted forward or back and left or right.
  102790. */
  102791. export class DeviceOrientationCamera extends FreeCamera {
  102792. private _initialQuaternion;
  102793. private _quaternionCache;
  102794. private _tmpDragQuaternion;
  102795. private _disablePointerInputWhenUsingDeviceOrientation;
  102796. /**
  102797. * Creates a new device orientation camera
  102798. * @param name The name of the camera
  102799. * @param position The start position camera
  102800. * @param scene The scene the camera belongs to
  102801. */
  102802. constructor(name: string, position: Vector3, scene: Scene);
  102803. /**
  102804. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  102805. */
  102806. disablePointerInputWhenUsingDeviceOrientation: boolean;
  102807. private _dragFactor;
  102808. /**
  102809. * Enabled turning on the y axis when the orientation sensor is active
  102810. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102811. */
  102812. enableHorizontalDragging(dragFactor?: number): void;
  102813. /**
  102814. * Gets the current instance class name ("DeviceOrientationCamera").
  102815. * This helps avoiding instanceof at run time.
  102816. * @returns the class name
  102817. */
  102818. getClassName(): string;
  102819. /**
  102820. * @hidden
  102821. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102822. */
  102823. _checkInputs(): void;
  102824. /**
  102825. * Reset the camera to its default orientation on the specified axis only.
  102826. * @param axis The axis to reset
  102827. */
  102828. resetToCurrentRotation(axis?: Axis): void;
  102829. }
  102830. }
  102831. declare module BABYLON {
  102832. /**
  102833. * Defines supported buttons for XBox360 compatible gamepads
  102834. */
  102835. export enum Xbox360Button {
  102836. /** A */
  102837. A = 0,
  102838. /** B */
  102839. B = 1,
  102840. /** X */
  102841. X = 2,
  102842. /** Y */
  102843. Y = 3,
  102844. /** Start */
  102845. Start = 4,
  102846. /** Back */
  102847. Back = 5,
  102848. /** Left button */
  102849. LB = 6,
  102850. /** Right button */
  102851. RB = 7,
  102852. /** Left stick */
  102853. LeftStick = 8,
  102854. /** Right stick */
  102855. RightStick = 9
  102856. }
  102857. /** Defines values for XBox360 DPad */
  102858. export enum Xbox360Dpad {
  102859. /** Up */
  102860. Up = 0,
  102861. /** Down */
  102862. Down = 1,
  102863. /** Left */
  102864. Left = 2,
  102865. /** Right */
  102866. Right = 3
  102867. }
  102868. /**
  102869. * Defines a XBox360 gamepad
  102870. */
  102871. export class Xbox360Pad extends Gamepad {
  102872. private _leftTrigger;
  102873. private _rightTrigger;
  102874. private _onlefttriggerchanged;
  102875. private _onrighttriggerchanged;
  102876. private _onbuttondown;
  102877. private _onbuttonup;
  102878. private _ondpaddown;
  102879. private _ondpadup;
  102880. /** Observable raised when a button is pressed */
  102881. onButtonDownObservable: Observable<Xbox360Button>;
  102882. /** Observable raised when a button is released */
  102883. onButtonUpObservable: Observable<Xbox360Button>;
  102884. /** Observable raised when a pad is pressed */
  102885. onPadDownObservable: Observable<Xbox360Dpad>;
  102886. /** Observable raised when a pad is released */
  102887. onPadUpObservable: Observable<Xbox360Dpad>;
  102888. private _buttonA;
  102889. private _buttonB;
  102890. private _buttonX;
  102891. private _buttonY;
  102892. private _buttonBack;
  102893. private _buttonStart;
  102894. private _buttonLB;
  102895. private _buttonRB;
  102896. private _buttonLeftStick;
  102897. private _buttonRightStick;
  102898. private _dPadUp;
  102899. private _dPadDown;
  102900. private _dPadLeft;
  102901. private _dPadRight;
  102902. private _isXboxOnePad;
  102903. /**
  102904. * Creates a new XBox360 gamepad object
  102905. * @param id defines the id of this gamepad
  102906. * @param index defines its index
  102907. * @param gamepad defines the internal HTML gamepad object
  102908. * @param xboxOne defines if it is a XBox One gamepad
  102909. */
  102910. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102911. /**
  102912. * Defines the callback to call when left trigger is pressed
  102913. * @param callback defines the callback to use
  102914. */
  102915. onlefttriggerchanged(callback: (value: number) => void): void;
  102916. /**
  102917. * Defines the callback to call when right trigger is pressed
  102918. * @param callback defines the callback to use
  102919. */
  102920. onrighttriggerchanged(callback: (value: number) => void): void;
  102921. /**
  102922. * Gets the left trigger value
  102923. */
  102924. /**
  102925. * Sets the left trigger value
  102926. */
  102927. leftTrigger: number;
  102928. /**
  102929. * Gets the right trigger value
  102930. */
  102931. /**
  102932. * Sets the right trigger value
  102933. */
  102934. rightTrigger: number;
  102935. /**
  102936. * Defines the callback to call when a button is pressed
  102937. * @param callback defines the callback to use
  102938. */
  102939. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102940. /**
  102941. * Defines the callback to call when a button is released
  102942. * @param callback defines the callback to use
  102943. */
  102944. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102945. /**
  102946. * Defines the callback to call when a pad is pressed
  102947. * @param callback defines the callback to use
  102948. */
  102949. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102950. /**
  102951. * Defines the callback to call when a pad is released
  102952. * @param callback defines the callback to use
  102953. */
  102954. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102955. private _setButtonValue;
  102956. private _setDPadValue;
  102957. /**
  102958. * Gets the value of the `A` button
  102959. */
  102960. /**
  102961. * Sets the value of the `A` button
  102962. */
  102963. buttonA: number;
  102964. /**
  102965. * Gets the value of the `B` button
  102966. */
  102967. /**
  102968. * Sets the value of the `B` button
  102969. */
  102970. buttonB: number;
  102971. /**
  102972. * Gets the value of the `X` button
  102973. */
  102974. /**
  102975. * Sets the value of the `X` button
  102976. */
  102977. buttonX: number;
  102978. /**
  102979. * Gets the value of the `Y` button
  102980. */
  102981. /**
  102982. * Sets the value of the `Y` button
  102983. */
  102984. buttonY: number;
  102985. /**
  102986. * Gets the value of the `Start` button
  102987. */
  102988. /**
  102989. * Sets the value of the `Start` button
  102990. */
  102991. buttonStart: number;
  102992. /**
  102993. * Gets the value of the `Back` button
  102994. */
  102995. /**
  102996. * Sets the value of the `Back` button
  102997. */
  102998. buttonBack: number;
  102999. /**
  103000. * Gets the value of the `Left` button
  103001. */
  103002. /**
  103003. * Sets the value of the `Left` button
  103004. */
  103005. buttonLB: number;
  103006. /**
  103007. * Gets the value of the `Right` button
  103008. */
  103009. /**
  103010. * Sets the value of the `Right` button
  103011. */
  103012. buttonRB: number;
  103013. /**
  103014. * Gets the value of the Left joystick
  103015. */
  103016. /**
  103017. * Sets the value of the Left joystick
  103018. */
  103019. buttonLeftStick: number;
  103020. /**
  103021. * Gets the value of the Right joystick
  103022. */
  103023. /**
  103024. * Sets the value of the Right joystick
  103025. */
  103026. buttonRightStick: number;
  103027. /**
  103028. * Gets the value of D-pad up
  103029. */
  103030. /**
  103031. * Sets the value of D-pad up
  103032. */
  103033. dPadUp: number;
  103034. /**
  103035. * Gets the value of D-pad down
  103036. */
  103037. /**
  103038. * Sets the value of D-pad down
  103039. */
  103040. dPadDown: number;
  103041. /**
  103042. * Gets the value of D-pad left
  103043. */
  103044. /**
  103045. * Sets the value of D-pad left
  103046. */
  103047. dPadLeft: number;
  103048. /**
  103049. * Gets the value of D-pad right
  103050. */
  103051. /**
  103052. * Sets the value of D-pad right
  103053. */
  103054. dPadRight: number;
  103055. /**
  103056. * Force the gamepad to synchronize with device values
  103057. */
  103058. update(): void;
  103059. /**
  103060. * Disposes the gamepad
  103061. */
  103062. dispose(): void;
  103063. }
  103064. }
  103065. declare module BABYLON {
  103066. /**
  103067. * Defines supported buttons for DualShock compatible gamepads
  103068. */
  103069. export enum DualShockButton {
  103070. /** Cross */
  103071. Cross = 0,
  103072. /** Circle */
  103073. Circle = 1,
  103074. /** Square */
  103075. Square = 2,
  103076. /** Triangle */
  103077. Triangle = 3,
  103078. /** Options */
  103079. Options = 4,
  103080. /** Share */
  103081. Share = 5,
  103082. /** L1 */
  103083. L1 = 6,
  103084. /** R1 */
  103085. R1 = 7,
  103086. /** Left stick */
  103087. LeftStick = 8,
  103088. /** Right stick */
  103089. RightStick = 9
  103090. }
  103091. /** Defines values for DualShock DPad */
  103092. export enum DualShockDpad {
  103093. /** Up */
  103094. Up = 0,
  103095. /** Down */
  103096. Down = 1,
  103097. /** Left */
  103098. Left = 2,
  103099. /** Right */
  103100. Right = 3
  103101. }
  103102. /**
  103103. * Defines a DualShock gamepad
  103104. */
  103105. export class DualShockPad extends Gamepad {
  103106. private _leftTrigger;
  103107. private _rightTrigger;
  103108. private _onlefttriggerchanged;
  103109. private _onrighttriggerchanged;
  103110. private _onbuttondown;
  103111. private _onbuttonup;
  103112. private _ondpaddown;
  103113. private _ondpadup;
  103114. /** Observable raised when a button is pressed */
  103115. onButtonDownObservable: Observable<DualShockButton>;
  103116. /** Observable raised when a button is released */
  103117. onButtonUpObservable: Observable<DualShockButton>;
  103118. /** Observable raised when a pad is pressed */
  103119. onPadDownObservable: Observable<DualShockDpad>;
  103120. /** Observable raised when a pad is released */
  103121. onPadUpObservable: Observable<DualShockDpad>;
  103122. private _buttonCross;
  103123. private _buttonCircle;
  103124. private _buttonSquare;
  103125. private _buttonTriangle;
  103126. private _buttonShare;
  103127. private _buttonOptions;
  103128. private _buttonL1;
  103129. private _buttonR1;
  103130. private _buttonLeftStick;
  103131. private _buttonRightStick;
  103132. private _dPadUp;
  103133. private _dPadDown;
  103134. private _dPadLeft;
  103135. private _dPadRight;
  103136. /**
  103137. * Creates a new DualShock gamepad object
  103138. * @param id defines the id of this gamepad
  103139. * @param index defines its index
  103140. * @param gamepad defines the internal HTML gamepad object
  103141. */
  103142. constructor(id: string, index: number, gamepad: any);
  103143. /**
  103144. * Defines the callback to call when left trigger is pressed
  103145. * @param callback defines the callback to use
  103146. */
  103147. onlefttriggerchanged(callback: (value: number) => void): void;
  103148. /**
  103149. * Defines the callback to call when right trigger is pressed
  103150. * @param callback defines the callback to use
  103151. */
  103152. onrighttriggerchanged(callback: (value: number) => void): void;
  103153. /**
  103154. * Gets the left trigger value
  103155. */
  103156. /**
  103157. * Sets the left trigger value
  103158. */
  103159. leftTrigger: number;
  103160. /**
  103161. * Gets the right trigger value
  103162. */
  103163. /**
  103164. * Sets the right trigger value
  103165. */
  103166. rightTrigger: number;
  103167. /**
  103168. * Defines the callback to call when a button is pressed
  103169. * @param callback defines the callback to use
  103170. */
  103171. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103172. /**
  103173. * Defines the callback to call when a button is released
  103174. * @param callback defines the callback to use
  103175. */
  103176. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103177. /**
  103178. * Defines the callback to call when a pad is pressed
  103179. * @param callback defines the callback to use
  103180. */
  103181. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103182. /**
  103183. * Defines the callback to call when a pad is released
  103184. * @param callback defines the callback to use
  103185. */
  103186. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103187. private _setButtonValue;
  103188. private _setDPadValue;
  103189. /**
  103190. * Gets the value of the `Cross` button
  103191. */
  103192. /**
  103193. * Sets the value of the `Cross` button
  103194. */
  103195. buttonCross: number;
  103196. /**
  103197. * Gets the value of the `Circle` button
  103198. */
  103199. /**
  103200. * Sets the value of the `Circle` button
  103201. */
  103202. buttonCircle: number;
  103203. /**
  103204. * Gets the value of the `Square` button
  103205. */
  103206. /**
  103207. * Sets the value of the `Square` button
  103208. */
  103209. buttonSquare: number;
  103210. /**
  103211. * Gets the value of the `Triangle` button
  103212. */
  103213. /**
  103214. * Sets the value of the `Triangle` button
  103215. */
  103216. buttonTriangle: number;
  103217. /**
  103218. * Gets the value of the `Options` button
  103219. */
  103220. /**
  103221. * Sets the value of the `Options` button
  103222. */
  103223. buttonOptions: number;
  103224. /**
  103225. * Gets the value of the `Share` button
  103226. */
  103227. /**
  103228. * Sets the value of the `Share` button
  103229. */
  103230. buttonShare: number;
  103231. /**
  103232. * Gets the value of the `L1` button
  103233. */
  103234. /**
  103235. * Sets the value of the `L1` button
  103236. */
  103237. buttonL1: number;
  103238. /**
  103239. * Gets the value of the `R1` button
  103240. */
  103241. /**
  103242. * Sets the value of the `R1` button
  103243. */
  103244. buttonR1: number;
  103245. /**
  103246. * Gets the value of the Left joystick
  103247. */
  103248. /**
  103249. * Sets the value of the Left joystick
  103250. */
  103251. buttonLeftStick: number;
  103252. /**
  103253. * Gets the value of the Right joystick
  103254. */
  103255. /**
  103256. * Sets the value of the Right joystick
  103257. */
  103258. buttonRightStick: number;
  103259. /**
  103260. * Gets the value of D-pad up
  103261. */
  103262. /**
  103263. * Sets the value of D-pad up
  103264. */
  103265. dPadUp: number;
  103266. /**
  103267. * Gets the value of D-pad down
  103268. */
  103269. /**
  103270. * Sets the value of D-pad down
  103271. */
  103272. dPadDown: number;
  103273. /**
  103274. * Gets the value of D-pad left
  103275. */
  103276. /**
  103277. * Sets the value of D-pad left
  103278. */
  103279. dPadLeft: number;
  103280. /**
  103281. * Gets the value of D-pad right
  103282. */
  103283. /**
  103284. * Sets the value of D-pad right
  103285. */
  103286. dPadRight: number;
  103287. /**
  103288. * Force the gamepad to synchronize with device values
  103289. */
  103290. update(): void;
  103291. /**
  103292. * Disposes the gamepad
  103293. */
  103294. dispose(): void;
  103295. }
  103296. }
  103297. declare module BABYLON {
  103298. /**
  103299. * Manager for handling gamepads
  103300. */
  103301. export class GamepadManager {
  103302. private _scene?;
  103303. private _babylonGamepads;
  103304. private _oneGamepadConnected;
  103305. /** @hidden */
  103306. _isMonitoring: boolean;
  103307. private _gamepadEventSupported;
  103308. private _gamepadSupport;
  103309. /**
  103310. * observable to be triggered when the gamepad controller has been connected
  103311. */
  103312. onGamepadConnectedObservable: Observable<Gamepad>;
  103313. /**
  103314. * observable to be triggered when the gamepad controller has been disconnected
  103315. */
  103316. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103317. private _onGamepadConnectedEvent;
  103318. private _onGamepadDisconnectedEvent;
  103319. /**
  103320. * Initializes the gamepad manager
  103321. * @param _scene BabylonJS scene
  103322. */
  103323. constructor(_scene?: Scene | undefined);
  103324. /**
  103325. * The gamepads in the game pad manager
  103326. */
  103327. readonly gamepads: Gamepad[];
  103328. /**
  103329. * Get the gamepad controllers based on type
  103330. * @param type The type of gamepad controller
  103331. * @returns Nullable gamepad
  103332. */
  103333. getGamepadByType(type?: number): Nullable<Gamepad>;
  103334. /**
  103335. * Disposes the gamepad manager
  103336. */
  103337. dispose(): void;
  103338. private _addNewGamepad;
  103339. private _startMonitoringGamepads;
  103340. private _stopMonitoringGamepads;
  103341. /** @hidden */
  103342. _checkGamepadsStatus(): void;
  103343. private _updateGamepadObjects;
  103344. }
  103345. }
  103346. declare module BABYLON {
  103347. interface Scene {
  103348. /** @hidden */
  103349. _gamepadManager: Nullable<GamepadManager>;
  103350. /**
  103351. * Gets the gamepad manager associated with the scene
  103352. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103353. */
  103354. gamepadManager: GamepadManager;
  103355. }
  103356. /**
  103357. * Interface representing a free camera inputs manager
  103358. */
  103359. interface FreeCameraInputsManager {
  103360. /**
  103361. * Adds gamepad input support to the FreeCameraInputsManager.
  103362. * @returns the FreeCameraInputsManager
  103363. */
  103364. addGamepad(): FreeCameraInputsManager;
  103365. }
  103366. /**
  103367. * Interface representing an arc rotate camera inputs manager
  103368. */
  103369. interface ArcRotateCameraInputsManager {
  103370. /**
  103371. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103372. * @returns the camera inputs manager
  103373. */
  103374. addGamepad(): ArcRotateCameraInputsManager;
  103375. }
  103376. /**
  103377. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103378. */
  103379. export class GamepadSystemSceneComponent implements ISceneComponent {
  103380. /**
  103381. * The component name helpfull to identify the component in the list of scene components.
  103382. */
  103383. readonly name: string;
  103384. /**
  103385. * The scene the component belongs to.
  103386. */
  103387. scene: Scene;
  103388. /**
  103389. * Creates a new instance of the component for the given scene
  103390. * @param scene Defines the scene to register the component in
  103391. */
  103392. constructor(scene: Scene);
  103393. /**
  103394. * Registers the component in a given scene
  103395. */
  103396. register(): void;
  103397. /**
  103398. * Rebuilds the elements related to this component in case of
  103399. * context lost for instance.
  103400. */
  103401. rebuild(): void;
  103402. /**
  103403. * Disposes the component and the associated ressources
  103404. */
  103405. dispose(): void;
  103406. private _beforeCameraUpdate;
  103407. }
  103408. }
  103409. declare module BABYLON {
  103410. /**
  103411. * 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,
  103412. * which still works and will still be found in many Playgrounds.
  103413. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103414. */
  103415. export class UniversalCamera extends TouchCamera {
  103416. /**
  103417. * Defines the gamepad rotation sensiblity.
  103418. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103419. */
  103420. gamepadAngularSensibility: number;
  103421. /**
  103422. * Defines the gamepad move sensiblity.
  103423. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103424. */
  103425. gamepadMoveSensibility: number;
  103426. /**
  103427. * 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,
  103428. * which still works and will still be found in many Playgrounds.
  103429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103430. * @param name Define the name of the camera in the scene
  103431. * @param position Define the start position of the camera in the scene
  103432. * @param scene Define the scene the camera belongs to
  103433. */
  103434. constructor(name: string, position: Vector3, scene: Scene);
  103435. /**
  103436. * Gets the current object class name.
  103437. * @return the class name
  103438. */
  103439. getClassName(): string;
  103440. }
  103441. }
  103442. declare module BABYLON {
  103443. /**
  103444. * This represents a FPS type of camera. This is only here for back compat purpose.
  103445. * Please use the UniversalCamera instead as both are identical.
  103446. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103447. */
  103448. export class GamepadCamera extends UniversalCamera {
  103449. /**
  103450. * Instantiates a new Gamepad Camera
  103451. * This represents a FPS type of camera. This is only here for back compat purpose.
  103452. * Please use the UniversalCamera instead as both are identical.
  103453. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103454. * @param name Define the name of the camera in the scene
  103455. * @param position Define the start position of the camera in the scene
  103456. * @param scene Define the scene the camera belongs to
  103457. */
  103458. constructor(name: string, position: Vector3, scene: Scene);
  103459. /**
  103460. * Gets the current object class name.
  103461. * @return the class name
  103462. */
  103463. getClassName(): string;
  103464. }
  103465. }
  103466. declare module BABYLON {
  103467. /** @hidden */
  103468. export var passPixelShader: {
  103469. name: string;
  103470. shader: string;
  103471. };
  103472. }
  103473. declare module BABYLON {
  103474. /** @hidden */
  103475. export var passCubePixelShader: {
  103476. name: string;
  103477. shader: string;
  103478. };
  103479. }
  103480. declare module BABYLON {
  103481. /**
  103482. * PassPostProcess which produces an output the same as it's input
  103483. */
  103484. export class PassPostProcess extends PostProcess {
  103485. /**
  103486. * Creates the PassPostProcess
  103487. * @param name The name of the effect.
  103488. * @param options The required width/height ratio to downsize to before computing the render pass.
  103489. * @param camera The camera to apply the render pass to.
  103490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103491. * @param engine The engine which the post process will be applied. (default: current engine)
  103492. * @param reusable If the post process can be reused on the same frame. (default: false)
  103493. * @param textureType The type of texture to be used when performing the post processing.
  103494. * @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)
  103495. */
  103496. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103497. }
  103498. /**
  103499. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103500. */
  103501. export class PassCubePostProcess extends PostProcess {
  103502. private _face;
  103503. /**
  103504. * Gets or sets the cube face to display.
  103505. * * 0 is +X
  103506. * * 1 is -X
  103507. * * 2 is +Y
  103508. * * 3 is -Y
  103509. * * 4 is +Z
  103510. * * 5 is -Z
  103511. */
  103512. face: number;
  103513. /**
  103514. * Creates the PassCubePostProcess
  103515. * @param name The name of the effect.
  103516. * @param options The required width/height ratio to downsize to before computing the render pass.
  103517. * @param camera The camera to apply the render pass to.
  103518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103519. * @param engine The engine which the post process will be applied. (default: current engine)
  103520. * @param reusable If the post process can be reused on the same frame. (default: false)
  103521. * @param textureType The type of texture to be used when performing the post processing.
  103522. * @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)
  103523. */
  103524. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103525. }
  103526. }
  103527. declare module BABYLON {
  103528. /** @hidden */
  103529. export var anaglyphPixelShader: {
  103530. name: string;
  103531. shader: string;
  103532. };
  103533. }
  103534. declare module BABYLON {
  103535. /**
  103536. * Postprocess used to generate anaglyphic rendering
  103537. */
  103538. export class AnaglyphPostProcess extends PostProcess {
  103539. private _passedProcess;
  103540. /**
  103541. * Creates a new AnaglyphPostProcess
  103542. * @param name defines postprocess name
  103543. * @param options defines creation options or target ratio scale
  103544. * @param rigCameras defines cameras using this postprocess
  103545. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103546. * @param engine defines hosting engine
  103547. * @param reusable defines if the postprocess will be reused multiple times per frame
  103548. */
  103549. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103550. }
  103551. }
  103552. declare module BABYLON {
  103553. /**
  103554. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103555. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103556. */
  103557. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103558. /**
  103559. * Creates a new AnaglyphArcRotateCamera
  103560. * @param name defines camera name
  103561. * @param alpha defines alpha angle (in radians)
  103562. * @param beta defines beta angle (in radians)
  103563. * @param radius defines radius
  103564. * @param target defines camera target
  103565. * @param interaxialDistance defines distance between each color axis
  103566. * @param scene defines the hosting scene
  103567. */
  103568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103569. /**
  103570. * Gets camera class name
  103571. * @returns AnaglyphArcRotateCamera
  103572. */
  103573. getClassName(): string;
  103574. }
  103575. }
  103576. declare module BABYLON {
  103577. /**
  103578. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103579. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103580. */
  103581. export class AnaglyphFreeCamera extends FreeCamera {
  103582. /**
  103583. * Creates a new AnaglyphFreeCamera
  103584. * @param name defines camera name
  103585. * @param position defines initial position
  103586. * @param interaxialDistance defines distance between each color axis
  103587. * @param scene defines the hosting scene
  103588. */
  103589. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103590. /**
  103591. * Gets camera class name
  103592. * @returns AnaglyphFreeCamera
  103593. */
  103594. getClassName(): string;
  103595. }
  103596. }
  103597. declare module BABYLON {
  103598. /**
  103599. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103600. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103601. */
  103602. export class AnaglyphGamepadCamera extends GamepadCamera {
  103603. /**
  103604. * Creates a new AnaglyphGamepadCamera
  103605. * @param name defines camera name
  103606. * @param position defines initial position
  103607. * @param interaxialDistance defines distance between each color axis
  103608. * @param scene defines the hosting scene
  103609. */
  103610. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103611. /**
  103612. * Gets camera class name
  103613. * @returns AnaglyphGamepadCamera
  103614. */
  103615. getClassName(): string;
  103616. }
  103617. }
  103618. declare module BABYLON {
  103619. /**
  103620. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103621. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103622. */
  103623. export class AnaglyphUniversalCamera extends UniversalCamera {
  103624. /**
  103625. * Creates a new AnaglyphUniversalCamera
  103626. * @param name defines camera name
  103627. * @param position defines initial position
  103628. * @param interaxialDistance defines distance between each color axis
  103629. * @param scene defines the hosting scene
  103630. */
  103631. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103632. /**
  103633. * Gets camera class name
  103634. * @returns AnaglyphUniversalCamera
  103635. */
  103636. getClassName(): string;
  103637. }
  103638. }
  103639. declare module BABYLON {
  103640. /** @hidden */
  103641. export var stereoscopicInterlacePixelShader: {
  103642. name: string;
  103643. shader: string;
  103644. };
  103645. }
  103646. declare module BABYLON {
  103647. /**
  103648. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103649. */
  103650. export class StereoscopicInterlacePostProcess extends PostProcess {
  103651. private _stepSize;
  103652. private _passedProcess;
  103653. /**
  103654. * Initializes a StereoscopicInterlacePostProcess
  103655. * @param name The name of the effect.
  103656. * @param rigCameras The rig cameras to be appled to the post process
  103657. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103659. * @param engine The engine which the post process will be applied. (default: current engine)
  103660. * @param reusable If the post process can be reused on the same frame. (default: false)
  103661. */
  103662. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103663. }
  103664. }
  103665. declare module BABYLON {
  103666. /**
  103667. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103668. * @see http://doc.babylonjs.com/features/cameras
  103669. */
  103670. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103671. /**
  103672. * Creates a new StereoscopicArcRotateCamera
  103673. * @param name defines camera name
  103674. * @param alpha defines alpha angle (in radians)
  103675. * @param beta defines beta angle (in radians)
  103676. * @param radius defines radius
  103677. * @param target defines camera target
  103678. * @param interaxialDistance defines distance between each color axis
  103679. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103680. * @param scene defines the hosting scene
  103681. */
  103682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103683. /**
  103684. * Gets camera class name
  103685. * @returns StereoscopicArcRotateCamera
  103686. */
  103687. getClassName(): string;
  103688. }
  103689. }
  103690. declare module BABYLON {
  103691. /**
  103692. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103693. * @see http://doc.babylonjs.com/features/cameras
  103694. */
  103695. export class StereoscopicFreeCamera extends FreeCamera {
  103696. /**
  103697. * Creates a new StereoscopicFreeCamera
  103698. * @param name defines camera name
  103699. * @param position defines initial position
  103700. * @param interaxialDistance defines distance between each color axis
  103701. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103702. * @param scene defines the hosting scene
  103703. */
  103704. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103705. /**
  103706. * Gets camera class name
  103707. * @returns StereoscopicFreeCamera
  103708. */
  103709. getClassName(): string;
  103710. }
  103711. }
  103712. declare module BABYLON {
  103713. /**
  103714. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103715. * @see http://doc.babylonjs.com/features/cameras
  103716. */
  103717. export class StereoscopicGamepadCamera extends GamepadCamera {
  103718. /**
  103719. * Creates a new StereoscopicGamepadCamera
  103720. * @param name defines camera name
  103721. * @param position defines initial position
  103722. * @param interaxialDistance defines distance between each color axis
  103723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103724. * @param scene defines the hosting scene
  103725. */
  103726. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103727. /**
  103728. * Gets camera class name
  103729. * @returns StereoscopicGamepadCamera
  103730. */
  103731. getClassName(): string;
  103732. }
  103733. }
  103734. declare module BABYLON {
  103735. /**
  103736. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103737. * @see http://doc.babylonjs.com/features/cameras
  103738. */
  103739. export class StereoscopicUniversalCamera extends UniversalCamera {
  103740. /**
  103741. * Creates a new StereoscopicUniversalCamera
  103742. * @param name defines camera name
  103743. * @param position defines initial position
  103744. * @param interaxialDistance defines distance between each color axis
  103745. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103746. * @param scene defines the hosting scene
  103747. */
  103748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103749. /**
  103750. * Gets camera class name
  103751. * @returns StereoscopicUniversalCamera
  103752. */
  103753. getClassName(): string;
  103754. }
  103755. }
  103756. declare module BABYLON {
  103757. /**
  103758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103759. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103760. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103761. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103762. */
  103763. export class VirtualJoysticksCamera extends FreeCamera {
  103764. /**
  103765. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103766. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103767. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103768. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103769. * @param name Define the name of the camera in the scene
  103770. * @param position Define the start position of the camera in the scene
  103771. * @param scene Define the scene the camera belongs to
  103772. */
  103773. constructor(name: string, position: Vector3, scene: Scene);
  103774. /**
  103775. * Gets the current object class name.
  103776. * @return the class name
  103777. */
  103778. getClassName(): string;
  103779. }
  103780. }
  103781. declare module BABYLON {
  103782. /**
  103783. * This represents all the required metrics to create a VR camera.
  103784. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103785. */
  103786. export class VRCameraMetrics {
  103787. /**
  103788. * Define the horizontal resolution off the screen.
  103789. */
  103790. hResolution: number;
  103791. /**
  103792. * Define the vertical resolution off the screen.
  103793. */
  103794. vResolution: number;
  103795. /**
  103796. * Define the horizontal screen size.
  103797. */
  103798. hScreenSize: number;
  103799. /**
  103800. * Define the vertical screen size.
  103801. */
  103802. vScreenSize: number;
  103803. /**
  103804. * Define the vertical screen center position.
  103805. */
  103806. vScreenCenter: number;
  103807. /**
  103808. * Define the distance of the eyes to the screen.
  103809. */
  103810. eyeToScreenDistance: number;
  103811. /**
  103812. * Define the distance between both lenses
  103813. */
  103814. lensSeparationDistance: number;
  103815. /**
  103816. * Define the distance between both viewer's eyes.
  103817. */
  103818. interpupillaryDistance: number;
  103819. /**
  103820. * Define the distortion factor of the VR postprocess.
  103821. * Please, touch with care.
  103822. */
  103823. distortionK: number[];
  103824. /**
  103825. * Define the chromatic aberration correction factors for the VR post process.
  103826. */
  103827. chromaAbCorrection: number[];
  103828. /**
  103829. * Define the scale factor of the post process.
  103830. * The smaller the better but the slower.
  103831. */
  103832. postProcessScaleFactor: number;
  103833. /**
  103834. * Define an offset for the lens center.
  103835. */
  103836. lensCenterOffset: number;
  103837. /**
  103838. * Define if the current vr camera should compensate the distortion of the lense or not.
  103839. */
  103840. compensateDistortion: boolean;
  103841. /**
  103842. * Defines if multiview should be enabled when rendering (Default: false)
  103843. */
  103844. multiviewEnabled: boolean;
  103845. /**
  103846. * Gets the rendering aspect ratio based on the provided resolutions.
  103847. */
  103848. readonly aspectRatio: number;
  103849. /**
  103850. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103851. */
  103852. readonly aspectRatioFov: number;
  103853. /**
  103854. * @hidden
  103855. */
  103856. readonly leftHMatrix: Matrix;
  103857. /**
  103858. * @hidden
  103859. */
  103860. readonly rightHMatrix: Matrix;
  103861. /**
  103862. * @hidden
  103863. */
  103864. readonly leftPreViewMatrix: Matrix;
  103865. /**
  103866. * @hidden
  103867. */
  103868. readonly rightPreViewMatrix: Matrix;
  103869. /**
  103870. * Get the default VRMetrics based on the most generic setup.
  103871. * @returns the default vr metrics
  103872. */
  103873. static GetDefault(): VRCameraMetrics;
  103874. }
  103875. }
  103876. declare module BABYLON {
  103877. /** @hidden */
  103878. export var vrDistortionCorrectionPixelShader: {
  103879. name: string;
  103880. shader: string;
  103881. };
  103882. }
  103883. declare module BABYLON {
  103884. /**
  103885. * VRDistortionCorrectionPostProcess used for mobile VR
  103886. */
  103887. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103888. private _isRightEye;
  103889. private _distortionFactors;
  103890. private _postProcessScaleFactor;
  103891. private _lensCenterOffset;
  103892. private _scaleIn;
  103893. private _scaleFactor;
  103894. private _lensCenter;
  103895. /**
  103896. * Initializes the VRDistortionCorrectionPostProcess
  103897. * @param name The name of the effect.
  103898. * @param camera The camera to apply the render pass to.
  103899. * @param isRightEye If this is for the right eye distortion
  103900. * @param vrMetrics All the required metrics for the VR camera
  103901. */
  103902. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103903. }
  103904. }
  103905. declare module BABYLON {
  103906. /**
  103907. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103908. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103909. */
  103910. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103911. /**
  103912. * Creates a new VRDeviceOrientationArcRotateCamera
  103913. * @param name defines camera name
  103914. * @param alpha defines the camera rotation along the logitudinal axis
  103915. * @param beta defines the camera rotation along the latitudinal axis
  103916. * @param radius defines the camera distance from its target
  103917. * @param target defines the camera target
  103918. * @param scene defines the scene the camera belongs to
  103919. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103920. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103921. */
  103922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103923. /**
  103924. * Gets camera class name
  103925. * @returns VRDeviceOrientationArcRotateCamera
  103926. */
  103927. getClassName(): string;
  103928. }
  103929. }
  103930. declare module BABYLON {
  103931. /**
  103932. * Camera used to simulate VR rendering (based on FreeCamera)
  103933. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103934. */
  103935. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103936. /**
  103937. * Creates a new VRDeviceOrientationFreeCamera
  103938. * @param name defines camera name
  103939. * @param position defines the start position of the camera
  103940. * @param scene defines the scene the camera belongs to
  103941. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103942. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103943. */
  103944. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103945. /**
  103946. * Gets camera class name
  103947. * @returns VRDeviceOrientationFreeCamera
  103948. */
  103949. getClassName(): string;
  103950. }
  103951. }
  103952. declare module BABYLON {
  103953. /**
  103954. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103955. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103956. */
  103957. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103958. /**
  103959. * Creates a new VRDeviceOrientationGamepadCamera
  103960. * @param name defines camera name
  103961. * @param position defines the start position of the camera
  103962. * @param scene defines the scene the camera belongs to
  103963. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103964. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103965. */
  103966. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103967. /**
  103968. * Gets camera class name
  103969. * @returns VRDeviceOrientationGamepadCamera
  103970. */
  103971. getClassName(): string;
  103972. }
  103973. }
  103974. declare module BABYLON {
  103975. /**
  103976. * Base class of materials working in push mode in babylon JS
  103977. * @hidden
  103978. */
  103979. export class PushMaterial extends Material {
  103980. protected _activeEffect: Effect;
  103981. protected _normalMatrix: Matrix;
  103982. /**
  103983. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103984. * This means that the material can keep using a previous shader while a new one is being compiled.
  103985. * This is mostly used when shader parallel compilation is supported (true by default)
  103986. */
  103987. allowShaderHotSwapping: boolean;
  103988. constructor(name: string, scene: Scene);
  103989. getEffect(): Effect;
  103990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103991. /**
  103992. * Binds the given world matrix to the active effect
  103993. *
  103994. * @param world the matrix to bind
  103995. */
  103996. bindOnlyWorldMatrix(world: Matrix): void;
  103997. /**
  103998. * Binds the given normal matrix to the active effect
  103999. *
  104000. * @param normalMatrix the matrix to bind
  104001. */
  104002. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104003. bind(world: Matrix, mesh?: Mesh): void;
  104004. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104005. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104006. }
  104007. }
  104008. declare module BABYLON {
  104009. /**
  104010. * This groups all the flags used to control the materials channel.
  104011. */
  104012. export class MaterialFlags {
  104013. private static _DiffuseTextureEnabled;
  104014. /**
  104015. * Are diffuse textures enabled in the application.
  104016. */
  104017. static DiffuseTextureEnabled: boolean;
  104018. private static _AmbientTextureEnabled;
  104019. /**
  104020. * Are ambient textures enabled in the application.
  104021. */
  104022. static AmbientTextureEnabled: boolean;
  104023. private static _OpacityTextureEnabled;
  104024. /**
  104025. * Are opacity textures enabled in the application.
  104026. */
  104027. static OpacityTextureEnabled: boolean;
  104028. private static _ReflectionTextureEnabled;
  104029. /**
  104030. * Are reflection textures enabled in the application.
  104031. */
  104032. static ReflectionTextureEnabled: boolean;
  104033. private static _EmissiveTextureEnabled;
  104034. /**
  104035. * Are emissive textures enabled in the application.
  104036. */
  104037. static EmissiveTextureEnabled: boolean;
  104038. private static _SpecularTextureEnabled;
  104039. /**
  104040. * Are specular textures enabled in the application.
  104041. */
  104042. static SpecularTextureEnabled: boolean;
  104043. private static _BumpTextureEnabled;
  104044. /**
  104045. * Are bump textures enabled in the application.
  104046. */
  104047. static BumpTextureEnabled: boolean;
  104048. private static _LightmapTextureEnabled;
  104049. /**
  104050. * Are lightmap textures enabled in the application.
  104051. */
  104052. static LightmapTextureEnabled: boolean;
  104053. private static _RefractionTextureEnabled;
  104054. /**
  104055. * Are refraction textures enabled in the application.
  104056. */
  104057. static RefractionTextureEnabled: boolean;
  104058. private static _ColorGradingTextureEnabled;
  104059. /**
  104060. * Are color grading textures enabled in the application.
  104061. */
  104062. static ColorGradingTextureEnabled: boolean;
  104063. private static _FresnelEnabled;
  104064. /**
  104065. * Are fresnels enabled in the application.
  104066. */
  104067. static FresnelEnabled: boolean;
  104068. private static _ClearCoatTextureEnabled;
  104069. /**
  104070. * Are clear coat textures enabled in the application.
  104071. */
  104072. static ClearCoatTextureEnabled: boolean;
  104073. private static _ClearCoatBumpTextureEnabled;
  104074. /**
  104075. * Are clear coat bump textures enabled in the application.
  104076. */
  104077. static ClearCoatBumpTextureEnabled: boolean;
  104078. private static _ClearCoatTintTextureEnabled;
  104079. /**
  104080. * Are clear coat tint textures enabled in the application.
  104081. */
  104082. static ClearCoatTintTextureEnabled: boolean;
  104083. private static _SheenTextureEnabled;
  104084. /**
  104085. * Are sheen textures enabled in the application.
  104086. */
  104087. static SheenTextureEnabled: boolean;
  104088. private static _AnisotropicTextureEnabled;
  104089. /**
  104090. * Are anisotropic textures enabled in the application.
  104091. */
  104092. static AnisotropicTextureEnabled: boolean;
  104093. private static _ThicknessTextureEnabled;
  104094. /**
  104095. * Are thickness textures enabled in the application.
  104096. */
  104097. static ThicknessTextureEnabled: boolean;
  104098. }
  104099. }
  104100. declare module BABYLON {
  104101. /** @hidden */
  104102. export var defaultFragmentDeclaration: {
  104103. name: string;
  104104. shader: string;
  104105. };
  104106. }
  104107. declare module BABYLON {
  104108. /** @hidden */
  104109. export var defaultUboDeclaration: {
  104110. name: string;
  104111. shader: string;
  104112. };
  104113. }
  104114. declare module BABYLON {
  104115. /** @hidden */
  104116. export var lightFragmentDeclaration: {
  104117. name: string;
  104118. shader: string;
  104119. };
  104120. }
  104121. declare module BABYLON {
  104122. /** @hidden */
  104123. export var lightUboDeclaration: {
  104124. name: string;
  104125. shader: string;
  104126. };
  104127. }
  104128. declare module BABYLON {
  104129. /** @hidden */
  104130. export var lightsFragmentFunctions: {
  104131. name: string;
  104132. shader: string;
  104133. };
  104134. }
  104135. declare module BABYLON {
  104136. /** @hidden */
  104137. export var shadowsFragmentFunctions: {
  104138. name: string;
  104139. shader: string;
  104140. };
  104141. }
  104142. declare module BABYLON {
  104143. /** @hidden */
  104144. export var fresnelFunction: {
  104145. name: string;
  104146. shader: string;
  104147. };
  104148. }
  104149. declare module BABYLON {
  104150. /** @hidden */
  104151. export var reflectionFunction: {
  104152. name: string;
  104153. shader: string;
  104154. };
  104155. }
  104156. declare module BABYLON {
  104157. /** @hidden */
  104158. export var bumpFragmentFunctions: {
  104159. name: string;
  104160. shader: string;
  104161. };
  104162. }
  104163. declare module BABYLON {
  104164. /** @hidden */
  104165. export var logDepthDeclaration: {
  104166. name: string;
  104167. shader: string;
  104168. };
  104169. }
  104170. declare module BABYLON {
  104171. /** @hidden */
  104172. export var bumpFragment: {
  104173. name: string;
  104174. shader: string;
  104175. };
  104176. }
  104177. declare module BABYLON {
  104178. /** @hidden */
  104179. export var depthPrePass: {
  104180. name: string;
  104181. shader: string;
  104182. };
  104183. }
  104184. declare module BABYLON {
  104185. /** @hidden */
  104186. export var lightFragment: {
  104187. name: string;
  104188. shader: string;
  104189. };
  104190. }
  104191. declare module BABYLON {
  104192. /** @hidden */
  104193. export var logDepthFragment: {
  104194. name: string;
  104195. shader: string;
  104196. };
  104197. }
  104198. declare module BABYLON {
  104199. /** @hidden */
  104200. export var defaultPixelShader: {
  104201. name: string;
  104202. shader: string;
  104203. };
  104204. }
  104205. declare module BABYLON {
  104206. /** @hidden */
  104207. export var defaultVertexDeclaration: {
  104208. name: string;
  104209. shader: string;
  104210. };
  104211. }
  104212. declare module BABYLON {
  104213. /** @hidden */
  104214. export var bumpVertexDeclaration: {
  104215. name: string;
  104216. shader: string;
  104217. };
  104218. }
  104219. declare module BABYLON {
  104220. /** @hidden */
  104221. export var bumpVertex: {
  104222. name: string;
  104223. shader: string;
  104224. };
  104225. }
  104226. declare module BABYLON {
  104227. /** @hidden */
  104228. export var fogVertex: {
  104229. name: string;
  104230. shader: string;
  104231. };
  104232. }
  104233. declare module BABYLON {
  104234. /** @hidden */
  104235. export var shadowsVertex: {
  104236. name: string;
  104237. shader: string;
  104238. };
  104239. }
  104240. declare module BABYLON {
  104241. /** @hidden */
  104242. export var pointCloudVertex: {
  104243. name: string;
  104244. shader: string;
  104245. };
  104246. }
  104247. declare module BABYLON {
  104248. /** @hidden */
  104249. export var logDepthVertex: {
  104250. name: string;
  104251. shader: string;
  104252. };
  104253. }
  104254. declare module BABYLON {
  104255. /** @hidden */
  104256. export var defaultVertexShader: {
  104257. name: string;
  104258. shader: string;
  104259. };
  104260. }
  104261. declare module BABYLON {
  104262. /** @hidden */
  104263. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104264. MAINUV1: boolean;
  104265. MAINUV2: boolean;
  104266. DIFFUSE: boolean;
  104267. DIFFUSEDIRECTUV: number;
  104268. AMBIENT: boolean;
  104269. AMBIENTDIRECTUV: number;
  104270. OPACITY: boolean;
  104271. OPACITYDIRECTUV: number;
  104272. OPACITYRGB: boolean;
  104273. REFLECTION: boolean;
  104274. EMISSIVE: boolean;
  104275. EMISSIVEDIRECTUV: number;
  104276. SPECULAR: boolean;
  104277. SPECULARDIRECTUV: number;
  104278. BUMP: boolean;
  104279. BUMPDIRECTUV: number;
  104280. PARALLAX: boolean;
  104281. PARALLAXOCCLUSION: boolean;
  104282. SPECULAROVERALPHA: boolean;
  104283. CLIPPLANE: boolean;
  104284. CLIPPLANE2: boolean;
  104285. CLIPPLANE3: boolean;
  104286. CLIPPLANE4: boolean;
  104287. ALPHATEST: boolean;
  104288. DEPTHPREPASS: boolean;
  104289. ALPHAFROMDIFFUSE: boolean;
  104290. POINTSIZE: boolean;
  104291. FOG: boolean;
  104292. SPECULARTERM: boolean;
  104293. DIFFUSEFRESNEL: boolean;
  104294. OPACITYFRESNEL: boolean;
  104295. REFLECTIONFRESNEL: boolean;
  104296. REFRACTIONFRESNEL: boolean;
  104297. EMISSIVEFRESNEL: boolean;
  104298. FRESNEL: boolean;
  104299. NORMAL: boolean;
  104300. UV1: boolean;
  104301. UV2: boolean;
  104302. VERTEXCOLOR: boolean;
  104303. VERTEXALPHA: boolean;
  104304. NUM_BONE_INFLUENCERS: number;
  104305. BonesPerMesh: number;
  104306. BONETEXTURE: boolean;
  104307. INSTANCES: boolean;
  104308. GLOSSINESS: boolean;
  104309. ROUGHNESS: boolean;
  104310. EMISSIVEASILLUMINATION: boolean;
  104311. LINKEMISSIVEWITHDIFFUSE: boolean;
  104312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104313. LIGHTMAP: boolean;
  104314. LIGHTMAPDIRECTUV: number;
  104315. OBJECTSPACE_NORMALMAP: boolean;
  104316. USELIGHTMAPASSHADOWMAP: boolean;
  104317. REFLECTIONMAP_3D: boolean;
  104318. REFLECTIONMAP_SPHERICAL: boolean;
  104319. REFLECTIONMAP_PLANAR: boolean;
  104320. REFLECTIONMAP_CUBIC: boolean;
  104321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104322. REFLECTIONMAP_PROJECTION: boolean;
  104323. REFLECTIONMAP_SKYBOX: boolean;
  104324. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104325. REFLECTIONMAP_EXPLICIT: boolean;
  104326. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104327. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104328. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104329. INVERTCUBICMAP: boolean;
  104330. LOGARITHMICDEPTH: boolean;
  104331. REFRACTION: boolean;
  104332. REFRACTIONMAP_3D: boolean;
  104333. REFLECTIONOVERALPHA: boolean;
  104334. TWOSIDEDLIGHTING: boolean;
  104335. SHADOWFLOAT: boolean;
  104336. MORPHTARGETS: boolean;
  104337. MORPHTARGETS_NORMAL: boolean;
  104338. MORPHTARGETS_TANGENT: boolean;
  104339. MORPHTARGETS_UV: boolean;
  104340. NUM_MORPH_INFLUENCERS: number;
  104341. NONUNIFORMSCALING: boolean;
  104342. PREMULTIPLYALPHA: boolean;
  104343. IMAGEPROCESSING: boolean;
  104344. VIGNETTE: boolean;
  104345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104346. VIGNETTEBLENDMODEOPAQUE: boolean;
  104347. TONEMAPPING: boolean;
  104348. TONEMAPPING_ACES: boolean;
  104349. CONTRAST: boolean;
  104350. COLORCURVES: boolean;
  104351. COLORGRADING: boolean;
  104352. COLORGRADING3D: boolean;
  104353. SAMPLER3DGREENDEPTH: boolean;
  104354. SAMPLER3DBGRMAP: boolean;
  104355. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104356. MULTIVIEW: boolean;
  104357. /**
  104358. * If the reflection texture on this material is in linear color space
  104359. * @hidden
  104360. */
  104361. IS_REFLECTION_LINEAR: boolean;
  104362. /**
  104363. * If the refraction texture on this material is in linear color space
  104364. * @hidden
  104365. */
  104366. IS_REFRACTION_LINEAR: boolean;
  104367. EXPOSURE: boolean;
  104368. constructor();
  104369. setReflectionMode(modeToEnable: string): void;
  104370. }
  104371. /**
  104372. * This is the default material used in Babylon. It is the best trade off between quality
  104373. * and performances.
  104374. * @see http://doc.babylonjs.com/babylon101/materials
  104375. */
  104376. export class StandardMaterial extends PushMaterial {
  104377. private _diffuseTexture;
  104378. /**
  104379. * The basic texture of the material as viewed under a light.
  104380. */
  104381. diffuseTexture: Nullable<BaseTexture>;
  104382. private _ambientTexture;
  104383. /**
  104384. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104385. */
  104386. ambientTexture: Nullable<BaseTexture>;
  104387. private _opacityTexture;
  104388. /**
  104389. * Define the transparency of the material from a texture.
  104390. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104391. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104392. */
  104393. opacityTexture: Nullable<BaseTexture>;
  104394. private _reflectionTexture;
  104395. /**
  104396. * Define the texture used to display the reflection.
  104397. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104398. */
  104399. reflectionTexture: Nullable<BaseTexture>;
  104400. private _emissiveTexture;
  104401. /**
  104402. * Define texture of the material as if self lit.
  104403. * This will be mixed in the final result even in the absence of light.
  104404. */
  104405. emissiveTexture: Nullable<BaseTexture>;
  104406. private _specularTexture;
  104407. /**
  104408. * Define how the color and intensity of the highlight given by the light in the material.
  104409. */
  104410. specularTexture: Nullable<BaseTexture>;
  104411. private _bumpTexture;
  104412. /**
  104413. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104414. * 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.
  104415. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104416. */
  104417. bumpTexture: Nullable<BaseTexture>;
  104418. private _lightmapTexture;
  104419. /**
  104420. * Complex lighting can be computationally expensive to compute at runtime.
  104421. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104422. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104423. */
  104424. lightmapTexture: Nullable<BaseTexture>;
  104425. private _refractionTexture;
  104426. /**
  104427. * Define the texture used to display the refraction.
  104428. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104429. */
  104430. refractionTexture: Nullable<BaseTexture>;
  104431. /**
  104432. * The color of the material lit by the environmental background lighting.
  104433. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104434. */
  104435. ambientColor: Color3;
  104436. /**
  104437. * The basic color of the material as viewed under a light.
  104438. */
  104439. diffuseColor: Color3;
  104440. /**
  104441. * Define how the color and intensity of the highlight given by the light in the material.
  104442. */
  104443. specularColor: Color3;
  104444. /**
  104445. * Define the color of the material as if self lit.
  104446. * This will be mixed in the final result even in the absence of light.
  104447. */
  104448. emissiveColor: Color3;
  104449. /**
  104450. * Defines how sharp are the highlights in the material.
  104451. * The bigger the value the sharper giving a more glossy feeling to the result.
  104452. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104453. */
  104454. specularPower: number;
  104455. private _useAlphaFromDiffuseTexture;
  104456. /**
  104457. * Does the transparency come from the diffuse texture alpha channel.
  104458. */
  104459. useAlphaFromDiffuseTexture: boolean;
  104460. private _useEmissiveAsIllumination;
  104461. /**
  104462. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104463. */
  104464. useEmissiveAsIllumination: boolean;
  104465. private _linkEmissiveWithDiffuse;
  104466. /**
  104467. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104468. * the emissive level when the final color is close to one.
  104469. */
  104470. linkEmissiveWithDiffuse: boolean;
  104471. private _useSpecularOverAlpha;
  104472. /**
  104473. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104474. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104475. */
  104476. useSpecularOverAlpha: boolean;
  104477. private _useReflectionOverAlpha;
  104478. /**
  104479. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104480. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104481. */
  104482. useReflectionOverAlpha: boolean;
  104483. private _disableLighting;
  104484. /**
  104485. * Does lights from the scene impacts this material.
  104486. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104487. */
  104488. disableLighting: boolean;
  104489. private _useObjectSpaceNormalMap;
  104490. /**
  104491. * Allows using an object space normal map (instead of tangent space).
  104492. */
  104493. useObjectSpaceNormalMap: boolean;
  104494. private _useParallax;
  104495. /**
  104496. * Is parallax enabled or not.
  104497. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104498. */
  104499. useParallax: boolean;
  104500. private _useParallaxOcclusion;
  104501. /**
  104502. * Is parallax occlusion enabled or not.
  104503. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104504. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104505. */
  104506. useParallaxOcclusion: boolean;
  104507. /**
  104508. * 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.
  104509. */
  104510. parallaxScaleBias: number;
  104511. private _roughness;
  104512. /**
  104513. * Helps to define how blurry the reflections should appears in the material.
  104514. */
  104515. roughness: number;
  104516. /**
  104517. * In case of refraction, define the value of the index of refraction.
  104518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104519. */
  104520. indexOfRefraction: number;
  104521. /**
  104522. * Invert the refraction texture alongside the y axis.
  104523. * It can be useful with procedural textures or probe for instance.
  104524. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104525. */
  104526. invertRefractionY: boolean;
  104527. /**
  104528. * Defines the alpha limits in alpha test mode.
  104529. */
  104530. alphaCutOff: number;
  104531. private _useLightmapAsShadowmap;
  104532. /**
  104533. * In case of light mapping, define whether the map contains light or shadow informations.
  104534. */
  104535. useLightmapAsShadowmap: boolean;
  104536. private _diffuseFresnelParameters;
  104537. /**
  104538. * Define the diffuse fresnel parameters of the material.
  104539. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104540. */
  104541. diffuseFresnelParameters: FresnelParameters;
  104542. private _opacityFresnelParameters;
  104543. /**
  104544. * Define the opacity fresnel parameters of the material.
  104545. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104546. */
  104547. opacityFresnelParameters: FresnelParameters;
  104548. private _reflectionFresnelParameters;
  104549. /**
  104550. * Define the reflection fresnel parameters of the material.
  104551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104552. */
  104553. reflectionFresnelParameters: FresnelParameters;
  104554. private _refractionFresnelParameters;
  104555. /**
  104556. * Define the refraction fresnel parameters of the material.
  104557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104558. */
  104559. refractionFresnelParameters: FresnelParameters;
  104560. private _emissiveFresnelParameters;
  104561. /**
  104562. * Define the emissive fresnel parameters of the material.
  104563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104564. */
  104565. emissiveFresnelParameters: FresnelParameters;
  104566. private _useReflectionFresnelFromSpecular;
  104567. /**
  104568. * If true automatically deducts the fresnels values from the material specularity.
  104569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104570. */
  104571. useReflectionFresnelFromSpecular: boolean;
  104572. private _useGlossinessFromSpecularMapAlpha;
  104573. /**
  104574. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104575. */
  104576. useGlossinessFromSpecularMapAlpha: boolean;
  104577. private _maxSimultaneousLights;
  104578. /**
  104579. * Defines the maximum number of lights that can be used in the material
  104580. */
  104581. maxSimultaneousLights: number;
  104582. private _invertNormalMapX;
  104583. /**
  104584. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104585. */
  104586. invertNormalMapX: boolean;
  104587. private _invertNormalMapY;
  104588. /**
  104589. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104590. */
  104591. invertNormalMapY: boolean;
  104592. private _twoSidedLighting;
  104593. /**
  104594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104595. */
  104596. twoSidedLighting: boolean;
  104597. /**
  104598. * Default configuration related to image processing available in the standard Material.
  104599. */
  104600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104601. /**
  104602. * Gets the image processing configuration used either in this material.
  104603. */
  104604. /**
  104605. * Sets the Default image processing configuration used either in the this material.
  104606. *
  104607. * If sets to null, the scene one is in use.
  104608. */
  104609. imageProcessingConfiguration: ImageProcessingConfiguration;
  104610. /**
  104611. * Keep track of the image processing observer to allow dispose and replace.
  104612. */
  104613. private _imageProcessingObserver;
  104614. /**
  104615. * Attaches a new image processing configuration to the Standard Material.
  104616. * @param configuration
  104617. */
  104618. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104619. /**
  104620. * Gets wether the color curves effect is enabled.
  104621. */
  104622. /**
  104623. * Sets wether the color curves effect is enabled.
  104624. */
  104625. cameraColorCurvesEnabled: boolean;
  104626. /**
  104627. * Gets wether the color grading effect is enabled.
  104628. */
  104629. /**
  104630. * Gets wether the color grading effect is enabled.
  104631. */
  104632. cameraColorGradingEnabled: boolean;
  104633. /**
  104634. * Gets wether tonemapping is enabled or not.
  104635. */
  104636. /**
  104637. * Sets wether tonemapping is enabled or not
  104638. */
  104639. cameraToneMappingEnabled: boolean;
  104640. /**
  104641. * The camera exposure used on this material.
  104642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104643. * This corresponds to a photographic exposure.
  104644. */
  104645. /**
  104646. * The camera exposure used on this material.
  104647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104648. * This corresponds to a photographic exposure.
  104649. */
  104650. cameraExposure: number;
  104651. /**
  104652. * Gets The camera contrast used on this material.
  104653. */
  104654. /**
  104655. * Sets The camera contrast used on this material.
  104656. */
  104657. cameraContrast: number;
  104658. /**
  104659. * Gets the Color Grading 2D Lookup Texture.
  104660. */
  104661. /**
  104662. * Sets the Color Grading 2D Lookup Texture.
  104663. */
  104664. cameraColorGradingTexture: Nullable<BaseTexture>;
  104665. /**
  104666. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104667. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104668. * 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;
  104669. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104670. */
  104671. /**
  104672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104674. * 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;
  104675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104676. */
  104677. cameraColorCurves: Nullable<ColorCurves>;
  104678. /**
  104679. * Custom callback helping to override the default shader used in the material.
  104680. */
  104681. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104682. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104683. protected _worldViewProjectionMatrix: Matrix;
  104684. protected _globalAmbientColor: Color3;
  104685. protected _useLogarithmicDepth: boolean;
  104686. /**
  104687. * Instantiates a new standard material.
  104688. * This is the default material used in Babylon. It is the best trade off between quality
  104689. * and performances.
  104690. * @see http://doc.babylonjs.com/babylon101/materials
  104691. * @param name Define the name of the material in the scene
  104692. * @param scene Define the scene the material belong to
  104693. */
  104694. constructor(name: string, scene: Scene);
  104695. /**
  104696. * Gets a boolean indicating that current material needs to register RTT
  104697. */
  104698. readonly hasRenderTargetTextures: boolean;
  104699. /**
  104700. * Gets the current class name of the material e.g. "StandardMaterial"
  104701. * Mainly use in serialization.
  104702. * @returns the class name
  104703. */
  104704. getClassName(): string;
  104705. /**
  104706. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104707. * You can try switching to logarithmic depth.
  104708. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104709. */
  104710. useLogarithmicDepth: boolean;
  104711. /**
  104712. * Specifies if the material will require alpha blending
  104713. * @returns a boolean specifying if alpha blending is needed
  104714. */
  104715. needAlphaBlending(): boolean;
  104716. /**
  104717. * Specifies if this material should be rendered in alpha test mode
  104718. * @returns a boolean specifying if an alpha test is needed.
  104719. */
  104720. needAlphaTesting(): boolean;
  104721. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104722. /**
  104723. * Get the texture used for alpha test purpose.
  104724. * @returns the diffuse texture in case of the standard material.
  104725. */
  104726. getAlphaTestTexture(): Nullable<BaseTexture>;
  104727. /**
  104728. * Get if the submesh is ready to be used and all its information available.
  104729. * Child classes can use it to update shaders
  104730. * @param mesh defines the mesh to check
  104731. * @param subMesh defines which submesh to check
  104732. * @param useInstances specifies that instances should be used
  104733. * @returns a boolean indicating that the submesh is ready or not
  104734. */
  104735. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104736. /**
  104737. * Builds the material UBO layouts.
  104738. * Used internally during the effect preparation.
  104739. */
  104740. buildUniformLayout(): void;
  104741. /**
  104742. * Unbinds the material from the mesh
  104743. */
  104744. unbind(): void;
  104745. /**
  104746. * Binds the submesh to this material by preparing the effect and shader to draw
  104747. * @param world defines the world transformation matrix
  104748. * @param mesh defines the mesh containing the submesh
  104749. * @param subMesh defines the submesh to bind the material to
  104750. */
  104751. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104752. /**
  104753. * Get the list of animatables in the material.
  104754. * @returns the list of animatables object used in the material
  104755. */
  104756. getAnimatables(): IAnimatable[];
  104757. /**
  104758. * Gets the active textures from the material
  104759. * @returns an array of textures
  104760. */
  104761. getActiveTextures(): BaseTexture[];
  104762. /**
  104763. * Specifies if the material uses a texture
  104764. * @param texture defines the texture to check against the material
  104765. * @returns a boolean specifying if the material uses the texture
  104766. */
  104767. hasTexture(texture: BaseTexture): boolean;
  104768. /**
  104769. * Disposes the material
  104770. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104771. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104772. */
  104773. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104774. /**
  104775. * Makes a duplicate of the material, and gives it a new name
  104776. * @param name defines the new name for the duplicated material
  104777. * @returns the cloned material
  104778. */
  104779. clone(name: string): StandardMaterial;
  104780. /**
  104781. * Serializes this material in a JSON representation
  104782. * @returns the serialized material object
  104783. */
  104784. serialize(): any;
  104785. /**
  104786. * Creates a standard material from parsed material data
  104787. * @param source defines the JSON representation of the material
  104788. * @param scene defines the hosting scene
  104789. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104790. * @returns a new standard material
  104791. */
  104792. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104793. /**
  104794. * Are diffuse textures enabled in the application.
  104795. */
  104796. static DiffuseTextureEnabled: boolean;
  104797. /**
  104798. * Are ambient textures enabled in the application.
  104799. */
  104800. static AmbientTextureEnabled: boolean;
  104801. /**
  104802. * Are opacity textures enabled in the application.
  104803. */
  104804. static OpacityTextureEnabled: boolean;
  104805. /**
  104806. * Are reflection textures enabled in the application.
  104807. */
  104808. static ReflectionTextureEnabled: boolean;
  104809. /**
  104810. * Are emissive textures enabled in the application.
  104811. */
  104812. static EmissiveTextureEnabled: boolean;
  104813. /**
  104814. * Are specular textures enabled in the application.
  104815. */
  104816. static SpecularTextureEnabled: boolean;
  104817. /**
  104818. * Are bump textures enabled in the application.
  104819. */
  104820. static BumpTextureEnabled: boolean;
  104821. /**
  104822. * Are lightmap textures enabled in the application.
  104823. */
  104824. static LightmapTextureEnabled: boolean;
  104825. /**
  104826. * Are refraction textures enabled in the application.
  104827. */
  104828. static RefractionTextureEnabled: boolean;
  104829. /**
  104830. * Are color grading textures enabled in the application.
  104831. */
  104832. static ColorGradingTextureEnabled: boolean;
  104833. /**
  104834. * Are fresnels enabled in the application.
  104835. */
  104836. static FresnelEnabled: boolean;
  104837. }
  104838. }
  104839. declare module BABYLON {
  104840. /**
  104841. * A class extending Texture allowing drawing on a texture
  104842. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104843. */
  104844. export class DynamicTexture extends Texture {
  104845. private _generateMipMaps;
  104846. private _canvas;
  104847. private _context;
  104848. private _engine;
  104849. /**
  104850. * Creates a DynamicTexture
  104851. * @param name defines the name of the texture
  104852. * @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
  104853. * @param scene defines the scene where you want the texture
  104854. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104855. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104856. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104857. */
  104858. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104859. /**
  104860. * Get the current class name of the texture useful for serialization or dynamic coding.
  104861. * @returns "DynamicTexture"
  104862. */
  104863. getClassName(): string;
  104864. /**
  104865. * Gets the current state of canRescale
  104866. */
  104867. readonly canRescale: boolean;
  104868. private _recreate;
  104869. /**
  104870. * Scales the texture
  104871. * @param ratio the scale factor to apply to both width and height
  104872. */
  104873. scale(ratio: number): void;
  104874. /**
  104875. * Resizes the texture
  104876. * @param width the new width
  104877. * @param height the new height
  104878. */
  104879. scaleTo(width: number, height: number): void;
  104880. /**
  104881. * Gets the context of the canvas used by the texture
  104882. * @returns the canvas context of the dynamic texture
  104883. */
  104884. getContext(): CanvasRenderingContext2D;
  104885. /**
  104886. * Clears the texture
  104887. */
  104888. clear(): void;
  104889. /**
  104890. * Updates the texture
  104891. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104892. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104893. */
  104894. update(invertY?: boolean, premulAlpha?: boolean): void;
  104895. /**
  104896. * Draws text onto the texture
  104897. * @param text defines the text to be drawn
  104898. * @param x defines the placement of the text from the left
  104899. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104900. * @param font defines the font to be used with font-style, font-size, font-name
  104901. * @param color defines the color used for the text
  104902. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104903. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104904. * @param update defines whether texture is immediately update (default is true)
  104905. */
  104906. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104907. /**
  104908. * Clones the texture
  104909. * @returns the clone of the texture.
  104910. */
  104911. clone(): DynamicTexture;
  104912. /**
  104913. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104914. * @returns a serialized dynamic texture object
  104915. */
  104916. serialize(): any;
  104917. /** @hidden */
  104918. _rebuild(): void;
  104919. }
  104920. }
  104921. declare module BABYLON {
  104922. /** @hidden */
  104923. export var imageProcessingPixelShader: {
  104924. name: string;
  104925. shader: string;
  104926. };
  104927. }
  104928. declare module BABYLON {
  104929. /**
  104930. * ImageProcessingPostProcess
  104931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104932. */
  104933. export class ImageProcessingPostProcess extends PostProcess {
  104934. /**
  104935. * Default configuration related to image processing available in the PBR Material.
  104936. */
  104937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104938. /**
  104939. * Gets the image processing configuration used either in this material.
  104940. */
  104941. /**
  104942. * Sets the Default image processing configuration used either in the this material.
  104943. *
  104944. * If sets to null, the scene one is in use.
  104945. */
  104946. imageProcessingConfiguration: ImageProcessingConfiguration;
  104947. /**
  104948. * Keep track of the image processing observer to allow dispose and replace.
  104949. */
  104950. private _imageProcessingObserver;
  104951. /**
  104952. * Attaches a new image processing configuration to the PBR Material.
  104953. * @param configuration
  104954. */
  104955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104956. /**
  104957. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104958. */
  104959. /**
  104960. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104961. */
  104962. colorCurves: Nullable<ColorCurves>;
  104963. /**
  104964. * Gets wether the color curves effect is enabled.
  104965. */
  104966. /**
  104967. * Sets wether the color curves effect is enabled.
  104968. */
  104969. colorCurvesEnabled: boolean;
  104970. /**
  104971. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104972. */
  104973. /**
  104974. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104975. */
  104976. colorGradingTexture: Nullable<BaseTexture>;
  104977. /**
  104978. * Gets wether the color grading effect is enabled.
  104979. */
  104980. /**
  104981. * Gets wether the color grading effect is enabled.
  104982. */
  104983. colorGradingEnabled: boolean;
  104984. /**
  104985. * Gets exposure used in the effect.
  104986. */
  104987. /**
  104988. * Sets exposure used in the effect.
  104989. */
  104990. exposure: number;
  104991. /**
  104992. * Gets wether tonemapping is enabled or not.
  104993. */
  104994. /**
  104995. * Sets wether tonemapping is enabled or not
  104996. */
  104997. toneMappingEnabled: boolean;
  104998. /**
  104999. * Gets the type of tone mapping effect.
  105000. */
  105001. /**
  105002. * Sets the type of tone mapping effect.
  105003. */
  105004. toneMappingType: number;
  105005. /**
  105006. * Gets contrast used in the effect.
  105007. */
  105008. /**
  105009. * Sets contrast used in the effect.
  105010. */
  105011. contrast: number;
  105012. /**
  105013. * Gets Vignette stretch size.
  105014. */
  105015. /**
  105016. * Sets Vignette stretch size.
  105017. */
  105018. vignetteStretch: number;
  105019. /**
  105020. * Gets Vignette centre X Offset.
  105021. */
  105022. /**
  105023. * Sets Vignette centre X Offset.
  105024. */
  105025. vignetteCentreX: number;
  105026. /**
  105027. * Gets Vignette centre Y Offset.
  105028. */
  105029. /**
  105030. * Sets Vignette centre Y Offset.
  105031. */
  105032. vignetteCentreY: number;
  105033. /**
  105034. * Gets Vignette weight or intensity of the vignette effect.
  105035. */
  105036. /**
  105037. * Sets Vignette weight or intensity of the vignette effect.
  105038. */
  105039. vignetteWeight: number;
  105040. /**
  105041. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105042. * if vignetteEnabled is set to true.
  105043. */
  105044. /**
  105045. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105046. * if vignetteEnabled is set to true.
  105047. */
  105048. vignetteColor: Color4;
  105049. /**
  105050. * Gets Camera field of view used by the Vignette effect.
  105051. */
  105052. /**
  105053. * Sets Camera field of view used by the Vignette effect.
  105054. */
  105055. vignetteCameraFov: number;
  105056. /**
  105057. * Gets the vignette blend mode allowing different kind of effect.
  105058. */
  105059. /**
  105060. * Sets the vignette blend mode allowing different kind of effect.
  105061. */
  105062. vignetteBlendMode: number;
  105063. /**
  105064. * Gets wether the vignette effect is enabled.
  105065. */
  105066. /**
  105067. * Sets wether the vignette effect is enabled.
  105068. */
  105069. vignetteEnabled: boolean;
  105070. private _fromLinearSpace;
  105071. /**
  105072. * Gets wether the input of the processing is in Gamma or Linear Space.
  105073. */
  105074. /**
  105075. * Sets wether the input of the processing is in Gamma or Linear Space.
  105076. */
  105077. fromLinearSpace: boolean;
  105078. /**
  105079. * Defines cache preventing GC.
  105080. */
  105081. private _defines;
  105082. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105083. /**
  105084. * "ImageProcessingPostProcess"
  105085. * @returns "ImageProcessingPostProcess"
  105086. */
  105087. getClassName(): string;
  105088. protected _updateParameters(): void;
  105089. dispose(camera?: Camera): void;
  105090. }
  105091. }
  105092. declare module BABYLON {
  105093. /**
  105094. * Class containing static functions to help procedurally build meshes
  105095. */
  105096. export class GroundBuilder {
  105097. /**
  105098. * Creates a ground mesh
  105099. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105100. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105102. * @param name defines the name of the mesh
  105103. * @param options defines the options used to create the mesh
  105104. * @param scene defines the hosting scene
  105105. * @returns the ground mesh
  105106. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105107. */
  105108. static CreateGround(name: string, options: {
  105109. width?: number;
  105110. height?: number;
  105111. subdivisions?: number;
  105112. subdivisionsX?: number;
  105113. subdivisionsY?: number;
  105114. updatable?: boolean;
  105115. }, scene: any): Mesh;
  105116. /**
  105117. * Creates a tiled ground mesh
  105118. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105119. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105120. * * 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
  105121. * * 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
  105122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105123. * @param name defines the name of the mesh
  105124. * @param options defines the options used to create the mesh
  105125. * @param scene defines the hosting scene
  105126. * @returns the tiled ground mesh
  105127. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105128. */
  105129. static CreateTiledGround(name: string, options: {
  105130. xmin: number;
  105131. zmin: number;
  105132. xmax: number;
  105133. zmax: number;
  105134. subdivisions?: {
  105135. w: number;
  105136. h: number;
  105137. };
  105138. precision?: {
  105139. w: number;
  105140. h: number;
  105141. };
  105142. updatable?: boolean;
  105143. }, scene?: Nullable<Scene>): Mesh;
  105144. /**
  105145. * Creates a ground mesh from a height map
  105146. * * The parameter `url` sets the URL of the height map image resource.
  105147. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105148. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105149. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105150. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105151. * * 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.
  105152. * * 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).
  105153. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105155. * @param name defines the name of the mesh
  105156. * @param url defines the url to the height map
  105157. * @param options defines the options used to create the mesh
  105158. * @param scene defines the hosting scene
  105159. * @returns the ground mesh
  105160. * @see https://doc.babylonjs.com/babylon101/height_map
  105161. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105162. */
  105163. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105164. width?: number;
  105165. height?: number;
  105166. subdivisions?: number;
  105167. minHeight?: number;
  105168. maxHeight?: number;
  105169. colorFilter?: Color3;
  105170. alphaFilter?: number;
  105171. updatable?: boolean;
  105172. onReady?: (mesh: GroundMesh) => void;
  105173. }, scene?: Nullable<Scene>): GroundMesh;
  105174. }
  105175. }
  105176. declare module BABYLON {
  105177. /**
  105178. * Class containing static functions to help procedurally build meshes
  105179. */
  105180. export class TorusBuilder {
  105181. /**
  105182. * Creates a torus mesh
  105183. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105184. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105185. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105189. * @param name defines the name of the mesh
  105190. * @param options defines the options used to create the mesh
  105191. * @param scene defines the hosting scene
  105192. * @returns the torus mesh
  105193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105194. */
  105195. static CreateTorus(name: string, options: {
  105196. diameter?: number;
  105197. thickness?: number;
  105198. tessellation?: number;
  105199. updatable?: boolean;
  105200. sideOrientation?: number;
  105201. frontUVs?: Vector4;
  105202. backUVs?: Vector4;
  105203. }, scene: any): Mesh;
  105204. }
  105205. }
  105206. declare module BABYLON {
  105207. /**
  105208. * Class containing static functions to help procedurally build meshes
  105209. */
  105210. export class CylinderBuilder {
  105211. /**
  105212. * Creates a cylinder or a cone mesh
  105213. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105214. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105215. * * 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.
  105216. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105217. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105218. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105219. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105220. * * 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).
  105221. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105222. * * 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).
  105223. * * 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
  105224. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105225. * * 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
  105226. * * 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.
  105227. * * If `enclose` is false, a ring surface is one element.
  105228. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105229. * * 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
  105230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105233. * @param name defines the name of the mesh
  105234. * @param options defines the options used to create the mesh
  105235. * @param scene defines the hosting scene
  105236. * @returns the cylinder mesh
  105237. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105238. */
  105239. static CreateCylinder(name: string, options: {
  105240. height?: number;
  105241. diameterTop?: number;
  105242. diameterBottom?: number;
  105243. diameter?: number;
  105244. tessellation?: number;
  105245. subdivisions?: number;
  105246. arc?: number;
  105247. faceColors?: Color4[];
  105248. faceUV?: Vector4[];
  105249. updatable?: boolean;
  105250. hasRings?: boolean;
  105251. enclose?: boolean;
  105252. cap?: number;
  105253. sideOrientation?: number;
  105254. frontUVs?: Vector4;
  105255. backUVs?: Vector4;
  105256. }, scene: any): Mesh;
  105257. }
  105258. }
  105259. declare module BABYLON {
  105260. /**
  105261. * Options to modify the vr teleportation behavior.
  105262. */
  105263. export interface VRTeleportationOptions {
  105264. /**
  105265. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105266. */
  105267. floorMeshName?: string;
  105268. /**
  105269. * A list of meshes to be used as the teleportation floor. (default: empty)
  105270. */
  105271. floorMeshes?: Mesh[];
  105272. }
  105273. /**
  105274. * Options to modify the vr experience helper's behavior.
  105275. */
  105276. export interface VRExperienceHelperOptions extends WebVROptions {
  105277. /**
  105278. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105279. */
  105280. createDeviceOrientationCamera?: boolean;
  105281. /**
  105282. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105283. */
  105284. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105285. /**
  105286. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105287. */
  105288. laserToggle?: boolean;
  105289. /**
  105290. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105291. */
  105292. floorMeshes?: Mesh[];
  105293. /**
  105294. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105295. */
  105296. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105297. }
  105298. /**
  105299. * Event containing information after VR has been entered
  105300. */
  105301. export class OnAfterEnteringVRObservableEvent {
  105302. /**
  105303. * If entering vr was successful
  105304. */
  105305. success: boolean;
  105306. }
  105307. /**
  105308. * Helps to quickly add VR support to an existing scene.
  105309. * See http://doc.babylonjs.com/how_to/webvr_helper
  105310. */
  105311. export class VRExperienceHelper {
  105312. /** Options to modify the vr experience helper's behavior. */
  105313. webVROptions: VRExperienceHelperOptions;
  105314. private _scene;
  105315. private _position;
  105316. private _btnVR;
  105317. private _btnVRDisplayed;
  105318. private _webVRsupported;
  105319. private _webVRready;
  105320. private _webVRrequesting;
  105321. private _webVRpresenting;
  105322. private _hasEnteredVR;
  105323. private _fullscreenVRpresenting;
  105324. private _canvas;
  105325. private _webVRCamera;
  105326. private _vrDeviceOrientationCamera;
  105327. private _deviceOrientationCamera;
  105328. private _existingCamera;
  105329. private _onKeyDown;
  105330. private _onVrDisplayPresentChange;
  105331. private _onVRDisplayChanged;
  105332. private _onVRRequestPresentStart;
  105333. private _onVRRequestPresentComplete;
  105334. /**
  105335. * 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)
  105336. */
  105337. enableGazeEvenWhenNoPointerLock: boolean;
  105338. /**
  105339. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105340. */
  105341. exitVROnDoubleTap: boolean;
  105342. /**
  105343. * Observable raised right before entering VR.
  105344. */
  105345. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105346. /**
  105347. * Observable raised when entering VR has completed.
  105348. */
  105349. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105350. /**
  105351. * Observable raised when exiting VR.
  105352. */
  105353. onExitingVRObservable: Observable<VRExperienceHelper>;
  105354. /**
  105355. * Observable raised when controller mesh is loaded.
  105356. */
  105357. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105358. /** Return this.onEnteringVRObservable
  105359. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105360. */
  105361. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105362. /** Return this.onExitingVRObservable
  105363. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105364. */
  105365. readonly onExitingVR: Observable<VRExperienceHelper>;
  105366. /** Return this.onControllerMeshLoadedObservable
  105367. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105368. */
  105369. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105370. private _rayLength;
  105371. private _useCustomVRButton;
  105372. private _teleportationRequested;
  105373. private _teleportActive;
  105374. private _floorMeshName;
  105375. private _floorMeshesCollection;
  105376. private _rotationAllowed;
  105377. private _teleportBackwardsVector;
  105378. private _teleportationTarget;
  105379. private _isDefaultTeleportationTarget;
  105380. private _postProcessMove;
  105381. private _teleportationFillColor;
  105382. private _teleportationBorderColor;
  105383. private _rotationAngle;
  105384. private _haloCenter;
  105385. private _cameraGazer;
  105386. private _padSensibilityUp;
  105387. private _padSensibilityDown;
  105388. private _leftController;
  105389. private _rightController;
  105390. /**
  105391. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105392. */
  105393. onNewMeshSelected: Observable<AbstractMesh>;
  105394. /**
  105395. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105396. */
  105397. onNewMeshPicked: Observable<PickingInfo>;
  105398. private _circleEase;
  105399. /**
  105400. * Observable raised before camera teleportation
  105401. */
  105402. onBeforeCameraTeleport: Observable<Vector3>;
  105403. /**
  105404. * Observable raised after camera teleportation
  105405. */
  105406. onAfterCameraTeleport: Observable<Vector3>;
  105407. /**
  105408. * Observable raised when current selected mesh gets unselected
  105409. */
  105410. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105411. private _raySelectionPredicate;
  105412. /**
  105413. * To be optionaly changed by user to define custom ray selection
  105414. */
  105415. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105416. /**
  105417. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105418. */
  105419. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105420. /**
  105421. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105422. */
  105423. teleportationEnabled: boolean;
  105424. private _defaultHeight;
  105425. private _teleportationInitialized;
  105426. private _interactionsEnabled;
  105427. private _interactionsRequested;
  105428. private _displayGaze;
  105429. private _displayLaserPointer;
  105430. /**
  105431. * The mesh used to display where the user is going to teleport.
  105432. */
  105433. /**
  105434. * Sets the mesh to be used to display where the user is going to teleport.
  105435. */
  105436. teleportationTarget: Mesh;
  105437. /**
  105438. * 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
  105439. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105440. * See http://doc.babylonjs.com/resources/baking_transformations
  105441. */
  105442. gazeTrackerMesh: Mesh;
  105443. /**
  105444. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105445. */
  105446. updateGazeTrackerScale: boolean;
  105447. /**
  105448. * If the gaze trackers color should be updated when selecting meshes
  105449. */
  105450. updateGazeTrackerColor: boolean;
  105451. /**
  105452. * The gaze tracking mesh corresponding to the left controller
  105453. */
  105454. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105455. /**
  105456. * The gaze tracking mesh corresponding to the right controller
  105457. */
  105458. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105459. /**
  105460. * If the ray of the gaze should be displayed.
  105461. */
  105462. /**
  105463. * Sets if the ray of the gaze should be displayed.
  105464. */
  105465. displayGaze: boolean;
  105466. /**
  105467. * If the ray of the LaserPointer should be displayed.
  105468. */
  105469. /**
  105470. * Sets if the ray of the LaserPointer should be displayed.
  105471. */
  105472. displayLaserPointer: boolean;
  105473. /**
  105474. * The deviceOrientationCamera used as the camera when not in VR.
  105475. */
  105476. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105477. /**
  105478. * Based on the current WebVR support, returns the current VR camera used.
  105479. */
  105480. readonly currentVRCamera: Nullable<Camera>;
  105481. /**
  105482. * The webVRCamera which is used when in VR.
  105483. */
  105484. readonly webVRCamera: WebVRFreeCamera;
  105485. /**
  105486. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105487. */
  105488. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105489. /**
  105490. * The html button that is used to trigger entering into VR.
  105491. */
  105492. readonly vrButton: Nullable<HTMLButtonElement>;
  105493. private readonly _teleportationRequestInitiated;
  105494. /**
  105495. * Defines wether or not Pointer lock should be requested when switching to
  105496. * full screen.
  105497. */
  105498. requestPointerLockOnFullScreen: boolean;
  105499. /**
  105500. * Instantiates a VRExperienceHelper.
  105501. * Helps to quickly add VR support to an existing scene.
  105502. * @param scene The scene the VRExperienceHelper belongs to.
  105503. * @param webVROptions Options to modify the vr experience helper's behavior.
  105504. */
  105505. constructor(scene: Scene,
  105506. /** Options to modify the vr experience helper's behavior. */
  105507. webVROptions?: VRExperienceHelperOptions);
  105508. private _onDefaultMeshLoaded;
  105509. private _onResize;
  105510. private _onFullscreenChange;
  105511. /**
  105512. * Gets a value indicating if we are currently in VR mode.
  105513. */
  105514. readonly isInVRMode: boolean;
  105515. private onVrDisplayPresentChange;
  105516. private onVRDisplayChanged;
  105517. private moveButtonToBottomRight;
  105518. private displayVRButton;
  105519. private updateButtonVisibility;
  105520. private _cachedAngularSensibility;
  105521. /**
  105522. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105523. * Otherwise, will use the fullscreen API.
  105524. */
  105525. enterVR(): void;
  105526. /**
  105527. * Attempt to exit VR, or fullscreen.
  105528. */
  105529. exitVR(): void;
  105530. /**
  105531. * The position of the vr experience helper.
  105532. */
  105533. /**
  105534. * Sets the position of the vr experience helper.
  105535. */
  105536. position: Vector3;
  105537. /**
  105538. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105539. */
  105540. enableInteractions(): void;
  105541. private readonly _noControllerIsActive;
  105542. private beforeRender;
  105543. private _isTeleportationFloor;
  105544. /**
  105545. * Adds a floor mesh to be used for teleportation.
  105546. * @param floorMesh the mesh to be used for teleportation.
  105547. */
  105548. addFloorMesh(floorMesh: Mesh): void;
  105549. /**
  105550. * Removes a floor mesh from being used for teleportation.
  105551. * @param floorMesh the mesh to be removed.
  105552. */
  105553. removeFloorMesh(floorMesh: Mesh): void;
  105554. /**
  105555. * Enables interactions and teleportation using the VR controllers and gaze.
  105556. * @param vrTeleportationOptions options to modify teleportation behavior.
  105557. */
  105558. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105559. private _onNewGamepadConnected;
  105560. private _tryEnableInteractionOnController;
  105561. private _onNewGamepadDisconnected;
  105562. private _enableInteractionOnController;
  105563. private _checkTeleportWithRay;
  105564. private _checkRotate;
  105565. private _checkTeleportBackwards;
  105566. private _enableTeleportationOnController;
  105567. private _createTeleportationCircles;
  105568. private _displayTeleportationTarget;
  105569. private _hideTeleportationTarget;
  105570. private _rotateCamera;
  105571. private _moveTeleportationSelectorTo;
  105572. private _workingVector;
  105573. private _workingQuaternion;
  105574. private _workingMatrix;
  105575. /**
  105576. * Teleports the users feet to the desired location
  105577. * @param location The location where the user's feet should be placed
  105578. */
  105579. teleportCamera(location: Vector3): void;
  105580. private _convertNormalToDirectionOfRay;
  105581. private _castRayAndSelectObject;
  105582. private _notifySelectedMeshUnselected;
  105583. /**
  105584. * Sets the color of the laser ray from the vr controllers.
  105585. * @param color new color for the ray.
  105586. */
  105587. changeLaserColor(color: Color3): void;
  105588. /**
  105589. * Sets the color of the ray from the vr headsets gaze.
  105590. * @param color new color for the ray.
  105591. */
  105592. changeGazeColor(color: Color3): void;
  105593. /**
  105594. * Exits VR and disposes of the vr experience helper
  105595. */
  105596. dispose(): void;
  105597. /**
  105598. * Gets the name of the VRExperienceHelper class
  105599. * @returns "VRExperienceHelper"
  105600. */
  105601. getClassName(): string;
  105602. }
  105603. }
  105604. declare module BABYLON {
  105605. /**
  105606. * Manages an XRSession to work with Babylon's engine
  105607. * @see https://doc.babylonjs.com/how_to/webxr
  105608. */
  105609. export class WebXRSessionManager implements IDisposable {
  105610. private scene;
  105611. /**
  105612. * Fires every time a new xrFrame arrives which can be used to update the camera
  105613. */
  105614. onXRFrameObservable: Observable<any>;
  105615. /**
  105616. * Fires when the xr session is ended either by the device or manually done
  105617. */
  105618. onXRSessionEnded: Observable<any>;
  105619. /**
  105620. * Underlying xr session
  105621. */
  105622. session: XRSession;
  105623. /**
  105624. * Type of reference space used when creating the session
  105625. */
  105626. referenceSpace: XRReferenceSpace;
  105627. /** @hidden */
  105628. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105629. /**
  105630. * Current XR frame
  105631. */
  105632. currentFrame: Nullable<XRFrame>;
  105633. private _xrNavigator;
  105634. private baseLayer;
  105635. /**
  105636. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105637. * @param scene The scene which the session should be created for
  105638. */
  105639. constructor(scene: Scene);
  105640. /**
  105641. * Initializes the manager
  105642. * After initialization enterXR can be called to start an XR session
  105643. * @returns Promise which resolves after it is initialized
  105644. */
  105645. initializeAsync(): Promise<void>;
  105646. /**
  105647. * Initializes an xr session
  105648. * @param xrSessionMode mode to initialize
  105649. * @returns a promise which will resolve once the session has been initialized
  105650. */
  105651. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105652. /**
  105653. * Sets the reference space on the xr session
  105654. * @param referenceSpace space to set
  105655. * @returns a promise that will resolve once the reference space has been set
  105656. */
  105657. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105658. /**
  105659. * Updates the render state of the session
  105660. * @param state state to set
  105661. * @returns a promise that resolves once the render state has been updated
  105662. */
  105663. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105664. /**
  105665. * Starts rendering to the xr layer
  105666. * @returns a promise that will resolve once rendering has started
  105667. */
  105668. startRenderingToXRAsync(): Promise<void>;
  105669. /**
  105670. * Stops the xrSession and restores the renderloop
  105671. * @returns Promise which resolves after it exits XR
  105672. */
  105673. exitXRAsync(): Promise<unknown>;
  105674. /**
  105675. * Checks if a session would be supported for the creation options specified
  105676. * @param sessionMode session mode to check if supported eg. immersive-vr
  105677. * @returns true if supported
  105678. */
  105679. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105680. /**
  105681. * @hidden
  105682. * Converts the render layer of xrSession to a render target
  105683. * @param session session to create render target for
  105684. * @param scene scene the new render target should be created for
  105685. */
  105686. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105687. /**
  105688. * Disposes of the session manager
  105689. */
  105690. dispose(): void;
  105691. }
  105692. }
  105693. declare module BABYLON {
  105694. /**
  105695. * WebXR Camera which holds the views for the xrSession
  105696. * @see https://doc.babylonjs.com/how_to/webxr
  105697. */
  105698. export class WebXRCamera extends FreeCamera {
  105699. private static _TmpMatrix;
  105700. /**
  105701. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105702. * @param name the name of the camera
  105703. * @param scene the scene to add the camera to
  105704. */
  105705. constructor(name: string, scene: Scene);
  105706. private _updateNumberOfRigCameras;
  105707. /** @hidden */
  105708. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105709. /**
  105710. * Updates the cameras position from the current pose information of the XR session
  105711. * @param xrSessionManager the session containing pose information
  105712. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105713. */
  105714. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105715. }
  105716. }
  105717. declare module BABYLON {
  105718. /**
  105719. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105720. */
  105721. export class WebXRManagedOutputCanvas implements IDisposable {
  105722. private helper;
  105723. private _canvas;
  105724. /**
  105725. * xrpresent context of the canvas which can be used to display/mirror xr content
  105726. */
  105727. canvasContext: WebGLRenderingContext;
  105728. /**
  105729. * xr layer for the canvas
  105730. */
  105731. xrLayer: Nullable<XRWebGLLayer>;
  105732. /**
  105733. * Initializes the xr layer for the session
  105734. * @param xrSession xr session
  105735. * @returns a promise that will resolve once the XR Layer has been created
  105736. */
  105737. initializeXRLayerAsync(xrSession: any): any;
  105738. /**
  105739. * Initializes the canvas to be added/removed upon entering/exiting xr
  105740. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105741. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105742. */
  105743. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105744. /**
  105745. * Disposes of the object
  105746. */
  105747. dispose(): void;
  105748. private _setManagedOutputCanvas;
  105749. private _addCanvas;
  105750. private _removeCanvas;
  105751. }
  105752. }
  105753. declare module BABYLON {
  105754. /**
  105755. * States of the webXR experience
  105756. */
  105757. export enum WebXRState {
  105758. /**
  105759. * Transitioning to being in XR mode
  105760. */
  105761. ENTERING_XR = 0,
  105762. /**
  105763. * Transitioning to non XR mode
  105764. */
  105765. EXITING_XR = 1,
  105766. /**
  105767. * In XR mode and presenting
  105768. */
  105769. IN_XR = 2,
  105770. /**
  105771. * Not entered XR mode
  105772. */
  105773. NOT_IN_XR = 3
  105774. }
  105775. /**
  105776. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105777. * @see https://doc.babylonjs.com/how_to/webxr
  105778. */
  105779. export class WebXRExperienceHelper implements IDisposable {
  105780. private scene;
  105781. /**
  105782. * 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
  105783. */
  105784. container: AbstractMesh;
  105785. /**
  105786. * Camera used to render xr content
  105787. */
  105788. camera: WebXRCamera;
  105789. /**
  105790. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105791. */
  105792. state: WebXRState;
  105793. private _setState;
  105794. private static _TmpVector;
  105795. /**
  105796. * Fires when the state of the experience helper has changed
  105797. */
  105798. onStateChangedObservable: Observable<WebXRState>;
  105799. /** Session manager used to keep track of xr session */
  105800. sessionManager: WebXRSessionManager;
  105801. private _nonVRCamera;
  105802. private _originalSceneAutoClear;
  105803. private _supported;
  105804. /**
  105805. * Creates the experience helper
  105806. * @param scene the scene to attach the experience helper to
  105807. * @returns a promise for the experience helper
  105808. */
  105809. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105810. /**
  105811. * Creates a WebXRExperienceHelper
  105812. * @param scene The scene the helper should be created in
  105813. */
  105814. private constructor();
  105815. /**
  105816. * Exits XR mode and returns the scene to its original state
  105817. * @returns promise that resolves after xr mode has exited
  105818. */
  105819. exitXRAsync(): Promise<unknown>;
  105820. /**
  105821. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105822. * @param sessionCreationOptions options for the XR session
  105823. * @param referenceSpaceType frame of reference of the XR session
  105824. * @param outputCanvas the output canvas that will be used to enter XR mode
  105825. * @returns promise that resolves after xr mode has entered
  105826. */
  105827. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105828. /**
  105829. * Updates the global position of the camera by moving the camera's container
  105830. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  105831. * @param position The desired global position of the camera
  105832. */
  105833. setPositionOfCameraUsingContainer(position: Vector3): void;
  105834. /**
  105835. * Rotates the xr camera by rotating the camera's container around the camera's position
  105836. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105837. * @param rotation the desired quaternion rotation to apply to the camera
  105838. */
  105839. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105840. /**
  105841. * Disposes of the experience helper
  105842. */
  105843. dispose(): void;
  105844. }
  105845. }
  105846. declare module BABYLON {
  105847. /**
  105848. * Button which can be used to enter a different mode of XR
  105849. */
  105850. export class WebXREnterExitUIButton {
  105851. /** button element */
  105852. element: HTMLElement;
  105853. /** XR initialization options for the button */
  105854. sessionMode: XRSessionMode;
  105855. /** Reference space type */
  105856. referenceSpaceType: XRReferenceSpaceType;
  105857. /**
  105858. * Creates a WebXREnterExitUIButton
  105859. * @param element button element
  105860. * @param sessionMode XR initialization session mode
  105861. * @param referenceSpaceType the type of reference space to be used
  105862. */
  105863. constructor(
  105864. /** button element */
  105865. element: HTMLElement,
  105866. /** XR initialization options for the button */
  105867. sessionMode: XRSessionMode,
  105868. /** Reference space type */
  105869. referenceSpaceType: XRReferenceSpaceType);
  105870. /**
  105871. * Overwritable function which can be used to update the button's visuals when the state changes
  105872. * @param activeButton the current active button in the UI
  105873. */
  105874. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105875. }
  105876. /**
  105877. * Options to create the webXR UI
  105878. */
  105879. export class WebXREnterExitUIOptions {
  105880. /**
  105881. * Context to enter xr with
  105882. */
  105883. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105884. /**
  105885. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105886. */
  105887. customButtons?: Array<WebXREnterExitUIButton>;
  105888. }
  105889. /**
  105890. * UI to allow the user to enter/exit XR mode
  105891. */
  105892. export class WebXREnterExitUI implements IDisposable {
  105893. private scene;
  105894. private _overlay;
  105895. private _buttons;
  105896. private _activeButton;
  105897. /**
  105898. * Fired every time the active button is changed.
  105899. *
  105900. * When xr is entered via a button that launches xr that button will be the callback parameter
  105901. *
  105902. * When exiting xr the callback parameter will be null)
  105903. */
  105904. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105905. /**
  105906. * Creates UI to allow the user to enter/exit XR mode
  105907. * @param scene the scene to add the ui to
  105908. * @param helper the xr experience helper to enter/exit xr with
  105909. * @param options options to configure the UI
  105910. * @returns the created ui
  105911. */
  105912. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105913. private constructor();
  105914. private _updateButtons;
  105915. /**
  105916. * Disposes of the object
  105917. */
  105918. dispose(): void;
  105919. }
  105920. }
  105921. declare module BABYLON {
  105922. /**
  105923. * Represents an XR input
  105924. */
  105925. export class WebXRController {
  105926. private scene;
  105927. /** The underlying input source for the controller */
  105928. inputSource: XRInputSource;
  105929. private parentContainer;
  105930. /**
  105931. * 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
  105932. */
  105933. grip?: AbstractMesh;
  105934. /**
  105935. * Pointer which can be used to select objects or attach a visible laser to
  105936. */
  105937. pointer: AbstractMesh;
  105938. /**
  105939. * Event that fires when the controller is removed/disposed
  105940. */
  105941. onDisposeObservable: Observable<{}>;
  105942. private _tmpMatrix;
  105943. private _tmpQuaternion;
  105944. private _tmpVector;
  105945. /**
  105946. * Creates the controller
  105947. * @see https://doc.babylonjs.com/how_to/webxr
  105948. * @param scene the scene which the controller should be associated to
  105949. * @param inputSource the underlying input source for the controller
  105950. * @param parentContainer parent that the controller meshes should be children of
  105951. */
  105952. constructor(scene: Scene,
  105953. /** The underlying input source for the controller */
  105954. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105955. /**
  105956. * Updates the controller pose based on the given XRFrame
  105957. * @param xrFrame xr frame to update the pose with
  105958. * @param referenceSpace reference space to use
  105959. */
  105960. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105961. /**
  105962. * Gets a world space ray coming from the controller
  105963. * @param result the resulting ray
  105964. */
  105965. getWorldPointerRayToRef(result: Ray): void;
  105966. /**
  105967. * Disposes of the object
  105968. */
  105969. dispose(): void;
  105970. }
  105971. }
  105972. declare module BABYLON {
  105973. /**
  105974. * XR input used to track XR inputs such as controllers/rays
  105975. */
  105976. export class WebXRInput implements IDisposable {
  105977. /**
  105978. * Base experience the input listens to
  105979. */
  105980. baseExperience: WebXRExperienceHelper;
  105981. /**
  105982. * XR controllers being tracked
  105983. */
  105984. controllers: Array<WebXRController>;
  105985. private _frameObserver;
  105986. private _stateObserver;
  105987. /**
  105988. * Event when a controller has been connected/added
  105989. */
  105990. onControllerAddedObservable: Observable<WebXRController>;
  105991. /**
  105992. * Event when a controller has been removed/disconnected
  105993. */
  105994. onControllerRemovedObservable: Observable<WebXRController>;
  105995. /**
  105996. * Initializes the WebXRInput
  105997. * @param baseExperience experience helper which the input should be created for
  105998. */
  105999. constructor(
  106000. /**
  106001. * Base experience the input listens to
  106002. */
  106003. baseExperience: WebXRExperienceHelper);
  106004. private _onInputSourcesChange;
  106005. private _addAndRemoveControllers;
  106006. /**
  106007. * Disposes of the object
  106008. */
  106009. dispose(): void;
  106010. }
  106011. }
  106012. declare module BABYLON {
  106013. /**
  106014. * Enables teleportation
  106015. */
  106016. export class WebXRControllerTeleportation {
  106017. private _teleportationFillColor;
  106018. private _teleportationBorderColor;
  106019. private _tmpRay;
  106020. private _tmpVector;
  106021. /**
  106022. * Creates a WebXRControllerTeleportation
  106023. * @param input input manager to add teleportation to
  106024. * @param floorMeshes floormeshes which can be teleported to
  106025. */
  106026. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106027. }
  106028. }
  106029. declare module BABYLON {
  106030. /**
  106031. * Handles pointer input automatically for the pointer of XR controllers
  106032. */
  106033. export class WebXRControllerPointerSelection {
  106034. private static _idCounter;
  106035. private _tmpRay;
  106036. /**
  106037. * Creates a WebXRControllerPointerSelection
  106038. * @param input input manager to setup pointer selection
  106039. */
  106040. constructor(input: WebXRInput);
  106041. private _convertNormalToDirectionOfRay;
  106042. private _updatePointerDistance;
  106043. }
  106044. }
  106045. declare module BABYLON {
  106046. /**
  106047. * Class used to represent data loading progression
  106048. */
  106049. export class SceneLoaderProgressEvent {
  106050. /** defines if data length to load can be evaluated */
  106051. readonly lengthComputable: boolean;
  106052. /** defines the loaded data length */
  106053. readonly loaded: number;
  106054. /** defines the data length to load */
  106055. readonly total: number;
  106056. /**
  106057. * Create a new progress event
  106058. * @param lengthComputable defines if data length to load can be evaluated
  106059. * @param loaded defines the loaded data length
  106060. * @param total defines the data length to load
  106061. */
  106062. constructor(
  106063. /** defines if data length to load can be evaluated */
  106064. lengthComputable: boolean,
  106065. /** defines the loaded data length */
  106066. loaded: number,
  106067. /** defines the data length to load */
  106068. total: number);
  106069. /**
  106070. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106071. * @param event defines the source event
  106072. * @returns a new SceneLoaderProgressEvent
  106073. */
  106074. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106075. }
  106076. /**
  106077. * Interface used by SceneLoader plugins to define supported file extensions
  106078. */
  106079. export interface ISceneLoaderPluginExtensions {
  106080. /**
  106081. * Defines the list of supported extensions
  106082. */
  106083. [extension: string]: {
  106084. isBinary: boolean;
  106085. };
  106086. }
  106087. /**
  106088. * Interface used by SceneLoader plugin factory
  106089. */
  106090. export interface ISceneLoaderPluginFactory {
  106091. /**
  106092. * Defines the name of the factory
  106093. */
  106094. name: string;
  106095. /**
  106096. * Function called to create a new plugin
  106097. * @return the new plugin
  106098. */
  106099. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106100. /**
  106101. * Boolean indicating if the plugin can direct load specific data
  106102. */
  106103. canDirectLoad?: (data: string) => boolean;
  106104. }
  106105. /**
  106106. * Interface used to define a SceneLoader plugin
  106107. */
  106108. export interface ISceneLoaderPlugin {
  106109. /**
  106110. * The friendly name of this plugin.
  106111. */
  106112. name: string;
  106113. /**
  106114. * The file extensions supported by this plugin.
  106115. */
  106116. extensions: string | ISceneLoaderPluginExtensions;
  106117. /**
  106118. * Import meshes into a scene.
  106119. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106120. * @param scene The scene to import into
  106121. * @param data The data to import
  106122. * @param rootUrl The root url for scene and resources
  106123. * @param meshes The meshes array to import into
  106124. * @param particleSystems The particle systems array to import into
  106125. * @param skeletons The skeletons array to import into
  106126. * @param onError The callback when import fails
  106127. * @returns True if successful or false otherwise
  106128. */
  106129. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106130. /**
  106131. * Load into a scene.
  106132. * @param scene The scene to load into
  106133. * @param data The data to import
  106134. * @param rootUrl The root url for scene and resources
  106135. * @param onError The callback when import fails
  106136. * @returns true if successful or false otherwise
  106137. */
  106138. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106139. /**
  106140. * The callback that returns true if the data can be directly loaded.
  106141. */
  106142. canDirectLoad?: (data: string) => boolean;
  106143. /**
  106144. * The callback that allows custom handling of the root url based on the response url.
  106145. */
  106146. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106147. /**
  106148. * Load into an asset container.
  106149. * @param scene The scene to load into
  106150. * @param data The data to import
  106151. * @param rootUrl The root url for scene and resources
  106152. * @param onError The callback when import fails
  106153. * @returns The loaded asset container
  106154. */
  106155. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106156. }
  106157. /**
  106158. * Interface used to define an async SceneLoader plugin
  106159. */
  106160. export interface ISceneLoaderPluginAsync {
  106161. /**
  106162. * The friendly name of this plugin.
  106163. */
  106164. name: string;
  106165. /**
  106166. * The file extensions supported by this plugin.
  106167. */
  106168. extensions: string | ISceneLoaderPluginExtensions;
  106169. /**
  106170. * Import meshes into a scene.
  106171. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106172. * @param scene The scene to import into
  106173. * @param data The data to import
  106174. * @param rootUrl The root url for scene and resources
  106175. * @param onProgress The callback when the load progresses
  106176. * @param fileName Defines the name of the file to load
  106177. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106178. */
  106179. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106180. meshes: AbstractMesh[];
  106181. particleSystems: IParticleSystem[];
  106182. skeletons: Skeleton[];
  106183. animationGroups: AnimationGroup[];
  106184. }>;
  106185. /**
  106186. * Load into a scene.
  106187. * @param scene The scene to load into
  106188. * @param data The data to import
  106189. * @param rootUrl The root url for scene and resources
  106190. * @param onProgress The callback when the load progresses
  106191. * @param fileName Defines the name of the file to load
  106192. * @returns Nothing
  106193. */
  106194. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106195. /**
  106196. * The callback that returns true if the data can be directly loaded.
  106197. */
  106198. canDirectLoad?: (data: string) => boolean;
  106199. /**
  106200. * The callback that allows custom handling of the root url based on the response url.
  106201. */
  106202. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106203. /**
  106204. * Load into an asset container.
  106205. * @param scene The scene to load into
  106206. * @param data The data to import
  106207. * @param rootUrl The root url for scene and resources
  106208. * @param onProgress The callback when the load progresses
  106209. * @param fileName Defines the name of the file to load
  106210. * @returns The loaded asset container
  106211. */
  106212. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106213. }
  106214. /**
  106215. * Class used to load scene from various file formats using registered plugins
  106216. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106217. */
  106218. export class SceneLoader {
  106219. /**
  106220. * No logging while loading
  106221. */
  106222. static readonly NO_LOGGING: number;
  106223. /**
  106224. * Minimal logging while loading
  106225. */
  106226. static readonly MINIMAL_LOGGING: number;
  106227. /**
  106228. * Summary logging while loading
  106229. */
  106230. static readonly SUMMARY_LOGGING: number;
  106231. /**
  106232. * Detailled logging while loading
  106233. */
  106234. static readonly DETAILED_LOGGING: number;
  106235. /**
  106236. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106237. */
  106238. static ForceFullSceneLoadingForIncremental: boolean;
  106239. /**
  106240. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106241. */
  106242. static ShowLoadingScreen: boolean;
  106243. /**
  106244. * Defines the current logging level (while loading the scene)
  106245. * @ignorenaming
  106246. */
  106247. static loggingLevel: number;
  106248. /**
  106249. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106250. */
  106251. static CleanBoneMatrixWeights: boolean;
  106252. /**
  106253. * Event raised when a plugin is used to load a scene
  106254. */
  106255. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106256. private static _registeredPlugins;
  106257. private static _getDefaultPlugin;
  106258. private static _getPluginForExtension;
  106259. private static _getPluginForDirectLoad;
  106260. private static _getPluginForFilename;
  106261. private static _getDirectLoad;
  106262. private static _loadData;
  106263. private static _getFileInfo;
  106264. /**
  106265. * Gets a plugin that can load the given extension
  106266. * @param extension defines the extension to load
  106267. * @returns a plugin or null if none works
  106268. */
  106269. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106270. /**
  106271. * Gets a boolean indicating that the given extension can be loaded
  106272. * @param extension defines the extension to load
  106273. * @returns true if the extension is supported
  106274. */
  106275. static IsPluginForExtensionAvailable(extension: string): boolean;
  106276. /**
  106277. * Adds a new plugin to the list of registered plugins
  106278. * @param plugin defines the plugin to add
  106279. */
  106280. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106281. /**
  106282. * Import meshes into a scene
  106283. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106284. * @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)
  106285. * @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)
  106286. * @param scene the instance of BABYLON.Scene to append to
  106287. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106288. * @param onProgress a callback with a progress event for each file being loaded
  106289. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106290. * @param pluginExtension the extension used to determine the plugin
  106291. * @returns The loaded plugin
  106292. */
  106293. 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>;
  106294. /**
  106295. * Import meshes into a scene
  106296. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106297. * @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)
  106298. * @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)
  106299. * @param scene the instance of BABYLON.Scene to append to
  106300. * @param onProgress a callback with a progress event for each file being loaded
  106301. * @param pluginExtension the extension used to determine the plugin
  106302. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106303. */
  106304. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106305. meshes: AbstractMesh[];
  106306. particleSystems: IParticleSystem[];
  106307. skeletons: Skeleton[];
  106308. animationGroups: AnimationGroup[];
  106309. }>;
  106310. /**
  106311. * Load a scene
  106312. * @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)
  106313. * @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)
  106314. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106315. * @param onSuccess a callback with the scene when import succeeds
  106316. * @param onProgress a callback with a progress event for each file being loaded
  106317. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106318. * @param pluginExtension the extension used to determine the plugin
  106319. * @returns The loaded plugin
  106320. */
  106321. 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>;
  106322. /**
  106323. * Load a scene
  106324. * @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)
  106325. * @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)
  106326. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106327. * @param onProgress a callback with a progress event for each file being loaded
  106328. * @param pluginExtension the extension used to determine the plugin
  106329. * @returns The loaded scene
  106330. */
  106331. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106332. /**
  106333. * Append a scene
  106334. * @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)
  106335. * @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)
  106336. * @param scene is the instance of BABYLON.Scene to append to
  106337. * @param onSuccess a callback with the scene when import succeeds
  106338. * @param onProgress a callback with a progress event for each file being loaded
  106339. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106340. * @param pluginExtension the extension used to determine the plugin
  106341. * @returns The loaded plugin
  106342. */
  106343. 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>;
  106344. /**
  106345. * Append a scene
  106346. * @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)
  106347. * @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)
  106348. * @param scene is the instance of BABYLON.Scene to append to
  106349. * @param onProgress a callback with a progress event for each file being loaded
  106350. * @param pluginExtension the extension used to determine the plugin
  106351. * @returns The given scene
  106352. */
  106353. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106354. /**
  106355. * Load a scene into an asset container
  106356. * @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)
  106357. * @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)
  106358. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106359. * @param onSuccess a callback with the scene when import succeeds
  106360. * @param onProgress a callback with a progress event for each file being loaded
  106361. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106362. * @param pluginExtension the extension used to determine the plugin
  106363. * @returns The loaded plugin
  106364. */
  106365. 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>;
  106366. /**
  106367. * Load a scene into an asset container
  106368. * @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)
  106369. * @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)
  106370. * @param scene is the instance of Scene to append to
  106371. * @param onProgress a callback with a progress event for each file being loaded
  106372. * @param pluginExtension the extension used to determine the plugin
  106373. * @returns The loaded asset container
  106374. */
  106375. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106376. }
  106377. }
  106378. declare module BABYLON {
  106379. /**
  106380. * Generic Controller
  106381. */
  106382. export class GenericController extends WebVRController {
  106383. /**
  106384. * Base Url for the controller model.
  106385. */
  106386. static readonly MODEL_BASE_URL: string;
  106387. /**
  106388. * File name for the controller model.
  106389. */
  106390. static readonly MODEL_FILENAME: string;
  106391. /**
  106392. * Creates a new GenericController from a gamepad
  106393. * @param vrGamepad the gamepad that the controller should be created from
  106394. */
  106395. constructor(vrGamepad: any);
  106396. /**
  106397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106398. * @param scene scene in which to add meshes
  106399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106400. */
  106401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106402. /**
  106403. * Called once for each button that changed state since the last frame
  106404. * @param buttonIdx Which button index changed
  106405. * @param state New state of the button
  106406. * @param changes Which properties on the state changed since last frame
  106407. */
  106408. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106409. }
  106410. }
  106411. declare module BABYLON {
  106412. /**
  106413. * Defines the WindowsMotionController object that the state of the windows motion controller
  106414. */
  106415. export class WindowsMotionController extends WebVRController {
  106416. /**
  106417. * The base url used to load the left and right controller models
  106418. */
  106419. static MODEL_BASE_URL: string;
  106420. /**
  106421. * The name of the left controller model file
  106422. */
  106423. static MODEL_LEFT_FILENAME: string;
  106424. /**
  106425. * The name of the right controller model file
  106426. */
  106427. static MODEL_RIGHT_FILENAME: string;
  106428. /**
  106429. * The controller name prefix for this controller type
  106430. */
  106431. static readonly GAMEPAD_ID_PREFIX: string;
  106432. /**
  106433. * The controller id pattern for this controller type
  106434. */
  106435. private static readonly GAMEPAD_ID_PATTERN;
  106436. private _loadedMeshInfo;
  106437. private readonly _mapping;
  106438. /**
  106439. * Fired when the trackpad on this controller is clicked
  106440. */
  106441. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106442. /**
  106443. * Fired when the trackpad on this controller is modified
  106444. */
  106445. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106446. /**
  106447. * The current x and y values of this controller's trackpad
  106448. */
  106449. trackpad: StickValues;
  106450. /**
  106451. * Creates a new WindowsMotionController from a gamepad
  106452. * @param vrGamepad the gamepad that the controller should be created from
  106453. */
  106454. constructor(vrGamepad: any);
  106455. /**
  106456. * Fired when the trigger on this controller is modified
  106457. */
  106458. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106459. /**
  106460. * Fired when the menu button on this controller is modified
  106461. */
  106462. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106463. /**
  106464. * Fired when the grip button on this controller is modified
  106465. */
  106466. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106467. /**
  106468. * Fired when the thumbstick button on this controller is modified
  106469. */
  106470. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106471. /**
  106472. * Fired when the touchpad button on this controller is modified
  106473. */
  106474. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106475. /**
  106476. * Fired when the touchpad values on this controller are modified
  106477. */
  106478. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106479. private _updateTrackpad;
  106480. /**
  106481. * Called once per frame by the engine.
  106482. */
  106483. update(): void;
  106484. /**
  106485. * Called once for each button that changed state since the last frame
  106486. * @param buttonIdx Which button index changed
  106487. * @param state New state of the button
  106488. * @param changes Which properties on the state changed since last frame
  106489. */
  106490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106491. /**
  106492. * Moves the buttons on the controller mesh based on their current state
  106493. * @param buttonName the name of the button to move
  106494. * @param buttonValue the value of the button which determines the buttons new position
  106495. */
  106496. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106497. /**
  106498. * Moves the axis on the controller mesh based on its current state
  106499. * @param axis the index of the axis
  106500. * @param axisValue the value of the axis which determines the meshes new position
  106501. * @hidden
  106502. */
  106503. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106504. /**
  106505. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106506. * @param scene scene in which to add meshes
  106507. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106508. */
  106509. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106510. /**
  106511. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106512. * can be transformed by button presses and axes values, based on this._mapping.
  106513. *
  106514. * @param scene scene in which the meshes exist
  106515. * @param meshes list of meshes that make up the controller model to process
  106516. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106517. */
  106518. private processModel;
  106519. private createMeshInfo;
  106520. /**
  106521. * Gets the ray of the controller in the direction the controller is pointing
  106522. * @param length the length the resulting ray should be
  106523. * @returns a ray in the direction the controller is pointing
  106524. */
  106525. getForwardRay(length?: number): Ray;
  106526. /**
  106527. * Disposes of the controller
  106528. */
  106529. dispose(): void;
  106530. }
  106531. }
  106532. declare module BABYLON {
  106533. /**
  106534. * Oculus Touch Controller
  106535. */
  106536. export class OculusTouchController extends WebVRController {
  106537. /**
  106538. * Base Url for the controller model.
  106539. */
  106540. static MODEL_BASE_URL: string;
  106541. /**
  106542. * File name for the left controller model.
  106543. */
  106544. static MODEL_LEFT_FILENAME: string;
  106545. /**
  106546. * File name for the right controller model.
  106547. */
  106548. static MODEL_RIGHT_FILENAME: string;
  106549. /**
  106550. * Base Url for the Quest controller model.
  106551. */
  106552. static QUEST_MODEL_BASE_URL: string;
  106553. /**
  106554. * @hidden
  106555. * If the controllers are running on a device that needs the updated Quest controller models
  106556. */
  106557. static _IsQuest: boolean;
  106558. /**
  106559. * Fired when the secondary trigger on this controller is modified
  106560. */
  106561. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106562. /**
  106563. * Fired when the thumb rest on this controller is modified
  106564. */
  106565. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106566. /**
  106567. * Creates a new OculusTouchController from a gamepad
  106568. * @param vrGamepad the gamepad that the controller should be created from
  106569. */
  106570. constructor(vrGamepad: any);
  106571. /**
  106572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106573. * @param scene scene in which to add meshes
  106574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106575. */
  106576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106577. /**
  106578. * Fired when the A button on this controller is modified
  106579. */
  106580. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106581. /**
  106582. * Fired when the B button on this controller is modified
  106583. */
  106584. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106585. /**
  106586. * Fired when the X button on this controller is modified
  106587. */
  106588. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106589. /**
  106590. * Fired when the Y button on this controller is modified
  106591. */
  106592. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106593. /**
  106594. * Called once for each button that changed state since the last frame
  106595. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106596. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106597. * 2) secondary trigger (same)
  106598. * 3) A (right) X (left), touch, pressed = value
  106599. * 4) B / Y
  106600. * 5) thumb rest
  106601. * @param buttonIdx Which button index changed
  106602. * @param state New state of the button
  106603. * @param changes Which properties on the state changed since last frame
  106604. */
  106605. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106606. }
  106607. }
  106608. declare module BABYLON {
  106609. /**
  106610. * Vive Controller
  106611. */
  106612. export class ViveController extends WebVRController {
  106613. /**
  106614. * Base Url for the controller model.
  106615. */
  106616. static MODEL_BASE_URL: string;
  106617. /**
  106618. * File name for the controller model.
  106619. */
  106620. static MODEL_FILENAME: string;
  106621. /**
  106622. * Creates a new ViveController from a gamepad
  106623. * @param vrGamepad the gamepad that the controller should be created from
  106624. */
  106625. constructor(vrGamepad: any);
  106626. /**
  106627. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106628. * @param scene scene in which to add meshes
  106629. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106630. */
  106631. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106632. /**
  106633. * Fired when the left button on this controller is modified
  106634. */
  106635. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106636. /**
  106637. * Fired when the right button on this controller is modified
  106638. */
  106639. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106640. /**
  106641. * Fired when the menu button on this controller is modified
  106642. */
  106643. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106644. /**
  106645. * Called once for each button that changed state since the last frame
  106646. * Vive mapping:
  106647. * 0: touchpad
  106648. * 1: trigger
  106649. * 2: left AND right buttons
  106650. * 3: menu button
  106651. * @param buttonIdx Which button index changed
  106652. * @param state New state of the button
  106653. * @param changes Which properties on the state changed since last frame
  106654. */
  106655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106656. }
  106657. }
  106658. declare module BABYLON {
  106659. /**
  106660. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106661. */
  106662. export class WebXRControllerModelLoader {
  106663. /**
  106664. * Creates the WebXRControllerModelLoader
  106665. * @param input xr input that creates the controllers
  106666. */
  106667. constructor(input: WebXRInput);
  106668. }
  106669. }
  106670. declare module BABYLON {
  106671. /**
  106672. * Contains an array of blocks representing the octree
  106673. */
  106674. export interface IOctreeContainer<T> {
  106675. /**
  106676. * Blocks within the octree
  106677. */
  106678. blocks: Array<OctreeBlock<T>>;
  106679. }
  106680. /**
  106681. * Class used to store a cell in an octree
  106682. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106683. */
  106684. export class OctreeBlock<T> {
  106685. /**
  106686. * Gets the content of the current block
  106687. */
  106688. entries: T[];
  106689. /**
  106690. * Gets the list of block children
  106691. */
  106692. blocks: Array<OctreeBlock<T>>;
  106693. private _depth;
  106694. private _maxDepth;
  106695. private _capacity;
  106696. private _minPoint;
  106697. private _maxPoint;
  106698. private _boundingVectors;
  106699. private _creationFunc;
  106700. /**
  106701. * Creates a new block
  106702. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106703. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106704. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106705. * @param depth defines the current depth of this block in the octree
  106706. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106707. * @param creationFunc defines a callback to call when an element is added to the block
  106708. */
  106709. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106710. /**
  106711. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106712. */
  106713. readonly capacity: number;
  106714. /**
  106715. * Gets the minimum vector (in world space) of the block's bounding box
  106716. */
  106717. readonly minPoint: Vector3;
  106718. /**
  106719. * Gets the maximum vector (in world space) of the block's bounding box
  106720. */
  106721. readonly maxPoint: Vector3;
  106722. /**
  106723. * Add a new element to this block
  106724. * @param entry defines the element to add
  106725. */
  106726. addEntry(entry: T): void;
  106727. /**
  106728. * Remove an element from this block
  106729. * @param entry defines the element to remove
  106730. */
  106731. removeEntry(entry: T): void;
  106732. /**
  106733. * Add an array of elements to this block
  106734. * @param entries defines the array of elements to add
  106735. */
  106736. addEntries(entries: T[]): void;
  106737. /**
  106738. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106739. * @param frustumPlanes defines the frustum planes to test
  106740. * @param selection defines the array to store current content if selection is positive
  106741. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106742. */
  106743. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106744. /**
  106745. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106746. * @param sphereCenter defines the bounding sphere center
  106747. * @param sphereRadius defines the bounding sphere radius
  106748. * @param selection defines the array to store current content if selection is positive
  106749. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106750. */
  106751. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106752. /**
  106753. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106754. * @param ray defines the ray to test with
  106755. * @param selection defines the array to store current content if selection is positive
  106756. */
  106757. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106758. /**
  106759. * Subdivide the content into child blocks (this block will then be empty)
  106760. */
  106761. createInnerBlocks(): void;
  106762. /**
  106763. * @hidden
  106764. */
  106765. 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;
  106766. }
  106767. }
  106768. declare module BABYLON {
  106769. /**
  106770. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106771. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106772. */
  106773. export class Octree<T> {
  106774. /** 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.) */
  106775. maxDepth: number;
  106776. /**
  106777. * Blocks within the octree containing objects
  106778. */
  106779. blocks: Array<OctreeBlock<T>>;
  106780. /**
  106781. * Content stored in the octree
  106782. */
  106783. dynamicContent: T[];
  106784. private _maxBlockCapacity;
  106785. private _selectionContent;
  106786. private _creationFunc;
  106787. /**
  106788. * Creates a octree
  106789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106790. * @param creationFunc function to be used to instatiate the octree
  106791. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106792. * @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.)
  106793. */
  106794. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106795. /** 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.) */
  106796. maxDepth?: number);
  106797. /**
  106798. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106799. * @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);
  106800. * @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);
  106801. * @param entries meshes to be added to the octree blocks
  106802. */
  106803. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106804. /**
  106805. * Adds a mesh to the octree
  106806. * @param entry Mesh to add to the octree
  106807. */
  106808. addMesh(entry: T): void;
  106809. /**
  106810. * Remove an element from the octree
  106811. * @param entry defines the element to remove
  106812. */
  106813. removeMesh(entry: T): void;
  106814. /**
  106815. * Selects an array of meshes within the frustum
  106816. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106817. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106818. * @returns array of meshes within the frustum
  106819. */
  106820. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106821. /**
  106822. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106823. * @param sphereCenter defines the bounding sphere center
  106824. * @param sphereRadius defines the bounding sphere radius
  106825. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106826. * @returns an array of objects that intersect the sphere
  106827. */
  106828. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106829. /**
  106830. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  106831. * @param ray defines the ray to test with
  106832. * @returns array of intersected objects
  106833. */
  106834. intersectsRay(ray: Ray): SmartArray<T>;
  106835. /**
  106836. * Adds a mesh into the octree block if it intersects the block
  106837. */
  106838. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106839. /**
  106840. * Adds a submesh into the octree block if it intersects the block
  106841. */
  106842. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106843. }
  106844. }
  106845. declare module BABYLON {
  106846. interface Scene {
  106847. /**
  106848. * @hidden
  106849. * Backing Filed
  106850. */
  106851. _selectionOctree: Octree<AbstractMesh>;
  106852. /**
  106853. * Gets the octree used to boost mesh selection (picking)
  106854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106855. */
  106856. selectionOctree: Octree<AbstractMesh>;
  106857. /**
  106858. * Creates or updates the octree used to boost selection (picking)
  106859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106860. * @param maxCapacity defines the maximum capacity per leaf
  106861. * @param maxDepth defines the maximum depth of the octree
  106862. * @returns an octree of AbstractMesh
  106863. */
  106864. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106865. }
  106866. interface AbstractMesh {
  106867. /**
  106868. * @hidden
  106869. * Backing Field
  106870. */
  106871. _submeshesOctree: Octree<SubMesh>;
  106872. /**
  106873. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106874. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106875. * @param maxCapacity defines the maximum size of each block (64 by default)
  106876. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106877. * @returns the new octree
  106878. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106880. */
  106881. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106882. }
  106883. /**
  106884. * Defines the octree scene component responsible to manage any octrees
  106885. * in a given scene.
  106886. */
  106887. export class OctreeSceneComponent {
  106888. /**
  106889. * The component name help to identify the component in the list of scene components.
  106890. */
  106891. readonly name: string;
  106892. /**
  106893. * The scene the component belongs to.
  106894. */
  106895. scene: Scene;
  106896. /**
  106897. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106898. */
  106899. readonly checksIsEnabled: boolean;
  106900. /**
  106901. * Creates a new instance of the component for the given scene
  106902. * @param scene Defines the scene to register the component in
  106903. */
  106904. constructor(scene: Scene);
  106905. /**
  106906. * Registers the component in a given scene
  106907. */
  106908. register(): void;
  106909. /**
  106910. * Return the list of active meshes
  106911. * @returns the list of active meshes
  106912. */
  106913. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106914. /**
  106915. * Return the list of active sub meshes
  106916. * @param mesh The mesh to get the candidates sub meshes from
  106917. * @returns the list of active sub meshes
  106918. */
  106919. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106920. private _tempRay;
  106921. /**
  106922. * Return the list of sub meshes intersecting with a given local ray
  106923. * @param mesh defines the mesh to find the submesh for
  106924. * @param localRay defines the ray in local space
  106925. * @returns the list of intersecting sub meshes
  106926. */
  106927. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106928. /**
  106929. * Return the list of sub meshes colliding with a collider
  106930. * @param mesh defines the mesh to find the submesh for
  106931. * @param collider defines the collider to evaluate the collision against
  106932. * @returns the list of colliding sub meshes
  106933. */
  106934. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106935. /**
  106936. * Rebuilds the elements related to this component in case of
  106937. * context lost for instance.
  106938. */
  106939. rebuild(): void;
  106940. /**
  106941. * Disposes the component and the associated ressources.
  106942. */
  106943. dispose(): void;
  106944. }
  106945. }
  106946. declare module BABYLON {
  106947. /**
  106948. * Renders a layer on top of an existing scene
  106949. */
  106950. export class UtilityLayerRenderer implements IDisposable {
  106951. /** the original scene that will be rendered on top of */
  106952. originalScene: Scene;
  106953. private _pointerCaptures;
  106954. private _lastPointerEvents;
  106955. private static _DefaultUtilityLayer;
  106956. private static _DefaultKeepDepthUtilityLayer;
  106957. private _sharedGizmoLight;
  106958. private _renderCamera;
  106959. /**
  106960. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106961. * @returns the camera that is used when rendering the utility layer
  106962. */
  106963. getRenderCamera(): Nullable<Camera>;
  106964. /**
  106965. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106966. * @param cam the camera that should be used when rendering the utility layer
  106967. */
  106968. setRenderCamera(cam: Nullable<Camera>): void;
  106969. /**
  106970. * @hidden
  106971. * Light which used by gizmos to get light shading
  106972. */
  106973. _getSharedGizmoLight(): HemisphericLight;
  106974. /**
  106975. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106976. */
  106977. pickUtilitySceneFirst: boolean;
  106978. /**
  106979. * 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)
  106980. */
  106981. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106982. /**
  106983. * 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)
  106984. */
  106985. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106986. /**
  106987. * The scene that is rendered on top of the original scene
  106988. */
  106989. utilityLayerScene: Scene;
  106990. /**
  106991. * If the utility layer should automatically be rendered on top of existing scene
  106992. */
  106993. shouldRender: boolean;
  106994. /**
  106995. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106996. */
  106997. onlyCheckPointerDownEvents: boolean;
  106998. /**
  106999. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107000. */
  107001. processAllEvents: boolean;
  107002. /**
  107003. * Observable raised when the pointer move from the utility layer scene to the main scene
  107004. */
  107005. onPointerOutObservable: Observable<number>;
  107006. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107007. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107008. private _afterRenderObserver;
  107009. private _sceneDisposeObserver;
  107010. private _originalPointerObserver;
  107011. /**
  107012. * Instantiates a UtilityLayerRenderer
  107013. * @param originalScene the original scene that will be rendered on top of
  107014. * @param handleEvents boolean indicating if the utility layer should handle events
  107015. */
  107016. constructor(
  107017. /** the original scene that will be rendered on top of */
  107018. originalScene: Scene, handleEvents?: boolean);
  107019. private _notifyObservers;
  107020. /**
  107021. * Renders the utility layers scene on top of the original scene
  107022. */
  107023. render(): void;
  107024. /**
  107025. * Disposes of the renderer
  107026. */
  107027. dispose(): void;
  107028. private _updateCamera;
  107029. }
  107030. }
  107031. declare module BABYLON {
  107032. /**
  107033. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107034. */
  107035. export class Gizmo implements IDisposable {
  107036. /** The utility layer the gizmo will be added to */
  107037. gizmoLayer: UtilityLayerRenderer;
  107038. /**
  107039. * The root mesh of the gizmo
  107040. */
  107041. _rootMesh: Mesh;
  107042. private _attachedMesh;
  107043. /**
  107044. * Ratio for the scale of the gizmo (Default: 1)
  107045. */
  107046. scaleRatio: number;
  107047. /**
  107048. * If a custom mesh has been set (Default: false)
  107049. */
  107050. protected _customMeshSet: boolean;
  107051. /**
  107052. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107053. * * When set, interactions will be enabled
  107054. */
  107055. attachedMesh: Nullable<AbstractMesh>;
  107056. /**
  107057. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107058. * @param mesh The mesh to replace the default mesh of the gizmo
  107059. */
  107060. setCustomMesh(mesh: Mesh): void;
  107061. /**
  107062. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107063. */
  107064. updateGizmoRotationToMatchAttachedMesh: boolean;
  107065. /**
  107066. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107067. */
  107068. updateGizmoPositionToMatchAttachedMesh: boolean;
  107069. /**
  107070. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107071. */
  107072. updateScale: boolean;
  107073. protected _interactionsEnabled: boolean;
  107074. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107075. private _beforeRenderObserver;
  107076. private _tempVector;
  107077. /**
  107078. * Creates a gizmo
  107079. * @param gizmoLayer The utility layer the gizmo will be added to
  107080. */
  107081. constructor(
  107082. /** The utility layer the gizmo will be added to */
  107083. gizmoLayer?: UtilityLayerRenderer);
  107084. /**
  107085. * Updates the gizmo to match the attached mesh's position/rotation
  107086. */
  107087. protected _update(): void;
  107088. /**
  107089. * Disposes of the gizmo
  107090. */
  107091. dispose(): void;
  107092. }
  107093. }
  107094. declare module BABYLON {
  107095. /**
  107096. * Single plane drag gizmo
  107097. */
  107098. export class PlaneDragGizmo extends Gizmo {
  107099. /**
  107100. * Drag behavior responsible for the gizmos dragging interactions
  107101. */
  107102. dragBehavior: PointerDragBehavior;
  107103. private _pointerObserver;
  107104. /**
  107105. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107106. */
  107107. snapDistance: number;
  107108. /**
  107109. * Event that fires each time the gizmo snaps to a new location.
  107110. * * snapDistance is the the change in distance
  107111. */
  107112. onSnapObservable: Observable<{
  107113. snapDistance: number;
  107114. }>;
  107115. private _plane;
  107116. private _coloredMaterial;
  107117. private _hoverMaterial;
  107118. private _isEnabled;
  107119. private _parent;
  107120. /** @hidden */
  107121. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107122. /** @hidden */
  107123. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107124. /**
  107125. * Creates a PlaneDragGizmo
  107126. * @param gizmoLayer The utility layer the gizmo will be added to
  107127. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107128. * @param color The color of the gizmo
  107129. */
  107130. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107131. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107132. /**
  107133. * If the gizmo is enabled
  107134. */
  107135. isEnabled: boolean;
  107136. /**
  107137. * Disposes of the gizmo
  107138. */
  107139. dispose(): void;
  107140. }
  107141. }
  107142. declare module BABYLON {
  107143. /**
  107144. * Gizmo that enables dragging a mesh along 3 axis
  107145. */
  107146. export class PositionGizmo extends Gizmo {
  107147. /**
  107148. * Internal gizmo used for interactions on the x axis
  107149. */
  107150. xGizmo: AxisDragGizmo;
  107151. /**
  107152. * Internal gizmo used for interactions on the y axis
  107153. */
  107154. yGizmo: AxisDragGizmo;
  107155. /**
  107156. * Internal gizmo used for interactions on the z axis
  107157. */
  107158. zGizmo: AxisDragGizmo;
  107159. /**
  107160. * Internal gizmo used for interactions on the yz plane
  107161. */
  107162. xPlaneGizmo: PlaneDragGizmo;
  107163. /**
  107164. * Internal gizmo used for interactions on the xz plane
  107165. */
  107166. yPlaneGizmo: PlaneDragGizmo;
  107167. /**
  107168. * Internal gizmo used for interactions on the xy plane
  107169. */
  107170. zPlaneGizmo: PlaneDragGizmo;
  107171. /**
  107172. * private variables
  107173. */
  107174. private _meshAttached;
  107175. private _updateGizmoRotationToMatchAttachedMesh;
  107176. private _snapDistance;
  107177. private _scaleRatio;
  107178. /** Fires an event when any of it's sub gizmos are dragged */
  107179. onDragStartObservable: Observable<unknown>;
  107180. /** Fires an event when any of it's sub gizmos are released from dragging */
  107181. onDragEndObservable: Observable<unknown>;
  107182. /**
  107183. * If set to true, planar drag is enabled
  107184. */
  107185. private _planarGizmoEnabled;
  107186. attachedMesh: Nullable<AbstractMesh>;
  107187. /**
  107188. * Creates a PositionGizmo
  107189. * @param gizmoLayer The utility layer the gizmo will be added to
  107190. */
  107191. constructor(gizmoLayer?: UtilityLayerRenderer);
  107192. /**
  107193. * If the planar drag gizmo is enabled
  107194. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107195. */
  107196. planarGizmoEnabled: boolean;
  107197. updateGizmoRotationToMatchAttachedMesh: boolean;
  107198. /**
  107199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107200. */
  107201. snapDistance: number;
  107202. /**
  107203. * Ratio for the scale of the gizmo (Default: 1)
  107204. */
  107205. scaleRatio: number;
  107206. /**
  107207. * Disposes of the gizmo
  107208. */
  107209. dispose(): void;
  107210. /**
  107211. * CustomMeshes are not supported by this gizmo
  107212. * @param mesh The mesh to replace the default mesh of the gizmo
  107213. */
  107214. setCustomMesh(mesh: Mesh): void;
  107215. }
  107216. }
  107217. declare module BABYLON {
  107218. /**
  107219. * Single axis drag gizmo
  107220. */
  107221. export class AxisDragGizmo extends Gizmo {
  107222. /**
  107223. * Drag behavior responsible for the gizmos dragging interactions
  107224. */
  107225. dragBehavior: PointerDragBehavior;
  107226. private _pointerObserver;
  107227. /**
  107228. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107229. */
  107230. snapDistance: number;
  107231. /**
  107232. * Event that fires each time the gizmo snaps to a new location.
  107233. * * snapDistance is the the change in distance
  107234. */
  107235. onSnapObservable: Observable<{
  107236. snapDistance: number;
  107237. }>;
  107238. private _isEnabled;
  107239. private _parent;
  107240. private _arrow;
  107241. private _coloredMaterial;
  107242. private _hoverMaterial;
  107243. /** @hidden */
  107244. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107245. /** @hidden */
  107246. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107247. /**
  107248. * Creates an AxisDragGizmo
  107249. * @param gizmoLayer The utility layer the gizmo will be added to
  107250. * @param dragAxis The axis which the gizmo will be able to drag on
  107251. * @param color The color of the gizmo
  107252. */
  107253. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107254. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107255. /**
  107256. * If the gizmo is enabled
  107257. */
  107258. isEnabled: boolean;
  107259. /**
  107260. * Disposes of the gizmo
  107261. */
  107262. dispose(): void;
  107263. }
  107264. }
  107265. declare module BABYLON.Debug {
  107266. /**
  107267. * The Axes viewer will show 3 axes in a specific point in space
  107268. */
  107269. export class AxesViewer {
  107270. private _xAxis;
  107271. private _yAxis;
  107272. private _zAxis;
  107273. private _scaleLinesFactor;
  107274. private _instanced;
  107275. /**
  107276. * Gets the hosting scene
  107277. */
  107278. scene: Scene;
  107279. /**
  107280. * Gets or sets a number used to scale line length
  107281. */
  107282. scaleLines: number;
  107283. /** Gets the node hierarchy used to render x-axis */
  107284. readonly xAxis: TransformNode;
  107285. /** Gets the node hierarchy used to render y-axis */
  107286. readonly yAxis: TransformNode;
  107287. /** Gets the node hierarchy used to render z-axis */
  107288. readonly zAxis: TransformNode;
  107289. /**
  107290. * Creates a new AxesViewer
  107291. * @param scene defines the hosting scene
  107292. * @param scaleLines defines a number used to scale line length (1 by default)
  107293. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107294. * @param xAxis defines the node hierarchy used to render the x-axis
  107295. * @param yAxis defines the node hierarchy used to render the y-axis
  107296. * @param zAxis defines the node hierarchy used to render the z-axis
  107297. */
  107298. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107299. /**
  107300. * Force the viewer to update
  107301. * @param position defines the position of the viewer
  107302. * @param xaxis defines the x axis of the viewer
  107303. * @param yaxis defines the y axis of the viewer
  107304. * @param zaxis defines the z axis of the viewer
  107305. */
  107306. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107307. /**
  107308. * Creates an instance of this axes viewer.
  107309. * @returns a new axes viewer with instanced meshes
  107310. */
  107311. createInstance(): AxesViewer;
  107312. /** Releases resources */
  107313. dispose(): void;
  107314. private static _SetRenderingGroupId;
  107315. }
  107316. }
  107317. declare module BABYLON.Debug {
  107318. /**
  107319. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107320. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107321. */
  107322. export class BoneAxesViewer extends AxesViewer {
  107323. /**
  107324. * Gets or sets the target mesh where to display the axes viewer
  107325. */
  107326. mesh: Nullable<Mesh>;
  107327. /**
  107328. * Gets or sets the target bone where to display the axes viewer
  107329. */
  107330. bone: Nullable<Bone>;
  107331. /** Gets current position */
  107332. pos: Vector3;
  107333. /** Gets direction of X axis */
  107334. xaxis: Vector3;
  107335. /** Gets direction of Y axis */
  107336. yaxis: Vector3;
  107337. /** Gets direction of Z axis */
  107338. zaxis: Vector3;
  107339. /**
  107340. * Creates a new BoneAxesViewer
  107341. * @param scene defines the hosting scene
  107342. * @param bone defines the target bone
  107343. * @param mesh defines the target mesh
  107344. * @param scaleLines defines a scaling factor for line length (1 by default)
  107345. */
  107346. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107347. /**
  107348. * Force the viewer to update
  107349. */
  107350. update(): void;
  107351. /** Releases resources */
  107352. dispose(): void;
  107353. }
  107354. }
  107355. declare module BABYLON {
  107356. /**
  107357. * Interface used to define scene explorer extensibility option
  107358. */
  107359. export interface IExplorerExtensibilityOption {
  107360. /**
  107361. * Define the option label
  107362. */
  107363. label: string;
  107364. /**
  107365. * Defines the action to execute on click
  107366. */
  107367. action: (entity: any) => void;
  107368. }
  107369. /**
  107370. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107371. */
  107372. export interface IExplorerExtensibilityGroup {
  107373. /**
  107374. * Defines a predicate to test if a given type mut be extended
  107375. */
  107376. predicate: (entity: any) => boolean;
  107377. /**
  107378. * Gets the list of options added to a type
  107379. */
  107380. entries: IExplorerExtensibilityOption[];
  107381. }
  107382. /**
  107383. * Interface used to define the options to use to create the Inspector
  107384. */
  107385. export interface IInspectorOptions {
  107386. /**
  107387. * Display in overlay mode (default: false)
  107388. */
  107389. overlay?: boolean;
  107390. /**
  107391. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107392. */
  107393. globalRoot?: HTMLElement;
  107394. /**
  107395. * Display the Scene explorer
  107396. */
  107397. showExplorer?: boolean;
  107398. /**
  107399. * Display the property inspector
  107400. */
  107401. showInspector?: boolean;
  107402. /**
  107403. * Display in embed mode (both panes on the right)
  107404. */
  107405. embedMode?: boolean;
  107406. /**
  107407. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107408. */
  107409. handleResize?: boolean;
  107410. /**
  107411. * Allow the panes to popup (default: true)
  107412. */
  107413. enablePopup?: boolean;
  107414. /**
  107415. * Allow the panes to be closed by users (default: true)
  107416. */
  107417. enableClose?: boolean;
  107418. /**
  107419. * Optional list of extensibility entries
  107420. */
  107421. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107422. /**
  107423. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107424. */
  107425. inspectorURL?: string;
  107426. }
  107427. interface Scene {
  107428. /**
  107429. * @hidden
  107430. * Backing field
  107431. */
  107432. _debugLayer: DebugLayer;
  107433. /**
  107434. * Gets the debug layer (aka Inspector) associated with the scene
  107435. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107436. */
  107437. debugLayer: DebugLayer;
  107438. }
  107439. /**
  107440. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107441. * what is happening in your scene
  107442. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107443. */
  107444. export class DebugLayer {
  107445. /**
  107446. * Define the url to get the inspector script from.
  107447. * By default it uses the babylonjs CDN.
  107448. * @ignoreNaming
  107449. */
  107450. static InspectorURL: string;
  107451. private _scene;
  107452. private BJSINSPECTOR;
  107453. private _onPropertyChangedObservable?;
  107454. /**
  107455. * Observable triggered when a property is changed through the inspector.
  107456. */
  107457. readonly onPropertyChangedObservable: any;
  107458. /**
  107459. * Instantiates a new debug layer.
  107460. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107461. * what is happening in your scene
  107462. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107463. * @param scene Defines the scene to inspect
  107464. */
  107465. constructor(scene: Scene);
  107466. /** Creates the inspector window. */
  107467. private _createInspector;
  107468. /**
  107469. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107470. * @param entity defines the entity to select
  107471. * @param lineContainerTitle defines the specific block to highlight
  107472. */
  107473. select(entity: any, lineContainerTitle?: string): void;
  107474. /** Get the inspector from bundle or global */
  107475. private _getGlobalInspector;
  107476. /**
  107477. * Get if the inspector is visible or not.
  107478. * @returns true if visible otherwise, false
  107479. */
  107480. isVisible(): boolean;
  107481. /**
  107482. * Hide the inspector and close its window.
  107483. */
  107484. hide(): void;
  107485. /**
  107486. * Launch the debugLayer.
  107487. * @param config Define the configuration of the inspector
  107488. * @return a promise fulfilled when the debug layer is visible
  107489. */
  107490. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107491. }
  107492. }
  107493. declare module BABYLON {
  107494. /**
  107495. * Class containing static functions to help procedurally build meshes
  107496. */
  107497. export class BoxBuilder {
  107498. /**
  107499. * Creates a box mesh
  107500. * * The parameter `size` sets the size (float) of each box side (default 1)
  107501. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107502. * * 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)
  107503. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107507. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107508. * @param name defines the name of the mesh
  107509. * @param options defines the options used to create the mesh
  107510. * @param scene defines the hosting scene
  107511. * @returns the box mesh
  107512. */
  107513. static CreateBox(name: string, options: {
  107514. size?: number;
  107515. width?: number;
  107516. height?: number;
  107517. depth?: number;
  107518. faceUV?: Vector4[];
  107519. faceColors?: Color4[];
  107520. sideOrientation?: number;
  107521. frontUVs?: Vector4;
  107522. backUVs?: Vector4;
  107523. wrap?: boolean;
  107524. topBaseAt?: number;
  107525. bottomBaseAt?: number;
  107526. updatable?: boolean;
  107527. }, scene?: Nullable<Scene>): Mesh;
  107528. }
  107529. }
  107530. declare module BABYLON {
  107531. /**
  107532. * Class containing static functions to help procedurally build meshes
  107533. */
  107534. export class SphereBuilder {
  107535. /**
  107536. * Creates a sphere mesh
  107537. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107538. * * 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`)
  107539. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107540. * * 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
  107541. * * 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)
  107542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107545. * @param name defines the name of the mesh
  107546. * @param options defines the options used to create the mesh
  107547. * @param scene defines the hosting scene
  107548. * @returns the sphere mesh
  107549. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107550. */
  107551. static CreateSphere(name: string, options: {
  107552. segments?: number;
  107553. diameter?: number;
  107554. diameterX?: number;
  107555. diameterY?: number;
  107556. diameterZ?: number;
  107557. arc?: number;
  107558. slice?: number;
  107559. sideOrientation?: number;
  107560. frontUVs?: Vector4;
  107561. backUVs?: Vector4;
  107562. updatable?: boolean;
  107563. }, scene: any): Mesh;
  107564. }
  107565. }
  107566. declare module BABYLON.Debug {
  107567. /**
  107568. * Used to show the physics impostor around the specific mesh
  107569. */
  107570. export class PhysicsViewer {
  107571. /** @hidden */
  107572. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107573. /** @hidden */
  107574. protected _meshes: Array<Nullable<AbstractMesh>>;
  107575. /** @hidden */
  107576. protected _scene: Nullable<Scene>;
  107577. /** @hidden */
  107578. protected _numMeshes: number;
  107579. /** @hidden */
  107580. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107581. private _renderFunction;
  107582. private _utilityLayer;
  107583. private _debugBoxMesh;
  107584. private _debugSphereMesh;
  107585. private _debugCylinderMesh;
  107586. private _debugMaterial;
  107587. private _debugMeshMeshes;
  107588. /**
  107589. * Creates a new PhysicsViewer
  107590. * @param scene defines the hosting scene
  107591. */
  107592. constructor(scene: Scene);
  107593. /** @hidden */
  107594. protected _updateDebugMeshes(): void;
  107595. /**
  107596. * Renders a specified physic impostor
  107597. * @param impostor defines the impostor to render
  107598. * @param targetMesh defines the mesh represented by the impostor
  107599. * @returns the new debug mesh used to render the impostor
  107600. */
  107601. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107602. /**
  107603. * Hides a specified physic impostor
  107604. * @param impostor defines the impostor to hide
  107605. */
  107606. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107607. private _getDebugMaterial;
  107608. private _getDebugBoxMesh;
  107609. private _getDebugSphereMesh;
  107610. private _getDebugCylinderMesh;
  107611. private _getDebugMeshMesh;
  107612. private _getDebugMesh;
  107613. /** Releases all resources */
  107614. dispose(): void;
  107615. }
  107616. }
  107617. declare module BABYLON {
  107618. /**
  107619. * Class containing static functions to help procedurally build meshes
  107620. */
  107621. export class LinesBuilder {
  107622. /**
  107623. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107624. * * 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
  107625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107626. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107627. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107628. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107629. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107630. * * 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
  107631. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107634. * @param name defines the name of the new line system
  107635. * @param options defines the options used to create the line system
  107636. * @param scene defines the hosting scene
  107637. * @returns a new line system mesh
  107638. */
  107639. static CreateLineSystem(name: string, options: {
  107640. lines: Vector3[][];
  107641. updatable?: boolean;
  107642. instance?: Nullable<LinesMesh>;
  107643. colors?: Nullable<Color4[][]>;
  107644. useVertexAlpha?: boolean;
  107645. }, scene: Nullable<Scene>): LinesMesh;
  107646. /**
  107647. * Creates a line mesh
  107648. * 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
  107649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107650. * * The parameter `points` is an array successive Vector3
  107651. * * 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
  107652. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107654. * * When updating an instance, remember that only point positions can change, not the number of points
  107655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107657. * @param name defines the name of the new line system
  107658. * @param options defines the options used to create the line system
  107659. * @param scene defines the hosting scene
  107660. * @returns a new line mesh
  107661. */
  107662. static CreateLines(name: string, options: {
  107663. points: Vector3[];
  107664. updatable?: boolean;
  107665. instance?: Nullable<LinesMesh>;
  107666. colors?: Color4[];
  107667. useVertexAlpha?: boolean;
  107668. }, scene?: Nullable<Scene>): LinesMesh;
  107669. /**
  107670. * Creates a dashed line mesh
  107671. * * 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
  107672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107673. * * The parameter `points` is an array successive Vector3
  107674. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107675. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107676. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107677. * * 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
  107678. * * When updating an instance, remember that only point positions can change, not the number of points
  107679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107680. * @param name defines the name of the mesh
  107681. * @param options defines the options used to create the mesh
  107682. * @param scene defines the hosting scene
  107683. * @returns the dashed line mesh
  107684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107685. */
  107686. static CreateDashedLines(name: string, options: {
  107687. points: Vector3[];
  107688. dashSize?: number;
  107689. gapSize?: number;
  107690. dashNb?: number;
  107691. updatable?: boolean;
  107692. instance?: LinesMesh;
  107693. }, scene?: Nullable<Scene>): LinesMesh;
  107694. }
  107695. }
  107696. declare module BABYLON {
  107697. /**
  107698. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107699. * in order to better appreciate the issue one might have.
  107700. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107701. */
  107702. export class RayHelper {
  107703. /**
  107704. * Defines the ray we are currently tryin to visualize.
  107705. */
  107706. ray: Nullable<Ray>;
  107707. private _renderPoints;
  107708. private _renderLine;
  107709. private _renderFunction;
  107710. private _scene;
  107711. private _updateToMeshFunction;
  107712. private _attachedToMesh;
  107713. private _meshSpaceDirection;
  107714. private _meshSpaceOrigin;
  107715. /**
  107716. * Helper function to create a colored helper in a scene in one line.
  107717. * @param ray Defines the ray we are currently tryin to visualize
  107718. * @param scene Defines the scene the ray is used in
  107719. * @param color Defines the color we want to see the ray in
  107720. * @returns The newly created ray helper.
  107721. */
  107722. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107723. /**
  107724. * Instantiate a new ray helper.
  107725. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107726. * in order to better appreciate the issue one might have.
  107727. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107728. * @param ray Defines the ray we are currently tryin to visualize
  107729. */
  107730. constructor(ray: Ray);
  107731. /**
  107732. * Shows the ray we are willing to debug.
  107733. * @param scene Defines the scene the ray needs to be rendered in
  107734. * @param color Defines the color the ray needs to be rendered in
  107735. */
  107736. show(scene: Scene, color?: Color3): void;
  107737. /**
  107738. * Hides the ray we are debugging.
  107739. */
  107740. hide(): void;
  107741. private _render;
  107742. /**
  107743. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107744. * @param mesh Defines the mesh we want the helper attached to
  107745. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107746. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107747. * @param length Defines the length of the ray
  107748. */
  107749. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107750. /**
  107751. * Detach the ray helper from the mesh it has previously been attached to.
  107752. */
  107753. detachFromMesh(): void;
  107754. private _updateToMesh;
  107755. /**
  107756. * Dispose the helper and release its associated resources.
  107757. */
  107758. dispose(): void;
  107759. }
  107760. }
  107761. declare module BABYLON.Debug {
  107762. /**
  107763. * Class used to render a debug view of a given skeleton
  107764. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107765. */
  107766. export class SkeletonViewer {
  107767. /** defines the skeleton to render */
  107768. skeleton: Skeleton;
  107769. /** defines the mesh attached to the skeleton */
  107770. mesh: AbstractMesh;
  107771. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107772. autoUpdateBonesMatrices: boolean;
  107773. /** defines the rendering group id to use with the viewer */
  107774. renderingGroupId: number;
  107775. /** Gets or sets the color used to render the skeleton */
  107776. color: Color3;
  107777. private _scene;
  107778. private _debugLines;
  107779. private _debugMesh;
  107780. private _isEnabled;
  107781. private _renderFunction;
  107782. private _utilityLayer;
  107783. /**
  107784. * Returns the mesh used to render the bones
  107785. */
  107786. readonly debugMesh: Nullable<LinesMesh>;
  107787. /**
  107788. * Creates a new SkeletonViewer
  107789. * @param skeleton defines the skeleton to render
  107790. * @param mesh defines the mesh attached to the skeleton
  107791. * @param scene defines the hosting scene
  107792. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107793. * @param renderingGroupId defines the rendering group id to use with the viewer
  107794. */
  107795. constructor(
  107796. /** defines the skeleton to render */
  107797. skeleton: Skeleton,
  107798. /** defines the mesh attached to the skeleton */
  107799. mesh: AbstractMesh, scene: Scene,
  107800. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107801. autoUpdateBonesMatrices?: boolean,
  107802. /** defines the rendering group id to use with the viewer */
  107803. renderingGroupId?: number);
  107804. /** Gets or sets a boolean indicating if the viewer is enabled */
  107805. isEnabled: boolean;
  107806. private _getBonePosition;
  107807. private _getLinesForBonesWithLength;
  107808. private _getLinesForBonesNoLength;
  107809. /** Update the viewer to sync with current skeleton state */
  107810. update(): void;
  107811. /** Release associated resources */
  107812. dispose(): void;
  107813. }
  107814. }
  107815. declare module BABYLON {
  107816. /**
  107817. * Options to create the null engine
  107818. */
  107819. export class NullEngineOptions {
  107820. /**
  107821. * Render width (Default: 512)
  107822. */
  107823. renderWidth: number;
  107824. /**
  107825. * Render height (Default: 256)
  107826. */
  107827. renderHeight: number;
  107828. /**
  107829. * Texture size (Default: 512)
  107830. */
  107831. textureSize: number;
  107832. /**
  107833. * If delta time between frames should be constant
  107834. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107835. */
  107836. deterministicLockstep: boolean;
  107837. /**
  107838. * Maximum about of steps between frames (Default: 4)
  107839. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107840. */
  107841. lockstepMaxSteps: number;
  107842. }
  107843. /**
  107844. * The null engine class provides support for headless version of babylon.js.
  107845. * This can be used in server side scenario or for testing purposes
  107846. */
  107847. export class NullEngine extends Engine {
  107848. private _options;
  107849. /**
  107850. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107851. */
  107852. isDeterministicLockStep(): boolean;
  107853. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107854. getLockstepMaxSteps(): number;
  107855. /**
  107856. * Sets hardware scaling, used to save performance if needed
  107857. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107858. */
  107859. getHardwareScalingLevel(): number;
  107860. constructor(options?: NullEngineOptions);
  107861. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107862. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107863. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107864. getRenderWidth(useScreen?: boolean): number;
  107865. getRenderHeight(useScreen?: boolean): number;
  107866. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107867. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107868. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107869. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107870. bindSamplers(effect: Effect): void;
  107871. enableEffect(effect: Effect): void;
  107872. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107873. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107874. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107875. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107876. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107877. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107878. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107879. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107880. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107881. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107882. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107883. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107884. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107885. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107886. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107887. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107888. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107889. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107890. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107891. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107892. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107893. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107894. bindBuffers(vertexBuffers: {
  107895. [key: string]: VertexBuffer;
  107896. }, indexBuffer: DataBuffer, effect: Effect): void;
  107897. wipeCaches(bruteForce?: boolean): void;
  107898. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107899. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107901. /** @hidden */
  107902. _createTexture(): WebGLTexture;
  107903. /** @hidden */
  107904. _releaseTexture(texture: InternalTexture): void;
  107905. 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;
  107906. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107907. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107909. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107910. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107911. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107912. areAllEffectsReady(): boolean;
  107913. /**
  107914. * @hidden
  107915. * Get the current error code of the webGL context
  107916. * @returns the error code
  107917. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107918. */
  107919. getError(): number;
  107920. /** @hidden */
  107921. _getUnpackAlignement(): number;
  107922. /** @hidden */
  107923. _unpackFlipY(value: boolean): void;
  107924. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107925. /**
  107926. * Updates a dynamic vertex buffer.
  107927. * @param vertexBuffer the vertex buffer to update
  107928. * @param data the data used to update the vertex buffer
  107929. * @param byteOffset the byte offset of the data (optional)
  107930. * @param byteLength the byte length of the data (optional)
  107931. */
  107932. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107933. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107934. /** @hidden */
  107935. _bindTexture(channel: number, texture: InternalTexture): void;
  107936. /** @hidden */
  107937. _releaseBuffer(buffer: DataBuffer): boolean;
  107938. releaseEffects(): void;
  107939. displayLoadingUI(): void;
  107940. hideLoadingUI(): void;
  107941. /** @hidden */
  107942. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107943. /** @hidden */
  107944. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107945. /** @hidden */
  107946. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107947. /** @hidden */
  107948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107949. }
  107950. }
  107951. declare module BABYLON {
  107952. /** @hidden */
  107953. export class _OcclusionDataStorage {
  107954. /** @hidden */
  107955. occlusionInternalRetryCounter: number;
  107956. /** @hidden */
  107957. isOcclusionQueryInProgress: boolean;
  107958. /** @hidden */
  107959. isOccluded: boolean;
  107960. /** @hidden */
  107961. occlusionRetryCount: number;
  107962. /** @hidden */
  107963. occlusionType: number;
  107964. /** @hidden */
  107965. occlusionQueryAlgorithmType: number;
  107966. }
  107967. interface Engine {
  107968. /**
  107969. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107970. * @return the new query
  107971. */
  107972. createQuery(): WebGLQuery;
  107973. /**
  107974. * Delete and release a webGL query
  107975. * @param query defines the query to delete
  107976. * @return the current engine
  107977. */
  107978. deleteQuery(query: WebGLQuery): Engine;
  107979. /**
  107980. * Check if a given query has resolved and got its value
  107981. * @param query defines the query to check
  107982. * @returns true if the query got its value
  107983. */
  107984. isQueryResultAvailable(query: WebGLQuery): boolean;
  107985. /**
  107986. * Gets the value of a given query
  107987. * @param query defines the query to check
  107988. * @returns the value of the query
  107989. */
  107990. getQueryResult(query: WebGLQuery): number;
  107991. /**
  107992. * Initiates an occlusion query
  107993. * @param algorithmType defines the algorithm to use
  107994. * @param query defines the query to use
  107995. * @returns the current engine
  107996. * @see http://doc.babylonjs.com/features/occlusionquery
  107997. */
  107998. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107999. /**
  108000. * Ends an occlusion query
  108001. * @see http://doc.babylonjs.com/features/occlusionquery
  108002. * @param algorithmType defines the algorithm to use
  108003. * @returns the current engine
  108004. */
  108005. endOcclusionQuery(algorithmType: number): Engine;
  108006. /**
  108007. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108008. * Please note that only one query can be issued at a time
  108009. * @returns a time token used to track the time span
  108010. */
  108011. startTimeQuery(): Nullable<_TimeToken>;
  108012. /**
  108013. * Ends a time query
  108014. * @param token defines the token used to measure the time span
  108015. * @returns the time spent (in ns)
  108016. */
  108017. endTimeQuery(token: _TimeToken): int;
  108018. /** @hidden */
  108019. _currentNonTimestampToken: Nullable<_TimeToken>;
  108020. /** @hidden */
  108021. _createTimeQuery(): WebGLQuery;
  108022. /** @hidden */
  108023. _deleteTimeQuery(query: WebGLQuery): void;
  108024. /** @hidden */
  108025. _getGlAlgorithmType(algorithmType: number): number;
  108026. /** @hidden */
  108027. _getTimeQueryResult(query: WebGLQuery): any;
  108028. /** @hidden */
  108029. _getTimeQueryAvailability(query: WebGLQuery): any;
  108030. }
  108031. interface AbstractMesh {
  108032. /**
  108033. * Backing filed
  108034. * @hidden
  108035. */
  108036. __occlusionDataStorage: _OcclusionDataStorage;
  108037. /**
  108038. * Access property
  108039. * @hidden
  108040. */
  108041. _occlusionDataStorage: _OcclusionDataStorage;
  108042. /**
  108043. * 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.
  108044. * The default value is -1 which means don't break the query and wait till the result
  108045. * @see http://doc.babylonjs.com/features/occlusionquery
  108046. */
  108047. occlusionRetryCount: number;
  108048. /**
  108049. * 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:
  108050. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108051. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108052. * * 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.
  108053. * @see http://doc.babylonjs.com/features/occlusionquery
  108054. */
  108055. occlusionType: number;
  108056. /**
  108057. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108058. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108059. * * 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.
  108060. * @see http://doc.babylonjs.com/features/occlusionquery
  108061. */
  108062. occlusionQueryAlgorithmType: number;
  108063. /**
  108064. * 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
  108065. * @see http://doc.babylonjs.com/features/occlusionquery
  108066. */
  108067. isOccluded: boolean;
  108068. /**
  108069. * Flag to check the progress status of the query
  108070. * @see http://doc.babylonjs.com/features/occlusionquery
  108071. */
  108072. isOcclusionQueryInProgress: boolean;
  108073. }
  108074. }
  108075. declare module BABYLON {
  108076. /** @hidden */
  108077. export var _forceTransformFeedbackToBundle: boolean;
  108078. interface Engine {
  108079. /**
  108080. * Creates a webGL transform feedback object
  108081. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108082. * @returns the webGL transform feedback object
  108083. */
  108084. createTransformFeedback(): WebGLTransformFeedback;
  108085. /**
  108086. * Delete a webGL transform feedback object
  108087. * @param value defines the webGL transform feedback object to delete
  108088. */
  108089. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108090. /**
  108091. * Bind a webGL transform feedback object to the webgl context
  108092. * @param value defines the webGL transform feedback object to bind
  108093. */
  108094. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108095. /**
  108096. * Begins a transform feedback operation
  108097. * @param usePoints defines if points or triangles must be used
  108098. */
  108099. beginTransformFeedback(usePoints: boolean): void;
  108100. /**
  108101. * Ends a transform feedback operation
  108102. */
  108103. endTransformFeedback(): void;
  108104. /**
  108105. * Specify the varyings to use with transform feedback
  108106. * @param program defines the associated webGL program
  108107. * @param value defines the list of strings representing the varying names
  108108. */
  108109. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108110. /**
  108111. * Bind a webGL buffer for a transform feedback operation
  108112. * @param value defines the webGL buffer to bind
  108113. */
  108114. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108115. }
  108116. }
  108117. declare module BABYLON {
  108118. /**
  108119. * Creation options of the multi render target texture.
  108120. */
  108121. export interface IMultiRenderTargetOptions {
  108122. /**
  108123. * Define if the texture needs to create mip maps after render.
  108124. */
  108125. generateMipMaps?: boolean;
  108126. /**
  108127. * Define the types of all the draw buffers we want to create
  108128. */
  108129. types?: number[];
  108130. /**
  108131. * Define the sampling modes of all the draw buffers we want to create
  108132. */
  108133. samplingModes?: number[];
  108134. /**
  108135. * Define if a depth buffer is required
  108136. */
  108137. generateDepthBuffer?: boolean;
  108138. /**
  108139. * Define if a stencil buffer is required
  108140. */
  108141. generateStencilBuffer?: boolean;
  108142. /**
  108143. * Define if a depth texture is required instead of a depth buffer
  108144. */
  108145. generateDepthTexture?: boolean;
  108146. /**
  108147. * Define the number of desired draw buffers
  108148. */
  108149. textureCount?: number;
  108150. /**
  108151. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108152. */
  108153. doNotChangeAspectRatio?: boolean;
  108154. /**
  108155. * Define the default type of the buffers we are creating
  108156. */
  108157. defaultType?: number;
  108158. }
  108159. /**
  108160. * A multi render target, like a render target provides the ability to render to a texture.
  108161. * Unlike the render target, it can render to several draw buffers in one draw.
  108162. * This is specially interesting in deferred rendering or for any effects requiring more than
  108163. * just one color from a single pass.
  108164. */
  108165. export class MultiRenderTarget extends RenderTargetTexture {
  108166. private _internalTextures;
  108167. private _textures;
  108168. private _multiRenderTargetOptions;
  108169. /**
  108170. * Get if draw buffers are currently supported by the used hardware and browser.
  108171. */
  108172. readonly isSupported: boolean;
  108173. /**
  108174. * Get the list of textures generated by the multi render target.
  108175. */
  108176. readonly textures: Texture[];
  108177. /**
  108178. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108179. */
  108180. readonly depthTexture: Texture;
  108181. /**
  108182. * Set the wrapping mode on U of all the textures we are rendering to.
  108183. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108184. */
  108185. wrapU: number;
  108186. /**
  108187. * Set the wrapping mode on V of all the textures we are rendering to.
  108188. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108189. */
  108190. wrapV: number;
  108191. /**
  108192. * Instantiate a new multi render target texture.
  108193. * A multi render target, like a render target provides the ability to render to a texture.
  108194. * Unlike the render target, it can render to several draw buffers in one draw.
  108195. * This is specially interesting in deferred rendering or for any effects requiring more than
  108196. * just one color from a single pass.
  108197. * @param name Define the name of the texture
  108198. * @param size Define the size of the buffers to render to
  108199. * @param count Define the number of target we are rendering into
  108200. * @param scene Define the scene the texture belongs to
  108201. * @param options Define the options used to create the multi render target
  108202. */
  108203. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108204. /** @hidden */
  108205. _rebuild(): void;
  108206. private _createInternalTextures;
  108207. private _createTextures;
  108208. /**
  108209. * Define the number of samples used if MSAA is enabled.
  108210. */
  108211. samples: number;
  108212. /**
  108213. * Resize all the textures in the multi render target.
  108214. * Be carrefull as it will recreate all the data in the new texture.
  108215. * @param size Define the new size
  108216. */
  108217. resize(size: any): void;
  108218. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108219. /**
  108220. * Dispose the render targets and their associated resources
  108221. */
  108222. dispose(): void;
  108223. /**
  108224. * Release all the underlying texture used as draw buffers.
  108225. */
  108226. releaseInternalTextures(): void;
  108227. }
  108228. }
  108229. declare module BABYLON {
  108230. interface Engine {
  108231. /**
  108232. * Unbind a list of render target textures from the webGL context
  108233. * This is used only when drawBuffer extension or webGL2 are active
  108234. * @param textures defines the render target textures to unbind
  108235. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108236. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108237. */
  108238. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108239. /**
  108240. * Create a multi render target texture
  108241. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108242. * @param size defines the size of the texture
  108243. * @param options defines the creation options
  108244. * @returns the cube texture as an InternalTexture
  108245. */
  108246. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108247. /**
  108248. * Update the sample count for a given multiple render target texture
  108249. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108250. * @param textures defines the textures to update
  108251. * @param samples defines the sample count to set
  108252. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108253. */
  108254. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108255. }
  108256. }
  108257. declare module BABYLON {
  108258. /**
  108259. * Gather the list of clipboard event types as constants.
  108260. */
  108261. export class ClipboardEventTypes {
  108262. /**
  108263. * The clipboard event is fired when a copy command is active (pressed).
  108264. */
  108265. static readonly COPY: number;
  108266. /**
  108267. * The clipboard event is fired when a cut command is active (pressed).
  108268. */
  108269. static readonly CUT: number;
  108270. /**
  108271. * The clipboard event is fired when a paste command is active (pressed).
  108272. */
  108273. static readonly PASTE: number;
  108274. }
  108275. /**
  108276. * This class is used to store clipboard related info for the onClipboardObservable event.
  108277. */
  108278. export class ClipboardInfo {
  108279. /**
  108280. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108281. */
  108282. type: number;
  108283. /**
  108284. * Defines the related dom event
  108285. */
  108286. event: ClipboardEvent;
  108287. /**
  108288. *Creates an instance of ClipboardInfo.
  108289. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108290. * @param event Defines the related dom event
  108291. */
  108292. constructor(
  108293. /**
  108294. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108295. */
  108296. type: number,
  108297. /**
  108298. * Defines the related dom event
  108299. */
  108300. event: ClipboardEvent);
  108301. /**
  108302. * Get the clipboard event's type from the keycode.
  108303. * @param keyCode Defines the keyCode for the current keyboard event.
  108304. * @return {number}
  108305. */
  108306. static GetTypeFromCharacter(keyCode: number): number;
  108307. }
  108308. }
  108309. declare module BABYLON {
  108310. /**
  108311. * Google Daydream controller
  108312. */
  108313. export class DaydreamController extends WebVRController {
  108314. /**
  108315. * Base Url for the controller model.
  108316. */
  108317. static MODEL_BASE_URL: string;
  108318. /**
  108319. * File name for the controller model.
  108320. */
  108321. static MODEL_FILENAME: string;
  108322. /**
  108323. * Gamepad Id prefix used to identify Daydream Controller.
  108324. */
  108325. static readonly GAMEPAD_ID_PREFIX: string;
  108326. /**
  108327. * Creates a new DaydreamController from a gamepad
  108328. * @param vrGamepad the gamepad that the controller should be created from
  108329. */
  108330. constructor(vrGamepad: any);
  108331. /**
  108332. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108333. * @param scene scene in which to add meshes
  108334. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108335. */
  108336. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108337. /**
  108338. * Called once for each button that changed state since the last frame
  108339. * @param buttonIdx Which button index changed
  108340. * @param state New state of the button
  108341. * @param changes Which properties on the state changed since last frame
  108342. */
  108343. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108344. }
  108345. }
  108346. declare module BABYLON {
  108347. /**
  108348. * Gear VR Controller
  108349. */
  108350. export class GearVRController extends WebVRController {
  108351. /**
  108352. * Base Url for the controller model.
  108353. */
  108354. static MODEL_BASE_URL: string;
  108355. /**
  108356. * File name for the controller model.
  108357. */
  108358. static MODEL_FILENAME: string;
  108359. /**
  108360. * Gamepad Id prefix used to identify this controller.
  108361. */
  108362. static readonly GAMEPAD_ID_PREFIX: string;
  108363. private readonly _buttonIndexToObservableNameMap;
  108364. /**
  108365. * Creates a new GearVRController from a gamepad
  108366. * @param vrGamepad the gamepad that the controller should be created from
  108367. */
  108368. constructor(vrGamepad: any);
  108369. /**
  108370. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108371. * @param scene scene in which to add meshes
  108372. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108373. */
  108374. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108375. /**
  108376. * Called once for each button that changed state since the last frame
  108377. * @param buttonIdx Which button index changed
  108378. * @param state New state of the button
  108379. * @param changes Which properties on the state changed since last frame
  108380. */
  108381. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108382. }
  108383. }
  108384. declare module BABYLON {
  108385. /**
  108386. * Class containing static functions to help procedurally build meshes
  108387. */
  108388. export class PolyhedronBuilder {
  108389. /**
  108390. * Creates a polyhedron mesh
  108391. * * 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
  108392. * * The parameter `size` (positive float, default 1) sets the polygon size
  108393. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108394. * * 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`
  108395. * * 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
  108396. * * 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)`)
  108397. * * 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
  108398. * * 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
  108399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108402. * @param name defines the name of the mesh
  108403. * @param options defines the options used to create the mesh
  108404. * @param scene defines the hosting scene
  108405. * @returns the polyhedron mesh
  108406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108407. */
  108408. static CreatePolyhedron(name: string, options: {
  108409. type?: number;
  108410. size?: number;
  108411. sizeX?: number;
  108412. sizeY?: number;
  108413. sizeZ?: number;
  108414. custom?: any;
  108415. faceUV?: Vector4[];
  108416. faceColors?: Color4[];
  108417. flat?: boolean;
  108418. updatable?: boolean;
  108419. sideOrientation?: number;
  108420. frontUVs?: Vector4;
  108421. backUVs?: Vector4;
  108422. }, scene?: Nullable<Scene>): Mesh;
  108423. }
  108424. }
  108425. declare module BABYLON {
  108426. /**
  108427. * Gizmo that enables scaling a mesh along 3 axis
  108428. */
  108429. export class ScaleGizmo extends Gizmo {
  108430. /**
  108431. * Internal gizmo used for interactions on the x axis
  108432. */
  108433. xGizmo: AxisScaleGizmo;
  108434. /**
  108435. * Internal gizmo used for interactions on the y axis
  108436. */
  108437. yGizmo: AxisScaleGizmo;
  108438. /**
  108439. * Internal gizmo used for interactions on the z axis
  108440. */
  108441. zGizmo: AxisScaleGizmo;
  108442. /**
  108443. * Internal gizmo used to scale all axis equally
  108444. */
  108445. uniformScaleGizmo: AxisScaleGizmo;
  108446. private _meshAttached;
  108447. private _updateGizmoRotationToMatchAttachedMesh;
  108448. private _snapDistance;
  108449. private _scaleRatio;
  108450. private _uniformScalingMesh;
  108451. private _octahedron;
  108452. /** Fires an event when any of it's sub gizmos are dragged */
  108453. onDragStartObservable: Observable<unknown>;
  108454. /** Fires an event when any of it's sub gizmos are released from dragging */
  108455. onDragEndObservable: Observable<unknown>;
  108456. attachedMesh: Nullable<AbstractMesh>;
  108457. /**
  108458. * Creates a ScaleGizmo
  108459. * @param gizmoLayer The utility layer the gizmo will be added to
  108460. */
  108461. constructor(gizmoLayer?: UtilityLayerRenderer);
  108462. updateGizmoRotationToMatchAttachedMesh: boolean;
  108463. /**
  108464. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108465. */
  108466. snapDistance: number;
  108467. /**
  108468. * Ratio for the scale of the gizmo (Default: 1)
  108469. */
  108470. scaleRatio: number;
  108471. /**
  108472. * Disposes of the gizmo
  108473. */
  108474. dispose(): void;
  108475. }
  108476. }
  108477. declare module BABYLON {
  108478. /**
  108479. * Single axis scale gizmo
  108480. */
  108481. export class AxisScaleGizmo extends Gizmo {
  108482. /**
  108483. * Drag behavior responsible for the gizmos dragging interactions
  108484. */
  108485. dragBehavior: PointerDragBehavior;
  108486. private _pointerObserver;
  108487. /**
  108488. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108489. */
  108490. snapDistance: number;
  108491. /**
  108492. * Event that fires each time the gizmo snaps to a new location.
  108493. * * snapDistance is the the change in distance
  108494. */
  108495. onSnapObservable: Observable<{
  108496. snapDistance: number;
  108497. }>;
  108498. /**
  108499. * If the scaling operation should be done on all axis (default: false)
  108500. */
  108501. uniformScaling: boolean;
  108502. private _isEnabled;
  108503. private _parent;
  108504. private _arrow;
  108505. private _coloredMaterial;
  108506. private _hoverMaterial;
  108507. /**
  108508. * Creates an AxisScaleGizmo
  108509. * @param gizmoLayer The utility layer the gizmo will be added to
  108510. * @param dragAxis The axis which the gizmo will be able to scale on
  108511. * @param color The color of the gizmo
  108512. */
  108513. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108514. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108515. /**
  108516. * If the gizmo is enabled
  108517. */
  108518. isEnabled: boolean;
  108519. /**
  108520. * Disposes of the gizmo
  108521. */
  108522. dispose(): void;
  108523. /**
  108524. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108525. * @param mesh The mesh to replace the default mesh of the gizmo
  108526. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108527. */
  108528. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108529. }
  108530. }
  108531. declare module BABYLON {
  108532. /**
  108533. * Bounding box gizmo
  108534. */
  108535. export class BoundingBoxGizmo extends Gizmo {
  108536. private _lineBoundingBox;
  108537. private _rotateSpheresParent;
  108538. private _scaleBoxesParent;
  108539. private _boundingDimensions;
  108540. private _renderObserver;
  108541. private _pointerObserver;
  108542. private _scaleDragSpeed;
  108543. private _tmpQuaternion;
  108544. private _tmpVector;
  108545. private _tmpRotationMatrix;
  108546. /**
  108547. * 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)
  108548. */
  108549. ignoreChildren: boolean;
  108550. /**
  108551. * 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)
  108552. */
  108553. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108554. /**
  108555. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108556. */
  108557. rotationSphereSize: number;
  108558. /**
  108559. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108560. */
  108561. scaleBoxSize: number;
  108562. /**
  108563. * 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)
  108564. */
  108565. fixedDragMeshScreenSize: boolean;
  108566. /**
  108567. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108568. */
  108569. fixedDragMeshScreenSizeDistanceFactor: number;
  108570. /**
  108571. * Fired when a rotation sphere or scale box is dragged
  108572. */
  108573. onDragStartObservable: Observable<{}>;
  108574. /**
  108575. * Fired when a scale box is dragged
  108576. */
  108577. onScaleBoxDragObservable: Observable<{}>;
  108578. /**
  108579. * Fired when a scale box drag is ended
  108580. */
  108581. onScaleBoxDragEndObservable: Observable<{}>;
  108582. /**
  108583. * Fired when a rotation sphere is dragged
  108584. */
  108585. onRotationSphereDragObservable: Observable<{}>;
  108586. /**
  108587. * Fired when a rotation sphere drag is ended
  108588. */
  108589. onRotationSphereDragEndObservable: Observable<{}>;
  108590. /**
  108591. * 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)
  108592. */
  108593. scalePivot: Nullable<Vector3>;
  108594. /**
  108595. * Mesh used as a pivot to rotate the attached mesh
  108596. */
  108597. private _anchorMesh;
  108598. private _existingMeshScale;
  108599. private _dragMesh;
  108600. private pointerDragBehavior;
  108601. private coloredMaterial;
  108602. private hoverColoredMaterial;
  108603. /**
  108604. * Sets the color of the bounding box gizmo
  108605. * @param color the color to set
  108606. */
  108607. setColor(color: Color3): void;
  108608. /**
  108609. * Creates an BoundingBoxGizmo
  108610. * @param gizmoLayer The utility layer the gizmo will be added to
  108611. * @param color The color of the gizmo
  108612. */
  108613. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108614. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108615. private _selectNode;
  108616. /**
  108617. * Updates the bounding box information for the Gizmo
  108618. */
  108619. updateBoundingBox(): void;
  108620. private _updateRotationSpheres;
  108621. private _updateScaleBoxes;
  108622. /**
  108623. * Enables rotation on the specified axis and disables rotation on the others
  108624. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108625. */
  108626. setEnabledRotationAxis(axis: string): void;
  108627. /**
  108628. * Enables/disables scaling
  108629. * @param enable if scaling should be enabled
  108630. */
  108631. setEnabledScaling(enable: boolean): void;
  108632. private _updateDummy;
  108633. /**
  108634. * Enables a pointer drag behavior on the bounding box of the gizmo
  108635. */
  108636. enableDragBehavior(): void;
  108637. /**
  108638. * Disposes of the gizmo
  108639. */
  108640. dispose(): void;
  108641. /**
  108642. * 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)
  108643. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108644. * @returns the bounding box mesh with the passed in mesh as a child
  108645. */
  108646. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108647. /**
  108648. * CustomMeshes are not supported by this gizmo
  108649. * @param mesh The mesh to replace the default mesh of the gizmo
  108650. */
  108651. setCustomMesh(mesh: Mesh): void;
  108652. }
  108653. }
  108654. declare module BABYLON {
  108655. /**
  108656. * Single plane rotation gizmo
  108657. */
  108658. export class PlaneRotationGizmo extends Gizmo {
  108659. /**
  108660. * Drag behavior responsible for the gizmos dragging interactions
  108661. */
  108662. dragBehavior: PointerDragBehavior;
  108663. private _pointerObserver;
  108664. /**
  108665. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108666. */
  108667. snapDistance: number;
  108668. /**
  108669. * Event that fires each time the gizmo snaps to a new location.
  108670. * * snapDistance is the the change in distance
  108671. */
  108672. onSnapObservable: Observable<{
  108673. snapDistance: number;
  108674. }>;
  108675. private _isEnabled;
  108676. private _parent;
  108677. /**
  108678. * Creates a PlaneRotationGizmo
  108679. * @param gizmoLayer The utility layer the gizmo will be added to
  108680. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108681. * @param color The color of the gizmo
  108682. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108683. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108684. */
  108685. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  108686. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108687. /**
  108688. * If the gizmo is enabled
  108689. */
  108690. isEnabled: boolean;
  108691. /**
  108692. * Disposes of the gizmo
  108693. */
  108694. dispose(): void;
  108695. }
  108696. }
  108697. declare module BABYLON {
  108698. /**
  108699. * Gizmo that enables rotating a mesh along 3 axis
  108700. */
  108701. export class RotationGizmo extends Gizmo {
  108702. /**
  108703. * Internal gizmo used for interactions on the x axis
  108704. */
  108705. xGizmo: PlaneRotationGizmo;
  108706. /**
  108707. * Internal gizmo used for interactions on the y axis
  108708. */
  108709. yGizmo: PlaneRotationGizmo;
  108710. /**
  108711. * Internal gizmo used for interactions on the z axis
  108712. */
  108713. zGizmo: PlaneRotationGizmo;
  108714. /** Fires an event when any of it's sub gizmos are dragged */
  108715. onDragStartObservable: Observable<unknown>;
  108716. /** Fires an event when any of it's sub gizmos are released from dragging */
  108717. onDragEndObservable: Observable<unknown>;
  108718. private _meshAttached;
  108719. attachedMesh: Nullable<AbstractMesh>;
  108720. /**
  108721. * Creates a RotationGizmo
  108722. * @param gizmoLayer The utility layer the gizmo will be added to
  108723. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108724. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108725. */
  108726. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  108727. updateGizmoRotationToMatchAttachedMesh: boolean;
  108728. /**
  108729. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108730. */
  108731. snapDistance: number;
  108732. /**
  108733. * Ratio for the scale of the gizmo (Default: 1)
  108734. */
  108735. scaleRatio: number;
  108736. /**
  108737. * Disposes of the gizmo
  108738. */
  108739. dispose(): void;
  108740. /**
  108741. * CustomMeshes are not supported by this gizmo
  108742. * @param mesh The mesh to replace the default mesh of the gizmo
  108743. */
  108744. setCustomMesh(mesh: Mesh): void;
  108745. }
  108746. }
  108747. declare module BABYLON {
  108748. /**
  108749. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108750. */
  108751. export class GizmoManager implements IDisposable {
  108752. private scene;
  108753. /**
  108754. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108755. */
  108756. gizmos: {
  108757. positionGizmo: Nullable<PositionGizmo>;
  108758. rotationGizmo: Nullable<RotationGizmo>;
  108759. scaleGizmo: Nullable<ScaleGizmo>;
  108760. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108761. };
  108762. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108763. clearGizmoOnEmptyPointerEvent: boolean;
  108764. /** Fires an event when the manager is attached to a mesh */
  108765. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108766. private _gizmosEnabled;
  108767. private _pointerObserver;
  108768. private _attachedMesh;
  108769. private _boundingBoxColor;
  108770. private _defaultUtilityLayer;
  108771. private _defaultKeepDepthUtilityLayer;
  108772. /**
  108773. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108774. */
  108775. boundingBoxDragBehavior: SixDofDragBehavior;
  108776. /**
  108777. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108778. */
  108779. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108780. /**
  108781. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108782. */
  108783. usePointerToAttachGizmos: boolean;
  108784. /**
  108785. * Utility layer that the bounding box gizmo belongs to
  108786. */
  108787. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108788. /**
  108789. * Utility layer that all gizmos besides bounding box belong to
  108790. */
  108791. readonly utilityLayer: UtilityLayerRenderer;
  108792. /**
  108793. * Instatiates a gizmo manager
  108794. * @param scene the scene to overlay the gizmos on top of
  108795. */
  108796. constructor(scene: Scene);
  108797. /**
  108798. * Attaches a set of gizmos to the specified mesh
  108799. * @param mesh The mesh the gizmo's should be attached to
  108800. */
  108801. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108802. /**
  108803. * If the position gizmo is enabled
  108804. */
  108805. positionGizmoEnabled: boolean;
  108806. /**
  108807. * If the rotation gizmo is enabled
  108808. */
  108809. rotationGizmoEnabled: boolean;
  108810. /**
  108811. * If the scale gizmo is enabled
  108812. */
  108813. scaleGizmoEnabled: boolean;
  108814. /**
  108815. * If the boundingBox gizmo is enabled
  108816. */
  108817. boundingBoxGizmoEnabled: boolean;
  108818. /**
  108819. * Disposes of the gizmo manager
  108820. */
  108821. dispose(): void;
  108822. }
  108823. }
  108824. declare module BABYLON {
  108825. /**
  108826. * A directional light is defined by a direction (what a surprise!).
  108827. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108828. * 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.
  108829. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108830. */
  108831. export class DirectionalLight extends ShadowLight {
  108832. private _shadowFrustumSize;
  108833. /**
  108834. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108835. */
  108836. /**
  108837. * Specifies a fix frustum size for the shadow generation.
  108838. */
  108839. shadowFrustumSize: number;
  108840. private _shadowOrthoScale;
  108841. /**
  108842. * Gets the shadow projection scale against the optimal computed one.
  108843. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108844. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108845. */
  108846. /**
  108847. * Sets the shadow projection scale against the optimal computed one.
  108848. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108849. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108850. */
  108851. shadowOrthoScale: number;
  108852. /**
  108853. * Automatically compute the projection matrix to best fit (including all the casters)
  108854. * on each frame.
  108855. */
  108856. autoUpdateExtends: boolean;
  108857. private _orthoLeft;
  108858. private _orthoRight;
  108859. private _orthoTop;
  108860. private _orthoBottom;
  108861. /**
  108862. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108863. * The directional light is emitted from everywhere in the given direction.
  108864. * It can cast shadows.
  108865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108866. * @param name The friendly name of the light
  108867. * @param direction The direction of the light
  108868. * @param scene The scene the light belongs to
  108869. */
  108870. constructor(name: string, direction: Vector3, scene: Scene);
  108871. /**
  108872. * Returns the string "DirectionalLight".
  108873. * @return The class name
  108874. */
  108875. getClassName(): string;
  108876. /**
  108877. * Returns the integer 1.
  108878. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108879. */
  108880. getTypeID(): number;
  108881. /**
  108882. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108883. * Returns the DirectionalLight Shadow projection matrix.
  108884. */
  108885. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108886. /**
  108887. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108888. * Returns the DirectionalLight Shadow projection matrix.
  108889. */
  108890. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108891. /**
  108892. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108893. * Returns the DirectionalLight Shadow projection matrix.
  108894. */
  108895. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108896. protected _buildUniformLayout(): void;
  108897. /**
  108898. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108899. * @param effect The effect to update
  108900. * @param lightIndex The index of the light in the effect to update
  108901. * @returns The directional light
  108902. */
  108903. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108904. /**
  108905. * Gets the minZ used for shadow according to both the scene and the light.
  108906. *
  108907. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108908. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108909. * @param activeCamera The camera we are returning the min for
  108910. * @returns the depth min z
  108911. */
  108912. getDepthMinZ(activeCamera: Camera): number;
  108913. /**
  108914. * Gets the maxZ used for shadow according to both the scene and the light.
  108915. *
  108916. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108917. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108918. * @param activeCamera The camera we are returning the max for
  108919. * @returns the depth max z
  108920. */
  108921. getDepthMaxZ(activeCamera: Camera): number;
  108922. /**
  108923. * Prepares the list of defines specific to the light type.
  108924. * @param defines the list of defines
  108925. * @param lightIndex defines the index of the light for the effect
  108926. */
  108927. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108928. }
  108929. }
  108930. declare module BABYLON {
  108931. /**
  108932. * Class containing static functions to help procedurally build meshes
  108933. */
  108934. export class HemisphereBuilder {
  108935. /**
  108936. * Creates a hemisphere mesh
  108937. * @param name defines the name of the mesh
  108938. * @param options defines the options used to create the mesh
  108939. * @param scene defines the hosting scene
  108940. * @returns the hemisphere mesh
  108941. */
  108942. static CreateHemisphere(name: string, options: {
  108943. segments?: number;
  108944. diameter?: number;
  108945. sideOrientation?: number;
  108946. }, scene: any): Mesh;
  108947. }
  108948. }
  108949. declare module BABYLON {
  108950. /**
  108951. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108952. * These values define a cone of light starting from the position, emitting toward the direction.
  108953. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108954. * and the exponent defines the speed of the decay of the light with distance (reach).
  108955. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108956. */
  108957. export class SpotLight extends ShadowLight {
  108958. private _angle;
  108959. private _innerAngle;
  108960. private _cosHalfAngle;
  108961. private _lightAngleScale;
  108962. private _lightAngleOffset;
  108963. /**
  108964. * Gets the cone angle of the spot light in Radians.
  108965. */
  108966. /**
  108967. * Sets the cone angle of the spot light in Radians.
  108968. */
  108969. angle: number;
  108970. /**
  108971. * Only used in gltf falloff mode, this defines the angle where
  108972. * the directional falloff will start before cutting at angle which could be seen
  108973. * as outer angle.
  108974. */
  108975. /**
  108976. * Only used in gltf falloff mode, this defines the angle where
  108977. * the directional falloff will start before cutting at angle which could be seen
  108978. * as outer angle.
  108979. */
  108980. innerAngle: number;
  108981. private _shadowAngleScale;
  108982. /**
  108983. * Allows scaling the angle of the light for shadow generation only.
  108984. */
  108985. /**
  108986. * Allows scaling the angle of the light for shadow generation only.
  108987. */
  108988. shadowAngleScale: number;
  108989. /**
  108990. * The light decay speed with the distance from the emission spot.
  108991. */
  108992. exponent: number;
  108993. private _projectionTextureMatrix;
  108994. /**
  108995. * Allows reading the projecton texture
  108996. */
  108997. readonly projectionTextureMatrix: Matrix;
  108998. protected _projectionTextureLightNear: number;
  108999. /**
  109000. * Gets the near clip of the Spotlight for texture projection.
  109001. */
  109002. /**
  109003. * Sets the near clip of the Spotlight for texture projection.
  109004. */
  109005. projectionTextureLightNear: number;
  109006. protected _projectionTextureLightFar: number;
  109007. /**
  109008. * Gets the far clip of the Spotlight for texture projection.
  109009. */
  109010. /**
  109011. * Sets the far clip of the Spotlight for texture projection.
  109012. */
  109013. projectionTextureLightFar: number;
  109014. protected _projectionTextureUpDirection: Vector3;
  109015. /**
  109016. * Gets the Up vector of the Spotlight for texture projection.
  109017. */
  109018. /**
  109019. * Sets the Up vector of the Spotlight for texture projection.
  109020. */
  109021. projectionTextureUpDirection: Vector3;
  109022. private _projectionTexture;
  109023. /**
  109024. * Gets the projection texture of the light.
  109025. */
  109026. /**
  109027. * Sets the projection texture of the light.
  109028. */
  109029. projectionTexture: Nullable<BaseTexture>;
  109030. private _projectionTextureViewLightDirty;
  109031. private _projectionTextureProjectionLightDirty;
  109032. private _projectionTextureDirty;
  109033. private _projectionTextureViewTargetVector;
  109034. private _projectionTextureViewLightMatrix;
  109035. private _projectionTextureProjectionLightMatrix;
  109036. private _projectionTextureScalingMatrix;
  109037. /**
  109038. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109039. * It can cast shadows.
  109040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109041. * @param name The light friendly name
  109042. * @param position The position of the spot light in the scene
  109043. * @param direction The direction of the light in the scene
  109044. * @param angle The cone angle of the light in Radians
  109045. * @param exponent The light decay speed with the distance from the emission spot
  109046. * @param scene The scene the lights belongs to
  109047. */
  109048. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109049. /**
  109050. * Returns the string "SpotLight".
  109051. * @returns the class name
  109052. */
  109053. getClassName(): string;
  109054. /**
  109055. * Returns the integer 2.
  109056. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109057. */
  109058. getTypeID(): number;
  109059. /**
  109060. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109061. */
  109062. protected _setDirection(value: Vector3): void;
  109063. /**
  109064. * Overrides the position setter to recompute the projection texture view light Matrix.
  109065. */
  109066. protected _setPosition(value: Vector3): void;
  109067. /**
  109068. * 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.
  109069. * Returns the SpotLight.
  109070. */
  109071. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109072. protected _computeProjectionTextureViewLightMatrix(): void;
  109073. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109074. /**
  109075. * Main function for light texture projection matrix computing.
  109076. */
  109077. protected _computeProjectionTextureMatrix(): void;
  109078. protected _buildUniformLayout(): void;
  109079. private _computeAngleValues;
  109080. /**
  109081. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109082. * @param effect The effect to update
  109083. * @param lightIndex The index of the light in the effect to update
  109084. * @returns The spot light
  109085. */
  109086. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109087. /**
  109088. * Disposes the light and the associated resources.
  109089. */
  109090. dispose(): void;
  109091. /**
  109092. * Prepares the list of defines specific to the light type.
  109093. * @param defines the list of defines
  109094. * @param lightIndex defines the index of the light for the effect
  109095. */
  109096. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109097. }
  109098. }
  109099. declare module BABYLON {
  109100. /**
  109101. * Gizmo that enables viewing a light
  109102. */
  109103. export class LightGizmo extends Gizmo {
  109104. private _lightMesh;
  109105. private _material;
  109106. private cachedPosition;
  109107. private cachedForward;
  109108. /**
  109109. * Creates a LightGizmo
  109110. * @param gizmoLayer The utility layer the gizmo will be added to
  109111. */
  109112. constructor(gizmoLayer?: UtilityLayerRenderer);
  109113. private _light;
  109114. /**
  109115. * The light that the gizmo is attached to
  109116. */
  109117. light: Nullable<Light>;
  109118. /**
  109119. * Gets the material used to render the light gizmo
  109120. */
  109121. readonly material: StandardMaterial;
  109122. /**
  109123. * @hidden
  109124. * Updates the gizmo to match the attached mesh's position/rotation
  109125. */
  109126. protected _update(): void;
  109127. private static _Scale;
  109128. /**
  109129. * Creates the lines for a light mesh
  109130. */
  109131. private static _createLightLines;
  109132. /**
  109133. * Disposes of the light gizmo
  109134. */
  109135. dispose(): void;
  109136. private static _CreateHemisphericLightMesh;
  109137. private static _CreatePointLightMesh;
  109138. private static _CreateSpotLightMesh;
  109139. private static _CreateDirectionalLightMesh;
  109140. }
  109141. }
  109142. declare module BABYLON {
  109143. /** @hidden */
  109144. export var backgroundFragmentDeclaration: {
  109145. name: string;
  109146. shader: string;
  109147. };
  109148. }
  109149. declare module BABYLON {
  109150. /** @hidden */
  109151. export var backgroundUboDeclaration: {
  109152. name: string;
  109153. shader: string;
  109154. };
  109155. }
  109156. declare module BABYLON {
  109157. /** @hidden */
  109158. export var backgroundPixelShader: {
  109159. name: string;
  109160. shader: string;
  109161. };
  109162. }
  109163. declare module BABYLON {
  109164. /** @hidden */
  109165. export var backgroundVertexDeclaration: {
  109166. name: string;
  109167. shader: string;
  109168. };
  109169. }
  109170. declare module BABYLON {
  109171. /** @hidden */
  109172. export var backgroundVertexShader: {
  109173. name: string;
  109174. shader: string;
  109175. };
  109176. }
  109177. declare module BABYLON {
  109178. /**
  109179. * Background material used to create an efficient environement around your scene.
  109180. */
  109181. export class BackgroundMaterial extends PushMaterial {
  109182. /**
  109183. * Standard reflectance value at parallel view angle.
  109184. */
  109185. static StandardReflectance0: number;
  109186. /**
  109187. * Standard reflectance value at grazing angle.
  109188. */
  109189. static StandardReflectance90: number;
  109190. protected _primaryColor: Color3;
  109191. /**
  109192. * Key light Color (multiply against the environement texture)
  109193. */
  109194. primaryColor: Color3;
  109195. protected __perceptualColor: Nullable<Color3>;
  109196. /**
  109197. * Experimental Internal Use Only.
  109198. *
  109199. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109200. * This acts as a helper to set the primary color to a more "human friendly" value.
  109201. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109202. * output color as close as possible from the chosen value.
  109203. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109204. * part of lighting setup.)
  109205. */
  109206. _perceptualColor: Nullable<Color3>;
  109207. protected _primaryColorShadowLevel: float;
  109208. /**
  109209. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109210. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109211. */
  109212. primaryColorShadowLevel: float;
  109213. protected _primaryColorHighlightLevel: float;
  109214. /**
  109215. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109216. * The primary color is used at the level chosen to define what the white area would look.
  109217. */
  109218. primaryColorHighlightLevel: float;
  109219. protected _reflectionTexture: Nullable<BaseTexture>;
  109220. /**
  109221. * Reflection Texture used in the material.
  109222. * Should be author in a specific way for the best result (refer to the documentation).
  109223. */
  109224. reflectionTexture: Nullable<BaseTexture>;
  109225. protected _reflectionBlur: float;
  109226. /**
  109227. * Reflection Texture level of blur.
  109228. *
  109229. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109230. * texture twice.
  109231. */
  109232. reflectionBlur: float;
  109233. protected _diffuseTexture: Nullable<BaseTexture>;
  109234. /**
  109235. * Diffuse Texture used in the material.
  109236. * Should be author in a specific way for the best result (refer to the documentation).
  109237. */
  109238. diffuseTexture: Nullable<BaseTexture>;
  109239. protected _shadowLights: Nullable<IShadowLight[]>;
  109240. /**
  109241. * Specify the list of lights casting shadow on the material.
  109242. * All scene shadow lights will be included if null.
  109243. */
  109244. shadowLights: Nullable<IShadowLight[]>;
  109245. protected _shadowLevel: float;
  109246. /**
  109247. * Helps adjusting the shadow to a softer level if required.
  109248. * 0 means black shadows and 1 means no shadows.
  109249. */
  109250. shadowLevel: float;
  109251. protected _sceneCenter: Vector3;
  109252. /**
  109253. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109254. * It is usually zero but might be interesting to modify according to your setup.
  109255. */
  109256. sceneCenter: Vector3;
  109257. protected _opacityFresnel: boolean;
  109258. /**
  109259. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109260. * This helps ensuring a nice transition when the camera goes under the ground.
  109261. */
  109262. opacityFresnel: boolean;
  109263. protected _reflectionFresnel: boolean;
  109264. /**
  109265. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109266. * This helps adding a mirror texture on the ground.
  109267. */
  109268. reflectionFresnel: boolean;
  109269. protected _reflectionFalloffDistance: number;
  109270. /**
  109271. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109272. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109273. */
  109274. reflectionFalloffDistance: number;
  109275. protected _reflectionAmount: number;
  109276. /**
  109277. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109278. */
  109279. reflectionAmount: number;
  109280. protected _reflectionReflectance0: number;
  109281. /**
  109282. * This specifies the weight of the reflection at grazing angle.
  109283. */
  109284. reflectionReflectance0: number;
  109285. protected _reflectionReflectance90: number;
  109286. /**
  109287. * This specifies the weight of the reflection at a perpendicular point of view.
  109288. */
  109289. reflectionReflectance90: number;
  109290. /**
  109291. * Sets the reflection reflectance fresnel values according to the default standard
  109292. * empirically know to work well :-)
  109293. */
  109294. reflectionStandardFresnelWeight: number;
  109295. protected _useRGBColor: boolean;
  109296. /**
  109297. * Helps to directly use the maps channels instead of their level.
  109298. */
  109299. useRGBColor: boolean;
  109300. protected _enableNoise: boolean;
  109301. /**
  109302. * This helps reducing the banding effect that could occur on the background.
  109303. */
  109304. enableNoise: boolean;
  109305. /**
  109306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109307. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109308. * Recommended to be keep at 1.0 except for special cases.
  109309. */
  109310. fovMultiplier: number;
  109311. private _fovMultiplier;
  109312. /**
  109313. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109314. */
  109315. useEquirectangularFOV: boolean;
  109316. private _maxSimultaneousLights;
  109317. /**
  109318. * Number of Simultaneous lights allowed on the material.
  109319. */
  109320. maxSimultaneousLights: int;
  109321. /**
  109322. * Default configuration related to image processing available in the Background Material.
  109323. */
  109324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109325. /**
  109326. * Keep track of the image processing observer to allow dispose and replace.
  109327. */
  109328. private _imageProcessingObserver;
  109329. /**
  109330. * Attaches a new image processing configuration to the PBR Material.
  109331. * @param configuration (if null the scene configuration will be use)
  109332. */
  109333. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109334. /**
  109335. * Gets the image processing configuration used either in this material.
  109336. */
  109337. /**
  109338. * Sets the Default image processing configuration used either in the this material.
  109339. *
  109340. * If sets to null, the scene one is in use.
  109341. */
  109342. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109343. /**
  109344. * Gets wether the color curves effect is enabled.
  109345. */
  109346. /**
  109347. * Sets wether the color curves effect is enabled.
  109348. */
  109349. cameraColorCurvesEnabled: boolean;
  109350. /**
  109351. * Gets wether the color grading effect is enabled.
  109352. */
  109353. /**
  109354. * Gets wether the color grading effect is enabled.
  109355. */
  109356. cameraColorGradingEnabled: boolean;
  109357. /**
  109358. * Gets wether tonemapping is enabled or not.
  109359. */
  109360. /**
  109361. * Sets wether tonemapping is enabled or not
  109362. */
  109363. cameraToneMappingEnabled: boolean;
  109364. /**
  109365. * The camera exposure used on this material.
  109366. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109367. * This corresponds to a photographic exposure.
  109368. */
  109369. /**
  109370. * The camera exposure used on this material.
  109371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109372. * This corresponds to a photographic exposure.
  109373. */
  109374. cameraExposure: float;
  109375. /**
  109376. * Gets The camera contrast used on this material.
  109377. */
  109378. /**
  109379. * Sets The camera contrast used on this material.
  109380. */
  109381. cameraContrast: float;
  109382. /**
  109383. * Gets the Color Grading 2D Lookup Texture.
  109384. */
  109385. /**
  109386. * Sets the Color Grading 2D Lookup Texture.
  109387. */
  109388. cameraColorGradingTexture: Nullable<BaseTexture>;
  109389. /**
  109390. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109391. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109392. * 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;
  109393. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109394. */
  109395. /**
  109396. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109397. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109398. * 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;
  109399. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109400. */
  109401. cameraColorCurves: Nullable<ColorCurves>;
  109402. /**
  109403. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109404. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109405. */
  109406. switchToBGR: boolean;
  109407. private _renderTargets;
  109408. private _reflectionControls;
  109409. private _white;
  109410. private _primaryShadowColor;
  109411. private _primaryHighlightColor;
  109412. /**
  109413. * Instantiates a Background Material in the given scene
  109414. * @param name The friendly name of the material
  109415. * @param scene The scene to add the material to
  109416. */
  109417. constructor(name: string, scene: Scene);
  109418. /**
  109419. * Gets a boolean indicating that current material needs to register RTT
  109420. */
  109421. readonly hasRenderTargetTextures: boolean;
  109422. /**
  109423. * The entire material has been created in order to prevent overdraw.
  109424. * @returns false
  109425. */
  109426. needAlphaTesting(): boolean;
  109427. /**
  109428. * The entire material has been created in order to prevent overdraw.
  109429. * @returns true if blending is enable
  109430. */
  109431. needAlphaBlending(): boolean;
  109432. /**
  109433. * Checks wether the material is ready to be rendered for a given mesh.
  109434. * @param mesh The mesh to render
  109435. * @param subMesh The submesh to check against
  109436. * @param useInstances Specify wether or not the material is used with instances
  109437. * @returns true if all the dependencies are ready (Textures, Effects...)
  109438. */
  109439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109440. /**
  109441. * Compute the primary color according to the chosen perceptual color.
  109442. */
  109443. private _computePrimaryColorFromPerceptualColor;
  109444. /**
  109445. * Compute the highlights and shadow colors according to their chosen levels.
  109446. */
  109447. private _computePrimaryColors;
  109448. /**
  109449. * Build the uniform buffer used in the material.
  109450. */
  109451. buildUniformLayout(): void;
  109452. /**
  109453. * Unbind the material.
  109454. */
  109455. unbind(): void;
  109456. /**
  109457. * Bind only the world matrix to the material.
  109458. * @param world The world matrix to bind.
  109459. */
  109460. bindOnlyWorldMatrix(world: Matrix): void;
  109461. /**
  109462. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109463. * @param world The world matrix to bind.
  109464. * @param subMesh The submesh to bind for.
  109465. */
  109466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109467. /**
  109468. * Dispose the material.
  109469. * @param forceDisposeEffect Force disposal of the associated effect.
  109470. * @param forceDisposeTextures Force disposal of the associated textures.
  109471. */
  109472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109473. /**
  109474. * Clones the material.
  109475. * @param name The cloned name.
  109476. * @returns The cloned material.
  109477. */
  109478. clone(name: string): BackgroundMaterial;
  109479. /**
  109480. * Serializes the current material to its JSON representation.
  109481. * @returns The JSON representation.
  109482. */
  109483. serialize(): any;
  109484. /**
  109485. * Gets the class name of the material
  109486. * @returns "BackgroundMaterial"
  109487. */
  109488. getClassName(): string;
  109489. /**
  109490. * Parse a JSON input to create back a background material.
  109491. * @param source The JSON data to parse
  109492. * @param scene The scene to create the parsed material in
  109493. * @param rootUrl The root url of the assets the material depends upon
  109494. * @returns the instantiated BackgroundMaterial.
  109495. */
  109496. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109497. }
  109498. }
  109499. declare module BABYLON {
  109500. /**
  109501. * Represents the different options available during the creation of
  109502. * a Environment helper.
  109503. *
  109504. * This can control the default ground, skybox and image processing setup of your scene.
  109505. */
  109506. export interface IEnvironmentHelperOptions {
  109507. /**
  109508. * Specifies wether or not to create a ground.
  109509. * True by default.
  109510. */
  109511. createGround: boolean;
  109512. /**
  109513. * Specifies the ground size.
  109514. * 15 by default.
  109515. */
  109516. groundSize: number;
  109517. /**
  109518. * The texture used on the ground for the main color.
  109519. * Comes from the BabylonJS CDN by default.
  109520. *
  109521. * Remarks: Can be either a texture or a url.
  109522. */
  109523. groundTexture: string | BaseTexture;
  109524. /**
  109525. * The color mixed in the ground texture by default.
  109526. * BabylonJS clearColor by default.
  109527. */
  109528. groundColor: Color3;
  109529. /**
  109530. * Specifies the ground opacity.
  109531. * 1 by default.
  109532. */
  109533. groundOpacity: number;
  109534. /**
  109535. * Enables the ground to receive shadows.
  109536. * True by default.
  109537. */
  109538. enableGroundShadow: boolean;
  109539. /**
  109540. * Helps preventing the shadow to be fully black on the ground.
  109541. * 0.5 by default.
  109542. */
  109543. groundShadowLevel: number;
  109544. /**
  109545. * Creates a mirror texture attach to the ground.
  109546. * false by default.
  109547. */
  109548. enableGroundMirror: boolean;
  109549. /**
  109550. * Specifies the ground mirror size ratio.
  109551. * 0.3 by default as the default kernel is 64.
  109552. */
  109553. groundMirrorSizeRatio: number;
  109554. /**
  109555. * Specifies the ground mirror blur kernel size.
  109556. * 64 by default.
  109557. */
  109558. groundMirrorBlurKernel: number;
  109559. /**
  109560. * Specifies the ground mirror visibility amount.
  109561. * 1 by default
  109562. */
  109563. groundMirrorAmount: number;
  109564. /**
  109565. * Specifies the ground mirror reflectance weight.
  109566. * This uses the standard weight of the background material to setup the fresnel effect
  109567. * of the mirror.
  109568. * 1 by default.
  109569. */
  109570. groundMirrorFresnelWeight: number;
  109571. /**
  109572. * Specifies the ground mirror Falloff distance.
  109573. * This can helps reducing the size of the reflection.
  109574. * 0 by Default.
  109575. */
  109576. groundMirrorFallOffDistance: number;
  109577. /**
  109578. * Specifies the ground mirror texture type.
  109579. * Unsigned Int by Default.
  109580. */
  109581. groundMirrorTextureType: number;
  109582. /**
  109583. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109584. * the shown objects.
  109585. */
  109586. groundYBias: number;
  109587. /**
  109588. * Specifies wether or not to create a skybox.
  109589. * True by default.
  109590. */
  109591. createSkybox: boolean;
  109592. /**
  109593. * Specifies the skybox size.
  109594. * 20 by default.
  109595. */
  109596. skyboxSize: number;
  109597. /**
  109598. * The texture used on the skybox for the main color.
  109599. * Comes from the BabylonJS CDN by default.
  109600. *
  109601. * Remarks: Can be either a texture or a url.
  109602. */
  109603. skyboxTexture: string | BaseTexture;
  109604. /**
  109605. * The color mixed in the skybox texture by default.
  109606. * BabylonJS clearColor by default.
  109607. */
  109608. skyboxColor: Color3;
  109609. /**
  109610. * The background rotation around the Y axis of the scene.
  109611. * This helps aligning the key lights of your scene with the background.
  109612. * 0 by default.
  109613. */
  109614. backgroundYRotation: number;
  109615. /**
  109616. * Compute automatically the size of the elements to best fit with the scene.
  109617. */
  109618. sizeAuto: boolean;
  109619. /**
  109620. * Default position of the rootMesh if autoSize is not true.
  109621. */
  109622. rootPosition: Vector3;
  109623. /**
  109624. * Sets up the image processing in the scene.
  109625. * true by default.
  109626. */
  109627. setupImageProcessing: boolean;
  109628. /**
  109629. * The texture used as your environment texture in the scene.
  109630. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109631. *
  109632. * Remarks: Can be either a texture or a url.
  109633. */
  109634. environmentTexture: string | BaseTexture;
  109635. /**
  109636. * The value of the exposure to apply to the scene.
  109637. * 0.6 by default if setupImageProcessing is true.
  109638. */
  109639. cameraExposure: number;
  109640. /**
  109641. * The value of the contrast to apply to the scene.
  109642. * 1.6 by default if setupImageProcessing is true.
  109643. */
  109644. cameraContrast: number;
  109645. /**
  109646. * Specifies wether or not tonemapping should be enabled in the scene.
  109647. * true by default if setupImageProcessing is true.
  109648. */
  109649. toneMappingEnabled: boolean;
  109650. }
  109651. /**
  109652. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109653. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109654. * It also helps with the default setup of your imageProcessing configuration.
  109655. */
  109656. export class EnvironmentHelper {
  109657. /**
  109658. * Default ground texture URL.
  109659. */
  109660. private static _groundTextureCDNUrl;
  109661. /**
  109662. * Default skybox texture URL.
  109663. */
  109664. private static _skyboxTextureCDNUrl;
  109665. /**
  109666. * Default environment texture URL.
  109667. */
  109668. private static _environmentTextureCDNUrl;
  109669. /**
  109670. * Creates the default options for the helper.
  109671. */
  109672. private static _getDefaultOptions;
  109673. private _rootMesh;
  109674. /**
  109675. * Gets the root mesh created by the helper.
  109676. */
  109677. readonly rootMesh: Mesh;
  109678. private _skybox;
  109679. /**
  109680. * Gets the skybox created by the helper.
  109681. */
  109682. readonly skybox: Nullable<Mesh>;
  109683. private _skyboxTexture;
  109684. /**
  109685. * Gets the skybox texture created by the helper.
  109686. */
  109687. readonly skyboxTexture: Nullable<BaseTexture>;
  109688. private _skyboxMaterial;
  109689. /**
  109690. * Gets the skybox material created by the helper.
  109691. */
  109692. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109693. private _ground;
  109694. /**
  109695. * Gets the ground mesh created by the helper.
  109696. */
  109697. readonly ground: Nullable<Mesh>;
  109698. private _groundTexture;
  109699. /**
  109700. * Gets the ground texture created by the helper.
  109701. */
  109702. readonly groundTexture: Nullable<BaseTexture>;
  109703. private _groundMirror;
  109704. /**
  109705. * Gets the ground mirror created by the helper.
  109706. */
  109707. readonly groundMirror: Nullable<MirrorTexture>;
  109708. /**
  109709. * Gets the ground mirror render list to helps pushing the meshes
  109710. * you wish in the ground reflection.
  109711. */
  109712. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109713. private _groundMaterial;
  109714. /**
  109715. * Gets the ground material created by the helper.
  109716. */
  109717. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109718. /**
  109719. * Stores the creation options.
  109720. */
  109721. private readonly _scene;
  109722. private _options;
  109723. /**
  109724. * This observable will be notified with any error during the creation of the environment,
  109725. * mainly texture creation errors.
  109726. */
  109727. onErrorObservable: Observable<{
  109728. message?: string;
  109729. exception?: any;
  109730. }>;
  109731. /**
  109732. * constructor
  109733. * @param options Defines the options we want to customize the helper
  109734. * @param scene The scene to add the material to
  109735. */
  109736. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109737. /**
  109738. * Updates the background according to the new options
  109739. * @param options
  109740. */
  109741. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109742. /**
  109743. * Sets the primary color of all the available elements.
  109744. * @param color the main color to affect to the ground and the background
  109745. */
  109746. setMainColor(color: Color3): void;
  109747. /**
  109748. * Setup the image processing according to the specified options.
  109749. */
  109750. private _setupImageProcessing;
  109751. /**
  109752. * Setup the environment texture according to the specified options.
  109753. */
  109754. private _setupEnvironmentTexture;
  109755. /**
  109756. * Setup the background according to the specified options.
  109757. */
  109758. private _setupBackground;
  109759. /**
  109760. * Get the scene sizes according to the setup.
  109761. */
  109762. private _getSceneSize;
  109763. /**
  109764. * Setup the ground according to the specified options.
  109765. */
  109766. private _setupGround;
  109767. /**
  109768. * Setup the ground material according to the specified options.
  109769. */
  109770. private _setupGroundMaterial;
  109771. /**
  109772. * Setup the ground diffuse texture according to the specified options.
  109773. */
  109774. private _setupGroundDiffuseTexture;
  109775. /**
  109776. * Setup the ground mirror texture according to the specified options.
  109777. */
  109778. private _setupGroundMirrorTexture;
  109779. /**
  109780. * Setup the ground to receive the mirror texture.
  109781. */
  109782. private _setupMirrorInGroundMaterial;
  109783. /**
  109784. * Setup the skybox according to the specified options.
  109785. */
  109786. private _setupSkybox;
  109787. /**
  109788. * Setup the skybox material according to the specified options.
  109789. */
  109790. private _setupSkyboxMaterial;
  109791. /**
  109792. * Setup the skybox reflection texture according to the specified options.
  109793. */
  109794. private _setupSkyboxReflectionTexture;
  109795. private _errorHandler;
  109796. /**
  109797. * Dispose all the elements created by the Helper.
  109798. */
  109799. dispose(): void;
  109800. }
  109801. }
  109802. declare module BABYLON {
  109803. /**
  109804. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109805. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109806. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109807. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109808. */
  109809. export class PhotoDome extends TransformNode {
  109810. /**
  109811. * Define the image as a Monoscopic panoramic 360 image.
  109812. */
  109813. static readonly MODE_MONOSCOPIC: number;
  109814. /**
  109815. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109816. */
  109817. static readonly MODE_TOPBOTTOM: number;
  109818. /**
  109819. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109820. */
  109821. static readonly MODE_SIDEBYSIDE: number;
  109822. private _useDirectMapping;
  109823. /**
  109824. * The texture being displayed on the sphere
  109825. */
  109826. protected _photoTexture: Texture;
  109827. /**
  109828. * Gets or sets the texture being displayed on the sphere
  109829. */
  109830. photoTexture: Texture;
  109831. /**
  109832. * Observable raised when an error occured while loading the 360 image
  109833. */
  109834. onLoadErrorObservable: Observable<string>;
  109835. /**
  109836. * The skybox material
  109837. */
  109838. protected _material: BackgroundMaterial;
  109839. /**
  109840. * The surface used for the skybox
  109841. */
  109842. protected _mesh: Mesh;
  109843. /**
  109844. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109845. * Also see the options.resolution property.
  109846. */
  109847. fovMultiplier: number;
  109848. private _imageMode;
  109849. /**
  109850. * Gets or set the current video mode for the video. It can be:
  109851. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109852. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109853. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109854. */
  109855. imageMode: number;
  109856. /**
  109857. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109858. * @param name Element's name, child elements will append suffixes for their own names.
  109859. * @param urlsOfPhoto defines the url of the photo to display
  109860. * @param options defines an object containing optional or exposed sub element properties
  109861. * @param onError defines a callback called when an error occured while loading the texture
  109862. */
  109863. constructor(name: string, urlOfPhoto: string, options: {
  109864. resolution?: number;
  109865. size?: number;
  109866. useDirectMapping?: boolean;
  109867. faceForward?: boolean;
  109868. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109869. private _onBeforeCameraRenderObserver;
  109870. private _changeImageMode;
  109871. /**
  109872. * Releases resources associated with this node.
  109873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109875. */
  109876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109877. }
  109878. }
  109879. declare module BABYLON {
  109880. /** @hidden */
  109881. export var rgbdDecodePixelShader: {
  109882. name: string;
  109883. shader: string;
  109884. };
  109885. }
  109886. declare module BABYLON {
  109887. /**
  109888. * Class used to host texture specific utilities
  109889. */
  109890. export class BRDFTextureTools {
  109891. /**
  109892. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109893. * @param texture the texture to expand.
  109894. */
  109895. private static _ExpandDefaultBRDFTexture;
  109896. /**
  109897. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109898. * @param scene defines the hosting scene
  109899. * @returns the environment BRDF texture
  109900. */
  109901. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109902. private static _environmentBRDFBase64Texture;
  109903. }
  109904. }
  109905. declare module BABYLON {
  109906. /**
  109907. * @hidden
  109908. */
  109909. export interface IMaterialClearCoatDefines {
  109910. CLEARCOAT: boolean;
  109911. CLEARCOAT_DEFAULTIOR: boolean;
  109912. CLEARCOAT_TEXTURE: boolean;
  109913. CLEARCOAT_TEXTUREDIRECTUV: number;
  109914. CLEARCOAT_BUMP: boolean;
  109915. CLEARCOAT_BUMPDIRECTUV: number;
  109916. CLEARCOAT_TINT: boolean;
  109917. CLEARCOAT_TINT_TEXTURE: boolean;
  109918. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109919. /** @hidden */
  109920. _areTexturesDirty: boolean;
  109921. }
  109922. /**
  109923. * Define the code related to the clear coat parameters of the pbr material.
  109924. */
  109925. export class PBRClearCoatConfiguration {
  109926. /**
  109927. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109928. * The default fits with a polyurethane material.
  109929. */
  109930. private static readonly _DefaultIndexOfRefraction;
  109931. private _isEnabled;
  109932. /**
  109933. * Defines if the clear coat is enabled in the material.
  109934. */
  109935. isEnabled: boolean;
  109936. /**
  109937. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109938. */
  109939. intensity: number;
  109940. /**
  109941. * Defines the clear coat layer roughness.
  109942. */
  109943. roughness: number;
  109944. private _indexOfRefraction;
  109945. /**
  109946. * Defines the index of refraction of the clear coat.
  109947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109948. * The default fits with a polyurethane material.
  109949. * Changing the default value is more performance intensive.
  109950. */
  109951. indexOfRefraction: number;
  109952. private _texture;
  109953. /**
  109954. * Stores the clear coat values in a texture.
  109955. */
  109956. texture: Nullable<BaseTexture>;
  109957. private _bumpTexture;
  109958. /**
  109959. * Define the clear coat specific bump texture.
  109960. */
  109961. bumpTexture: Nullable<BaseTexture>;
  109962. private _isTintEnabled;
  109963. /**
  109964. * Defines if the clear coat tint is enabled in the material.
  109965. */
  109966. isTintEnabled: boolean;
  109967. /**
  109968. * Defines the clear coat tint of the material.
  109969. * This is only use if tint is enabled
  109970. */
  109971. tintColor: Color3;
  109972. /**
  109973. * Defines the distance at which the tint color should be found in the
  109974. * clear coat media.
  109975. * This is only use if tint is enabled
  109976. */
  109977. tintColorAtDistance: number;
  109978. /**
  109979. * Defines the clear coat layer thickness.
  109980. * This is only use if tint is enabled
  109981. */
  109982. tintThickness: number;
  109983. private _tintTexture;
  109984. /**
  109985. * Stores the clear tint values in a texture.
  109986. * rgb is tint
  109987. * a is a thickness factor
  109988. */
  109989. tintTexture: Nullable<BaseTexture>;
  109990. /** @hidden */
  109991. private _internalMarkAllSubMeshesAsTexturesDirty;
  109992. /** @hidden */
  109993. _markAllSubMeshesAsTexturesDirty(): void;
  109994. /**
  109995. * Instantiate a new istance of clear coat configuration.
  109996. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109997. */
  109998. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109999. /**
  110000. * Gets wehter the submesh is ready to be used or not.
  110001. * @param defines the list of "defines" to update.
  110002. * @param scene defines the scene the material belongs to.
  110003. * @param engine defines the engine the material belongs to.
  110004. * @param disableBumpMap defines wether the material disables bump or not.
  110005. * @returns - boolean indicating that the submesh is ready or not.
  110006. */
  110007. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110008. /**
  110009. * Checks to see if a texture is used in the material.
  110010. * @param defines the list of "defines" to update.
  110011. * @param scene defines the scene to the material belongs to.
  110012. */
  110013. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110014. /**
  110015. * Binds the material data.
  110016. * @param uniformBuffer defines the Uniform buffer to fill in.
  110017. * @param scene defines the scene the material belongs to.
  110018. * @param engine defines the engine the material belongs to.
  110019. * @param disableBumpMap defines wether the material disables bump or not.
  110020. * @param isFrozen defines wether the material is frozen or not.
  110021. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110022. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110023. */
  110024. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110025. /**
  110026. * Checks to see if a texture is used in the material.
  110027. * @param texture - Base texture to use.
  110028. * @returns - Boolean specifying if a texture is used in the material.
  110029. */
  110030. hasTexture(texture: BaseTexture): boolean;
  110031. /**
  110032. * Returns an array of the actively used textures.
  110033. * @param activeTextures Array of BaseTextures
  110034. */
  110035. getActiveTextures(activeTextures: BaseTexture[]): void;
  110036. /**
  110037. * Returns the animatable textures.
  110038. * @param animatables Array of animatable textures.
  110039. */
  110040. getAnimatables(animatables: IAnimatable[]): void;
  110041. /**
  110042. * Disposes the resources of the material.
  110043. * @param forceDisposeTextures - Forces the disposal of all textures.
  110044. */
  110045. dispose(forceDisposeTextures?: boolean): void;
  110046. /**
  110047. * Get the current class name of the texture useful for serialization or dynamic coding.
  110048. * @returns "PBRClearCoatConfiguration"
  110049. */
  110050. getClassName(): string;
  110051. /**
  110052. * Add fallbacks to the effect fallbacks list.
  110053. * @param defines defines the Base texture to use.
  110054. * @param fallbacks defines the current fallback list.
  110055. * @param currentRank defines the current fallback rank.
  110056. * @returns the new fallback rank.
  110057. */
  110058. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110059. /**
  110060. * Add the required uniforms to the current list.
  110061. * @param uniforms defines the current uniform list.
  110062. */
  110063. static AddUniforms(uniforms: string[]): void;
  110064. /**
  110065. * Add the required samplers to the current list.
  110066. * @param samplers defines the current sampler list.
  110067. */
  110068. static AddSamplers(samplers: string[]): void;
  110069. /**
  110070. * Add the required uniforms to the current buffer.
  110071. * @param uniformBuffer defines the current uniform buffer.
  110072. */
  110073. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110074. /**
  110075. * Makes a duplicate of the current configuration into another one.
  110076. * @param clearCoatConfiguration define the config where to copy the info
  110077. */
  110078. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110079. /**
  110080. * Serializes this clear coat configuration.
  110081. * @returns - An object with the serialized config.
  110082. */
  110083. serialize(): any;
  110084. /**
  110085. * Parses a anisotropy Configuration from a serialized object.
  110086. * @param source - Serialized object.
  110087. * @param scene Defines the scene we are parsing for
  110088. * @param rootUrl Defines the rootUrl to load from
  110089. */
  110090. parse(source: any, scene: Scene, rootUrl: string): void;
  110091. }
  110092. }
  110093. declare module BABYLON {
  110094. /**
  110095. * @hidden
  110096. */
  110097. export interface IMaterialAnisotropicDefines {
  110098. ANISOTROPIC: boolean;
  110099. ANISOTROPIC_TEXTURE: boolean;
  110100. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110101. MAINUV1: boolean;
  110102. _areTexturesDirty: boolean;
  110103. _needUVs: boolean;
  110104. }
  110105. /**
  110106. * Define the code related to the anisotropic parameters of the pbr material.
  110107. */
  110108. export class PBRAnisotropicConfiguration {
  110109. private _isEnabled;
  110110. /**
  110111. * Defines if the anisotropy is enabled in the material.
  110112. */
  110113. isEnabled: boolean;
  110114. /**
  110115. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110116. */
  110117. intensity: number;
  110118. /**
  110119. * Defines if the effect is along the tangents, bitangents or in between.
  110120. * By default, the effect is "strectching" the highlights along the tangents.
  110121. */
  110122. direction: Vector2;
  110123. private _texture;
  110124. /**
  110125. * Stores the anisotropy values in a texture.
  110126. * rg is direction (like normal from -1 to 1)
  110127. * b is a intensity
  110128. */
  110129. texture: Nullable<BaseTexture>;
  110130. /** @hidden */
  110131. private _internalMarkAllSubMeshesAsTexturesDirty;
  110132. /** @hidden */
  110133. _markAllSubMeshesAsTexturesDirty(): void;
  110134. /**
  110135. * Instantiate a new istance of anisotropy configuration.
  110136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110137. */
  110138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110139. /**
  110140. * Specifies that the submesh is ready to be used.
  110141. * @param defines the list of "defines" to update.
  110142. * @param scene defines the scene the material belongs to.
  110143. * @returns - boolean indicating that the submesh is ready or not.
  110144. */
  110145. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110146. /**
  110147. * Checks to see if a texture is used in the material.
  110148. * @param defines the list of "defines" to update.
  110149. * @param mesh the mesh we are preparing the defines for.
  110150. * @param scene defines the scene the material belongs to.
  110151. */
  110152. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110153. /**
  110154. * Binds the material data.
  110155. * @param uniformBuffer defines the Uniform buffer to fill in.
  110156. * @param scene defines the scene the material belongs to.
  110157. * @param isFrozen defines wether the material is frozen or not.
  110158. */
  110159. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110160. /**
  110161. * Checks to see if a texture is used in the material.
  110162. * @param texture - Base texture to use.
  110163. * @returns - Boolean specifying if a texture is used in the material.
  110164. */
  110165. hasTexture(texture: BaseTexture): boolean;
  110166. /**
  110167. * Returns an array of the actively used textures.
  110168. * @param activeTextures Array of BaseTextures
  110169. */
  110170. getActiveTextures(activeTextures: BaseTexture[]): void;
  110171. /**
  110172. * Returns the animatable textures.
  110173. * @param animatables Array of animatable textures.
  110174. */
  110175. getAnimatables(animatables: IAnimatable[]): void;
  110176. /**
  110177. * Disposes the resources of the material.
  110178. * @param forceDisposeTextures - Forces the disposal of all textures.
  110179. */
  110180. dispose(forceDisposeTextures?: boolean): void;
  110181. /**
  110182. * Get the current class name of the texture useful for serialization or dynamic coding.
  110183. * @returns "PBRAnisotropicConfiguration"
  110184. */
  110185. getClassName(): string;
  110186. /**
  110187. * Add fallbacks to the effect fallbacks list.
  110188. * @param defines defines the Base texture to use.
  110189. * @param fallbacks defines the current fallback list.
  110190. * @param currentRank defines the current fallback rank.
  110191. * @returns the new fallback rank.
  110192. */
  110193. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110194. /**
  110195. * Add the required uniforms to the current list.
  110196. * @param uniforms defines the current uniform list.
  110197. */
  110198. static AddUniforms(uniforms: string[]): void;
  110199. /**
  110200. * Add the required uniforms to the current buffer.
  110201. * @param uniformBuffer defines the current uniform buffer.
  110202. */
  110203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110204. /**
  110205. * Add the required samplers to the current list.
  110206. * @param samplers defines the current sampler list.
  110207. */
  110208. static AddSamplers(samplers: string[]): void;
  110209. /**
  110210. * Makes a duplicate of the current configuration into another one.
  110211. * @param anisotropicConfiguration define the config where to copy the info
  110212. */
  110213. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110214. /**
  110215. * Serializes this anisotropy configuration.
  110216. * @returns - An object with the serialized config.
  110217. */
  110218. serialize(): any;
  110219. /**
  110220. * Parses a anisotropy Configuration from a serialized object.
  110221. * @param source - Serialized object.
  110222. * @param scene Defines the scene we are parsing for
  110223. * @param rootUrl Defines the rootUrl to load from
  110224. */
  110225. parse(source: any, scene: Scene, rootUrl: string): void;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * @hidden
  110231. */
  110232. export interface IMaterialBRDFDefines {
  110233. BRDF_V_HEIGHT_CORRELATED: boolean;
  110234. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110235. SPHERICAL_HARMONICS: boolean;
  110236. /** @hidden */
  110237. _areMiscDirty: boolean;
  110238. }
  110239. /**
  110240. * Define the code related to the BRDF parameters of the pbr material.
  110241. */
  110242. export class PBRBRDFConfiguration {
  110243. /**
  110244. * Default value used for the energy conservation.
  110245. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110246. */
  110247. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110248. /**
  110249. * Default value used for the Smith Visibility Height Correlated mode.
  110250. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110251. */
  110252. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110253. /**
  110254. * Default value used for the IBL diffuse part.
  110255. * This can help switching back to the polynomials mode globally which is a tiny bit
  110256. * less GPU intensive at the drawback of a lower quality.
  110257. */
  110258. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110259. private _useEnergyConservation;
  110260. /**
  110261. * Defines if the material uses energy conservation.
  110262. */
  110263. useEnergyConservation: boolean;
  110264. private _useSmithVisibilityHeightCorrelated;
  110265. /**
  110266. * LEGACY Mode set to false
  110267. * Defines if the material uses height smith correlated visibility term.
  110268. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110269. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110270. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110271. * Not relying on height correlated will also disable energy conservation.
  110272. */
  110273. useSmithVisibilityHeightCorrelated: boolean;
  110274. private _useSphericalHarmonics;
  110275. /**
  110276. * LEGACY Mode set to false
  110277. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110278. * diffuse part of the IBL.
  110279. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110280. * to the ground truth.
  110281. */
  110282. useSphericalHarmonics: boolean;
  110283. /** @hidden */
  110284. private _internalMarkAllSubMeshesAsMiscDirty;
  110285. /** @hidden */
  110286. _markAllSubMeshesAsMiscDirty(): void;
  110287. /**
  110288. * Instantiate a new istance of clear coat configuration.
  110289. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110290. */
  110291. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110292. /**
  110293. * Checks to see if a texture is used in the material.
  110294. * @param defines the list of "defines" to update.
  110295. */
  110296. prepareDefines(defines: IMaterialBRDFDefines): void;
  110297. /**
  110298. * Get the current class name of the texture useful for serialization or dynamic coding.
  110299. * @returns "PBRClearCoatConfiguration"
  110300. */
  110301. getClassName(): string;
  110302. /**
  110303. * Makes a duplicate of the current configuration into another one.
  110304. * @param brdfConfiguration define the config where to copy the info
  110305. */
  110306. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110307. /**
  110308. * Serializes this BRDF configuration.
  110309. * @returns - An object with the serialized config.
  110310. */
  110311. serialize(): any;
  110312. /**
  110313. * Parses a anisotropy Configuration from a serialized object.
  110314. * @param source - Serialized object.
  110315. * @param scene Defines the scene we are parsing for
  110316. * @param rootUrl Defines the rootUrl to load from
  110317. */
  110318. parse(source: any, scene: Scene, rootUrl: string): void;
  110319. }
  110320. }
  110321. declare module BABYLON {
  110322. /**
  110323. * @hidden
  110324. */
  110325. export interface IMaterialSheenDefines {
  110326. SHEEN: boolean;
  110327. SHEEN_TEXTURE: boolean;
  110328. SHEEN_TEXTUREDIRECTUV: number;
  110329. SHEEN_LINKWITHALBEDO: boolean;
  110330. /** @hidden */
  110331. _areTexturesDirty: boolean;
  110332. }
  110333. /**
  110334. * Define the code related to the Sheen parameters of the pbr material.
  110335. */
  110336. export class PBRSheenConfiguration {
  110337. private _isEnabled;
  110338. /**
  110339. * Defines if the material uses sheen.
  110340. */
  110341. isEnabled: boolean;
  110342. private _linkSheenWithAlbedo;
  110343. /**
  110344. * Defines if the sheen is linked to the sheen color.
  110345. */
  110346. linkSheenWithAlbedo: boolean;
  110347. /**
  110348. * Defines the sheen intensity.
  110349. */
  110350. intensity: number;
  110351. /**
  110352. * Defines the sheen color.
  110353. */
  110354. color: Color3;
  110355. private _texture;
  110356. /**
  110357. * Stores the sheen tint values in a texture.
  110358. * rgb is tint
  110359. * a is a intensity
  110360. */
  110361. texture: Nullable<BaseTexture>;
  110362. /** @hidden */
  110363. private _internalMarkAllSubMeshesAsTexturesDirty;
  110364. /** @hidden */
  110365. _markAllSubMeshesAsTexturesDirty(): void;
  110366. /**
  110367. * Instantiate a new istance of clear coat configuration.
  110368. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110369. */
  110370. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110371. /**
  110372. * Specifies that the submesh is ready to be used.
  110373. * @param defines the list of "defines" to update.
  110374. * @param scene defines the scene the material belongs to.
  110375. * @returns - boolean indicating that the submesh is ready or not.
  110376. */
  110377. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110378. /**
  110379. * Checks to see if a texture is used in the material.
  110380. * @param defines the list of "defines" to update.
  110381. * @param scene defines the scene the material belongs to.
  110382. */
  110383. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110384. /**
  110385. * Binds the material data.
  110386. * @param uniformBuffer defines the Uniform buffer to fill in.
  110387. * @param scene defines the scene the material belongs to.
  110388. * @param isFrozen defines wether the material is frozen or not.
  110389. */
  110390. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110391. /**
  110392. * Checks to see if a texture is used in the material.
  110393. * @param texture - Base texture to use.
  110394. * @returns - Boolean specifying if a texture is used in the material.
  110395. */
  110396. hasTexture(texture: BaseTexture): boolean;
  110397. /**
  110398. * Returns an array of the actively used textures.
  110399. * @param activeTextures Array of BaseTextures
  110400. */
  110401. getActiveTextures(activeTextures: BaseTexture[]): void;
  110402. /**
  110403. * Returns the animatable textures.
  110404. * @param animatables Array of animatable textures.
  110405. */
  110406. getAnimatables(animatables: IAnimatable[]): void;
  110407. /**
  110408. * Disposes the resources of the material.
  110409. * @param forceDisposeTextures - Forces the disposal of all textures.
  110410. */
  110411. dispose(forceDisposeTextures?: boolean): void;
  110412. /**
  110413. * Get the current class name of the texture useful for serialization or dynamic coding.
  110414. * @returns "PBRSheenConfiguration"
  110415. */
  110416. getClassName(): string;
  110417. /**
  110418. * Add fallbacks to the effect fallbacks list.
  110419. * @param defines defines the Base texture to use.
  110420. * @param fallbacks defines the current fallback list.
  110421. * @param currentRank defines the current fallback rank.
  110422. * @returns the new fallback rank.
  110423. */
  110424. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110425. /**
  110426. * Add the required uniforms to the current list.
  110427. * @param uniforms defines the current uniform list.
  110428. */
  110429. static AddUniforms(uniforms: string[]): void;
  110430. /**
  110431. * Add the required uniforms to the current buffer.
  110432. * @param uniformBuffer defines the current uniform buffer.
  110433. */
  110434. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110435. /**
  110436. * Add the required samplers to the current list.
  110437. * @param samplers defines the current sampler list.
  110438. */
  110439. static AddSamplers(samplers: string[]): void;
  110440. /**
  110441. * Makes a duplicate of the current configuration into another one.
  110442. * @param sheenConfiguration define the config where to copy the info
  110443. */
  110444. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110445. /**
  110446. * Serializes this BRDF configuration.
  110447. * @returns - An object with the serialized config.
  110448. */
  110449. serialize(): any;
  110450. /**
  110451. * Parses a anisotropy Configuration from a serialized object.
  110452. * @param source - Serialized object.
  110453. * @param scene Defines the scene we are parsing for
  110454. * @param rootUrl Defines the rootUrl to load from
  110455. */
  110456. parse(source: any, scene: Scene, rootUrl: string): void;
  110457. }
  110458. }
  110459. declare module BABYLON {
  110460. /**
  110461. * @hidden
  110462. */
  110463. export interface IMaterialSubSurfaceDefines {
  110464. SUBSURFACE: boolean;
  110465. SS_REFRACTION: boolean;
  110466. SS_TRANSLUCENCY: boolean;
  110467. SS_SCATERRING: boolean;
  110468. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110469. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110470. SS_REFRACTIONMAP_3D: boolean;
  110471. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110472. SS_LODINREFRACTIONALPHA: boolean;
  110473. SS_GAMMAREFRACTION: boolean;
  110474. SS_RGBDREFRACTION: boolean;
  110475. SS_LINEARSPECULARREFRACTION: boolean;
  110476. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110477. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110478. /** @hidden */
  110479. _areTexturesDirty: boolean;
  110480. }
  110481. /**
  110482. * Define the code related to the sub surface parameters of the pbr material.
  110483. */
  110484. export class PBRSubSurfaceConfiguration {
  110485. private _isRefractionEnabled;
  110486. /**
  110487. * Defines if the refraction is enabled in the material.
  110488. */
  110489. isRefractionEnabled: boolean;
  110490. private _isTranslucencyEnabled;
  110491. /**
  110492. * Defines if the translucency is enabled in the material.
  110493. */
  110494. isTranslucencyEnabled: boolean;
  110495. private _isScatteringEnabled;
  110496. /**
  110497. * Defines the refraction intensity of the material.
  110498. * The refraction when enabled replaces the Diffuse part of the material.
  110499. * The intensity helps transitionning between diffuse and refraction.
  110500. */
  110501. refractionIntensity: number;
  110502. /**
  110503. * Defines the translucency intensity of the material.
  110504. * When translucency has been enabled, this defines how much of the "translucency"
  110505. * is addded to the diffuse part of the material.
  110506. */
  110507. translucencyIntensity: number;
  110508. /**
  110509. * Defines the scattering intensity of the material.
  110510. * When scattering has been enabled, this defines how much of the "scattered light"
  110511. * is addded to the diffuse part of the material.
  110512. */
  110513. scatteringIntensity: number;
  110514. private _thicknessTexture;
  110515. /**
  110516. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110517. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110518. * 0 would mean minimumThickness
  110519. * 1 would mean maximumThickness
  110520. * The other channels might be use as a mask to vary the different effects intensity.
  110521. */
  110522. thicknessTexture: Nullable<BaseTexture>;
  110523. private _refractionTexture;
  110524. /**
  110525. * Defines the texture to use for refraction.
  110526. */
  110527. refractionTexture: Nullable<BaseTexture>;
  110528. private _indexOfRefraction;
  110529. /**
  110530. * Defines the index of refraction used in the material.
  110531. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110532. */
  110533. indexOfRefraction: number;
  110534. private _invertRefractionY;
  110535. /**
  110536. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110537. */
  110538. invertRefractionY: boolean;
  110539. private _linkRefractionWithTransparency;
  110540. /**
  110541. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110542. * Materials half opaque for instance using refraction could benefit from this control.
  110543. */
  110544. linkRefractionWithTransparency: boolean;
  110545. /**
  110546. * Defines the minimum thickness stored in the thickness map.
  110547. * If no thickness map is defined, this value will be used to simulate thickness.
  110548. */
  110549. minimumThickness: number;
  110550. /**
  110551. * Defines the maximum thickness stored in the thickness map.
  110552. */
  110553. maximumThickness: number;
  110554. /**
  110555. * Defines the volume tint of the material.
  110556. * This is used for both translucency and scattering.
  110557. */
  110558. tintColor: Color3;
  110559. /**
  110560. * Defines the distance at which the tint color should be found in the media.
  110561. * This is used for refraction only.
  110562. */
  110563. tintColorAtDistance: number;
  110564. /**
  110565. * Defines how far each channel transmit through the media.
  110566. * It is defined as a color to simplify it selection.
  110567. */
  110568. diffusionDistance: Color3;
  110569. private _useMaskFromThicknessTexture;
  110570. /**
  110571. * Stores the intensity of the different subsurface effects in the thickness texture.
  110572. * * the green channel is the translucency intensity.
  110573. * * the blue channel is the scattering intensity.
  110574. * * the alpha channel is the refraction intensity.
  110575. */
  110576. useMaskFromThicknessTexture: boolean;
  110577. /** @hidden */
  110578. private _internalMarkAllSubMeshesAsTexturesDirty;
  110579. /** @hidden */
  110580. _markAllSubMeshesAsTexturesDirty(): void;
  110581. /**
  110582. * Instantiate a new istance of sub surface configuration.
  110583. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110584. */
  110585. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110586. /**
  110587. * Gets wehter the submesh is ready to be used or not.
  110588. * @param defines the list of "defines" to update.
  110589. * @param scene defines the scene the material belongs to.
  110590. * @returns - boolean indicating that the submesh is ready or not.
  110591. */
  110592. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110593. /**
  110594. * Checks to see if a texture is used in the material.
  110595. * @param defines the list of "defines" to update.
  110596. * @param scene defines the scene to the material belongs to.
  110597. */
  110598. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110599. /**
  110600. * Binds the material data.
  110601. * @param uniformBuffer defines the Uniform buffer to fill in.
  110602. * @param scene defines the scene the material belongs to.
  110603. * @param engine defines the engine the material belongs to.
  110604. * @param isFrozen defines wether the material is frozen or not.
  110605. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110606. */
  110607. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110608. /**
  110609. * Unbinds the material from the mesh.
  110610. * @param activeEffect defines the effect that should be unbound from.
  110611. * @returns true if unbound, otherwise false
  110612. */
  110613. unbind(activeEffect: Effect): boolean;
  110614. /**
  110615. * Returns the texture used for refraction or null if none is used.
  110616. * @param scene defines the scene the material belongs to.
  110617. * @returns - Refraction texture if present. If no refraction texture and refraction
  110618. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110619. */
  110620. private _getRefractionTexture;
  110621. /**
  110622. * Returns true if alpha blending should be disabled.
  110623. */
  110624. readonly disableAlphaBlending: boolean;
  110625. /**
  110626. * Fills the list of render target textures.
  110627. * @param renderTargets the list of render targets to update
  110628. */
  110629. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110630. /**
  110631. * Checks to see if a texture is used in the material.
  110632. * @param texture - Base texture to use.
  110633. * @returns - Boolean specifying if a texture is used in the material.
  110634. */
  110635. hasTexture(texture: BaseTexture): boolean;
  110636. /**
  110637. * Gets a boolean indicating that current material needs to register RTT
  110638. * @returns true if this uses a render target otherwise false.
  110639. */
  110640. hasRenderTargetTextures(): boolean;
  110641. /**
  110642. * Returns an array of the actively used textures.
  110643. * @param activeTextures Array of BaseTextures
  110644. */
  110645. getActiveTextures(activeTextures: BaseTexture[]): void;
  110646. /**
  110647. * Returns the animatable textures.
  110648. * @param animatables Array of animatable textures.
  110649. */
  110650. getAnimatables(animatables: IAnimatable[]): void;
  110651. /**
  110652. * Disposes the resources of the material.
  110653. * @param forceDisposeTextures - Forces the disposal of all textures.
  110654. */
  110655. dispose(forceDisposeTextures?: boolean): void;
  110656. /**
  110657. * Get the current class name of the texture useful for serialization or dynamic coding.
  110658. * @returns "PBRSubSurfaceConfiguration"
  110659. */
  110660. getClassName(): string;
  110661. /**
  110662. * Add fallbacks to the effect fallbacks list.
  110663. * @param defines defines the Base texture to use.
  110664. * @param fallbacks defines the current fallback list.
  110665. * @param currentRank defines the current fallback rank.
  110666. * @returns the new fallback rank.
  110667. */
  110668. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110669. /**
  110670. * Add the required uniforms to the current list.
  110671. * @param uniforms defines the current uniform list.
  110672. */
  110673. static AddUniforms(uniforms: string[]): void;
  110674. /**
  110675. * Add the required samplers to the current list.
  110676. * @param samplers defines the current sampler list.
  110677. */
  110678. static AddSamplers(samplers: string[]): void;
  110679. /**
  110680. * Add the required uniforms to the current buffer.
  110681. * @param uniformBuffer defines the current uniform buffer.
  110682. */
  110683. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110684. /**
  110685. * Makes a duplicate of the current configuration into another one.
  110686. * @param configuration define the config where to copy the info
  110687. */
  110688. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110689. /**
  110690. * Serializes this Sub Surface configuration.
  110691. * @returns - An object with the serialized config.
  110692. */
  110693. serialize(): any;
  110694. /**
  110695. * Parses a anisotropy Configuration from a serialized object.
  110696. * @param source - Serialized object.
  110697. * @param scene Defines the scene we are parsing for
  110698. * @param rootUrl Defines the rootUrl to load from
  110699. */
  110700. parse(source: any, scene: Scene, rootUrl: string): void;
  110701. }
  110702. }
  110703. declare module BABYLON {
  110704. /** @hidden */
  110705. export var pbrFragmentDeclaration: {
  110706. name: string;
  110707. shader: string;
  110708. };
  110709. }
  110710. declare module BABYLON {
  110711. /** @hidden */
  110712. export var pbrUboDeclaration: {
  110713. name: string;
  110714. shader: string;
  110715. };
  110716. }
  110717. declare module BABYLON {
  110718. /** @hidden */
  110719. export var pbrFragmentExtraDeclaration: {
  110720. name: string;
  110721. shader: string;
  110722. };
  110723. }
  110724. declare module BABYLON {
  110725. /** @hidden */
  110726. export var pbrFragmentSamplersDeclaration: {
  110727. name: string;
  110728. shader: string;
  110729. };
  110730. }
  110731. declare module BABYLON {
  110732. /** @hidden */
  110733. export var pbrHelperFunctions: {
  110734. name: string;
  110735. shader: string;
  110736. };
  110737. }
  110738. declare module BABYLON {
  110739. /** @hidden */
  110740. export var harmonicsFunctions: {
  110741. name: string;
  110742. shader: string;
  110743. };
  110744. }
  110745. declare module BABYLON {
  110746. /** @hidden */
  110747. export var pbrDirectLightingSetupFunctions: {
  110748. name: string;
  110749. shader: string;
  110750. };
  110751. }
  110752. declare module BABYLON {
  110753. /** @hidden */
  110754. export var pbrDirectLightingFalloffFunctions: {
  110755. name: string;
  110756. shader: string;
  110757. };
  110758. }
  110759. declare module BABYLON {
  110760. /** @hidden */
  110761. export var pbrBRDFFunctions: {
  110762. name: string;
  110763. shader: string;
  110764. };
  110765. }
  110766. declare module BABYLON {
  110767. /** @hidden */
  110768. export var pbrDirectLightingFunctions: {
  110769. name: string;
  110770. shader: string;
  110771. };
  110772. }
  110773. declare module BABYLON {
  110774. /** @hidden */
  110775. export var pbrIBLFunctions: {
  110776. name: string;
  110777. shader: string;
  110778. };
  110779. }
  110780. declare module BABYLON {
  110781. /** @hidden */
  110782. export var pbrDebug: {
  110783. name: string;
  110784. shader: string;
  110785. };
  110786. }
  110787. declare module BABYLON {
  110788. /** @hidden */
  110789. export var pbrPixelShader: {
  110790. name: string;
  110791. shader: string;
  110792. };
  110793. }
  110794. declare module BABYLON {
  110795. /** @hidden */
  110796. export var pbrVertexDeclaration: {
  110797. name: string;
  110798. shader: string;
  110799. };
  110800. }
  110801. declare module BABYLON {
  110802. /** @hidden */
  110803. export var pbrVertexShader: {
  110804. name: string;
  110805. shader: string;
  110806. };
  110807. }
  110808. declare module BABYLON {
  110809. /**
  110810. * Manages the defines for the PBR Material.
  110811. * @hidden
  110812. */
  110813. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110814. PBR: boolean;
  110815. MAINUV1: boolean;
  110816. MAINUV2: boolean;
  110817. UV1: boolean;
  110818. UV2: boolean;
  110819. ALBEDO: boolean;
  110820. ALBEDODIRECTUV: number;
  110821. VERTEXCOLOR: boolean;
  110822. AMBIENT: boolean;
  110823. AMBIENTDIRECTUV: number;
  110824. AMBIENTINGRAYSCALE: boolean;
  110825. OPACITY: boolean;
  110826. VERTEXALPHA: boolean;
  110827. OPACITYDIRECTUV: number;
  110828. OPACITYRGB: boolean;
  110829. ALPHATEST: boolean;
  110830. DEPTHPREPASS: boolean;
  110831. ALPHABLEND: boolean;
  110832. ALPHAFROMALBEDO: boolean;
  110833. ALPHATESTVALUE: string;
  110834. SPECULAROVERALPHA: boolean;
  110835. RADIANCEOVERALPHA: boolean;
  110836. ALPHAFRESNEL: boolean;
  110837. LINEARALPHAFRESNEL: boolean;
  110838. PREMULTIPLYALPHA: boolean;
  110839. EMISSIVE: boolean;
  110840. EMISSIVEDIRECTUV: number;
  110841. REFLECTIVITY: boolean;
  110842. REFLECTIVITYDIRECTUV: number;
  110843. SPECULARTERM: boolean;
  110844. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110845. MICROSURFACEAUTOMATIC: boolean;
  110846. LODBASEDMICROSFURACE: boolean;
  110847. MICROSURFACEMAP: boolean;
  110848. MICROSURFACEMAPDIRECTUV: number;
  110849. METALLICWORKFLOW: boolean;
  110850. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110851. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110852. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110853. AOSTOREINMETALMAPRED: boolean;
  110854. ENVIRONMENTBRDF: boolean;
  110855. ENVIRONMENTBRDF_RGBD: boolean;
  110856. NORMAL: boolean;
  110857. TANGENT: boolean;
  110858. BUMP: boolean;
  110859. BUMPDIRECTUV: number;
  110860. OBJECTSPACE_NORMALMAP: boolean;
  110861. PARALLAX: boolean;
  110862. PARALLAXOCCLUSION: boolean;
  110863. NORMALXYSCALE: boolean;
  110864. LIGHTMAP: boolean;
  110865. LIGHTMAPDIRECTUV: number;
  110866. USELIGHTMAPASSHADOWMAP: boolean;
  110867. GAMMALIGHTMAP: boolean;
  110868. REFLECTION: boolean;
  110869. REFLECTIONMAP_3D: boolean;
  110870. REFLECTIONMAP_SPHERICAL: boolean;
  110871. REFLECTIONMAP_PLANAR: boolean;
  110872. REFLECTIONMAP_CUBIC: boolean;
  110873. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110874. REFLECTIONMAP_PROJECTION: boolean;
  110875. REFLECTIONMAP_SKYBOX: boolean;
  110876. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110877. REFLECTIONMAP_EXPLICIT: boolean;
  110878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110881. INVERTCUBICMAP: boolean;
  110882. USESPHERICALFROMREFLECTIONMAP: boolean;
  110883. USEIRRADIANCEMAP: boolean;
  110884. SPHERICAL_HARMONICS: boolean;
  110885. USESPHERICALINVERTEX: boolean;
  110886. REFLECTIONMAP_OPPOSITEZ: boolean;
  110887. LODINREFLECTIONALPHA: boolean;
  110888. GAMMAREFLECTION: boolean;
  110889. RGBDREFLECTION: boolean;
  110890. LINEARSPECULARREFLECTION: boolean;
  110891. RADIANCEOCCLUSION: boolean;
  110892. HORIZONOCCLUSION: boolean;
  110893. INSTANCES: boolean;
  110894. NUM_BONE_INFLUENCERS: number;
  110895. BonesPerMesh: number;
  110896. BONETEXTURE: boolean;
  110897. NONUNIFORMSCALING: boolean;
  110898. MORPHTARGETS: boolean;
  110899. MORPHTARGETS_NORMAL: boolean;
  110900. MORPHTARGETS_TANGENT: boolean;
  110901. MORPHTARGETS_UV: boolean;
  110902. NUM_MORPH_INFLUENCERS: number;
  110903. IMAGEPROCESSING: boolean;
  110904. VIGNETTE: boolean;
  110905. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110906. VIGNETTEBLENDMODEOPAQUE: boolean;
  110907. TONEMAPPING: boolean;
  110908. TONEMAPPING_ACES: boolean;
  110909. CONTRAST: boolean;
  110910. COLORCURVES: boolean;
  110911. COLORGRADING: boolean;
  110912. COLORGRADING3D: boolean;
  110913. SAMPLER3DGREENDEPTH: boolean;
  110914. SAMPLER3DBGRMAP: boolean;
  110915. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110916. EXPOSURE: boolean;
  110917. MULTIVIEW: boolean;
  110918. USEPHYSICALLIGHTFALLOFF: boolean;
  110919. USEGLTFLIGHTFALLOFF: boolean;
  110920. TWOSIDEDLIGHTING: boolean;
  110921. SHADOWFLOAT: boolean;
  110922. CLIPPLANE: boolean;
  110923. CLIPPLANE2: boolean;
  110924. CLIPPLANE3: boolean;
  110925. CLIPPLANE4: boolean;
  110926. POINTSIZE: boolean;
  110927. FOG: boolean;
  110928. LOGARITHMICDEPTH: boolean;
  110929. FORCENORMALFORWARD: boolean;
  110930. SPECULARAA: boolean;
  110931. CLEARCOAT: boolean;
  110932. CLEARCOAT_DEFAULTIOR: boolean;
  110933. CLEARCOAT_TEXTURE: boolean;
  110934. CLEARCOAT_TEXTUREDIRECTUV: number;
  110935. CLEARCOAT_BUMP: boolean;
  110936. CLEARCOAT_BUMPDIRECTUV: number;
  110937. CLEARCOAT_TINT: boolean;
  110938. CLEARCOAT_TINT_TEXTURE: boolean;
  110939. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110940. ANISOTROPIC: boolean;
  110941. ANISOTROPIC_TEXTURE: boolean;
  110942. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110943. BRDF_V_HEIGHT_CORRELATED: boolean;
  110944. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110945. SHEEN: boolean;
  110946. SHEEN_TEXTURE: boolean;
  110947. SHEEN_TEXTUREDIRECTUV: number;
  110948. SHEEN_LINKWITHALBEDO: boolean;
  110949. SUBSURFACE: boolean;
  110950. SS_REFRACTION: boolean;
  110951. SS_TRANSLUCENCY: boolean;
  110952. SS_SCATERRING: boolean;
  110953. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110954. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110955. SS_REFRACTIONMAP_3D: boolean;
  110956. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110957. SS_LODINREFRACTIONALPHA: boolean;
  110958. SS_GAMMAREFRACTION: boolean;
  110959. SS_RGBDREFRACTION: boolean;
  110960. SS_LINEARSPECULARREFRACTION: boolean;
  110961. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110962. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110963. UNLIT: boolean;
  110964. DEBUGMODE: number;
  110965. /**
  110966. * Initializes the PBR Material defines.
  110967. */
  110968. constructor();
  110969. /**
  110970. * Resets the PBR Material defines.
  110971. */
  110972. reset(): void;
  110973. }
  110974. /**
  110975. * The Physically based material base class of BJS.
  110976. *
  110977. * This offers the main features of a standard PBR material.
  110978. * For more information, please refer to the documentation :
  110979. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110980. */
  110981. export abstract class PBRBaseMaterial extends PushMaterial {
  110982. /**
  110983. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110984. */
  110985. static readonly PBRMATERIAL_OPAQUE: number;
  110986. /**
  110987. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110988. */
  110989. static readonly PBRMATERIAL_ALPHATEST: number;
  110990. /**
  110991. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110992. */
  110993. static readonly PBRMATERIAL_ALPHABLEND: number;
  110994. /**
  110995. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110996. * They are also discarded below the alpha cutoff threshold to improve performances.
  110997. */
  110998. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110999. /**
  111000. * Defines the default value of how much AO map is occluding the analytical lights
  111001. * (point spot...).
  111002. */
  111003. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111004. /**
  111005. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111006. */
  111007. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111008. /**
  111009. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111010. * to enhance interoperability with other engines.
  111011. */
  111012. static readonly LIGHTFALLOFF_GLTF: number;
  111013. /**
  111014. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111015. * to enhance interoperability with other materials.
  111016. */
  111017. static readonly LIGHTFALLOFF_STANDARD: number;
  111018. /**
  111019. * Intensity of the direct lights e.g. the four lights available in your scene.
  111020. * This impacts both the direct diffuse and specular highlights.
  111021. */
  111022. protected _directIntensity: number;
  111023. /**
  111024. * Intensity of the emissive part of the material.
  111025. * This helps controlling the emissive effect without modifying the emissive color.
  111026. */
  111027. protected _emissiveIntensity: number;
  111028. /**
  111029. * Intensity of the environment e.g. how much the environment will light the object
  111030. * either through harmonics for rough material or through the refelction for shiny ones.
  111031. */
  111032. protected _environmentIntensity: number;
  111033. /**
  111034. * This is a special control allowing the reduction of the specular highlights coming from the
  111035. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111036. */
  111037. protected _specularIntensity: number;
  111038. /**
  111039. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111040. */
  111041. private _lightingInfos;
  111042. /**
  111043. * Debug Control allowing disabling the bump map on this material.
  111044. */
  111045. protected _disableBumpMap: boolean;
  111046. /**
  111047. * AKA Diffuse Texture in standard nomenclature.
  111048. */
  111049. protected _albedoTexture: Nullable<BaseTexture>;
  111050. /**
  111051. * AKA Occlusion Texture in other nomenclature.
  111052. */
  111053. protected _ambientTexture: Nullable<BaseTexture>;
  111054. /**
  111055. * AKA Occlusion Texture Intensity in other nomenclature.
  111056. */
  111057. protected _ambientTextureStrength: number;
  111058. /**
  111059. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111060. * 1 means it completely occludes it
  111061. * 0 mean it has no impact
  111062. */
  111063. protected _ambientTextureImpactOnAnalyticalLights: number;
  111064. /**
  111065. * Stores the alpha values in a texture.
  111066. */
  111067. protected _opacityTexture: Nullable<BaseTexture>;
  111068. /**
  111069. * Stores the reflection values in a texture.
  111070. */
  111071. protected _reflectionTexture: Nullable<BaseTexture>;
  111072. /**
  111073. * Stores the emissive values in a texture.
  111074. */
  111075. protected _emissiveTexture: Nullable<BaseTexture>;
  111076. /**
  111077. * AKA Specular texture in other nomenclature.
  111078. */
  111079. protected _reflectivityTexture: Nullable<BaseTexture>;
  111080. /**
  111081. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111082. */
  111083. protected _metallicTexture: Nullable<BaseTexture>;
  111084. /**
  111085. * Specifies the metallic scalar of the metallic/roughness workflow.
  111086. * Can also be used to scale the metalness values of the metallic texture.
  111087. */
  111088. protected _metallic: Nullable<number>;
  111089. /**
  111090. * Specifies the roughness scalar of the metallic/roughness workflow.
  111091. * Can also be used to scale the roughness values of the metallic texture.
  111092. */
  111093. protected _roughness: Nullable<number>;
  111094. /**
  111095. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111096. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111097. */
  111098. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111099. /**
  111100. * Stores surface normal data used to displace a mesh in a texture.
  111101. */
  111102. protected _bumpTexture: Nullable<BaseTexture>;
  111103. /**
  111104. * Stores the pre-calculated light information of a mesh in a texture.
  111105. */
  111106. protected _lightmapTexture: Nullable<BaseTexture>;
  111107. /**
  111108. * The color of a material in ambient lighting.
  111109. */
  111110. protected _ambientColor: Color3;
  111111. /**
  111112. * AKA Diffuse Color in other nomenclature.
  111113. */
  111114. protected _albedoColor: Color3;
  111115. /**
  111116. * AKA Specular Color in other nomenclature.
  111117. */
  111118. protected _reflectivityColor: Color3;
  111119. /**
  111120. * The color applied when light is reflected from a material.
  111121. */
  111122. protected _reflectionColor: Color3;
  111123. /**
  111124. * The color applied when light is emitted from a material.
  111125. */
  111126. protected _emissiveColor: Color3;
  111127. /**
  111128. * AKA Glossiness in other nomenclature.
  111129. */
  111130. protected _microSurface: number;
  111131. /**
  111132. * Specifies that the material will use the light map as a show map.
  111133. */
  111134. protected _useLightmapAsShadowmap: boolean;
  111135. /**
  111136. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111137. * makes the reflect vector face the model (under horizon).
  111138. */
  111139. protected _useHorizonOcclusion: boolean;
  111140. /**
  111141. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111142. * too much the area relying on ambient texture to define their ambient occlusion.
  111143. */
  111144. protected _useRadianceOcclusion: boolean;
  111145. /**
  111146. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111147. */
  111148. protected _useAlphaFromAlbedoTexture: boolean;
  111149. /**
  111150. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111151. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111152. */
  111153. protected _useSpecularOverAlpha: boolean;
  111154. /**
  111155. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111156. */
  111157. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111158. /**
  111159. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111160. */
  111161. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111162. /**
  111163. * Specifies if the metallic texture contains the roughness information in its green channel.
  111164. */
  111165. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111166. /**
  111167. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111168. */
  111169. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111170. /**
  111171. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111172. */
  111173. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111174. /**
  111175. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111176. */
  111177. protected _useAmbientInGrayScale: boolean;
  111178. /**
  111179. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111180. * The material will try to infer what glossiness each pixel should be.
  111181. */
  111182. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111183. /**
  111184. * Defines the falloff type used in this material.
  111185. * It by default is Physical.
  111186. */
  111187. protected _lightFalloff: number;
  111188. /**
  111189. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111190. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111191. */
  111192. protected _useRadianceOverAlpha: boolean;
  111193. /**
  111194. * Allows using an object space normal map (instead of tangent space).
  111195. */
  111196. protected _useObjectSpaceNormalMap: boolean;
  111197. /**
  111198. * Allows using the bump map in parallax mode.
  111199. */
  111200. protected _useParallax: boolean;
  111201. /**
  111202. * Allows using the bump map in parallax occlusion mode.
  111203. */
  111204. protected _useParallaxOcclusion: boolean;
  111205. /**
  111206. * Controls the scale bias of the parallax mode.
  111207. */
  111208. protected _parallaxScaleBias: number;
  111209. /**
  111210. * If sets to true, disables all the lights affecting the material.
  111211. */
  111212. protected _disableLighting: boolean;
  111213. /**
  111214. * Number of Simultaneous lights allowed on the material.
  111215. */
  111216. protected _maxSimultaneousLights: number;
  111217. /**
  111218. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111219. */
  111220. protected _invertNormalMapX: boolean;
  111221. /**
  111222. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111223. */
  111224. protected _invertNormalMapY: boolean;
  111225. /**
  111226. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111227. */
  111228. protected _twoSidedLighting: boolean;
  111229. /**
  111230. * Defines the alpha limits in alpha test mode.
  111231. */
  111232. protected _alphaCutOff: number;
  111233. /**
  111234. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111235. */
  111236. protected _forceAlphaTest: boolean;
  111237. /**
  111238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111239. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111240. */
  111241. protected _useAlphaFresnel: boolean;
  111242. /**
  111243. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111244. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111245. */
  111246. protected _useLinearAlphaFresnel: boolean;
  111247. /**
  111248. * The transparency mode of the material.
  111249. */
  111250. protected _transparencyMode: Nullable<number>;
  111251. /**
  111252. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111253. * from cos thetav and roughness:
  111254. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111255. */
  111256. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111257. /**
  111258. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111259. */
  111260. protected _forceIrradianceInFragment: boolean;
  111261. /**
  111262. * Force normal to face away from face.
  111263. */
  111264. protected _forceNormalForward: boolean;
  111265. /**
  111266. * Enables specular anti aliasing in the PBR shader.
  111267. * It will both interacts on the Geometry for analytical and IBL lighting.
  111268. * It also prefilter the roughness map based on the bump values.
  111269. */
  111270. protected _enableSpecularAntiAliasing: boolean;
  111271. /**
  111272. * Default configuration related to image processing available in the PBR Material.
  111273. */
  111274. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111275. /**
  111276. * Keep track of the image processing observer to allow dispose and replace.
  111277. */
  111278. private _imageProcessingObserver;
  111279. /**
  111280. * Attaches a new image processing configuration to the PBR Material.
  111281. * @param configuration
  111282. */
  111283. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111284. /**
  111285. * Stores the available render targets.
  111286. */
  111287. private _renderTargets;
  111288. /**
  111289. * Sets the global ambient color for the material used in lighting calculations.
  111290. */
  111291. private _globalAmbientColor;
  111292. /**
  111293. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111294. */
  111295. private _useLogarithmicDepth;
  111296. /**
  111297. * If set to true, no lighting calculations will be applied.
  111298. */
  111299. private _unlit;
  111300. private _debugMode;
  111301. /**
  111302. * @hidden
  111303. * This is reserved for the inspector.
  111304. * Defines the material debug mode.
  111305. * It helps seeing only some components of the material while troubleshooting.
  111306. */
  111307. debugMode: number;
  111308. /**
  111309. * @hidden
  111310. * This is reserved for the inspector.
  111311. * Specify from where on screen the debug mode should start.
  111312. * The value goes from -1 (full screen) to 1 (not visible)
  111313. * It helps with side by side comparison against the final render
  111314. * This defaults to -1
  111315. */
  111316. private debugLimit;
  111317. /**
  111318. * @hidden
  111319. * This is reserved for the inspector.
  111320. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111321. * You can use the factor to better multiply the final value.
  111322. */
  111323. private debugFactor;
  111324. /**
  111325. * Defines the clear coat layer parameters for the material.
  111326. */
  111327. readonly clearCoat: PBRClearCoatConfiguration;
  111328. /**
  111329. * Defines the anisotropic parameters for the material.
  111330. */
  111331. readonly anisotropy: PBRAnisotropicConfiguration;
  111332. /**
  111333. * Defines the BRDF parameters for the material.
  111334. */
  111335. readonly brdf: PBRBRDFConfiguration;
  111336. /**
  111337. * Defines the Sheen parameters for the material.
  111338. */
  111339. readonly sheen: PBRSheenConfiguration;
  111340. /**
  111341. * Defines the SubSurface parameters for the material.
  111342. */
  111343. readonly subSurface: PBRSubSurfaceConfiguration;
  111344. /**
  111345. * Custom callback helping to override the default shader used in the material.
  111346. */
  111347. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111348. /**
  111349. * Instantiates a new PBRMaterial instance.
  111350. *
  111351. * @param name The material name
  111352. * @param scene The scene the material will be use in.
  111353. */
  111354. constructor(name: string, scene: Scene);
  111355. /**
  111356. * Gets a boolean indicating that current material needs to register RTT
  111357. */
  111358. readonly hasRenderTargetTextures: boolean;
  111359. /**
  111360. * Gets the name of the material class.
  111361. */
  111362. getClassName(): string;
  111363. /**
  111364. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111365. */
  111366. /**
  111367. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111368. */
  111369. useLogarithmicDepth: boolean;
  111370. /**
  111371. * Gets the current transparency mode.
  111372. */
  111373. /**
  111374. * Sets the transparency mode of the material.
  111375. *
  111376. * | Value | Type | Description |
  111377. * | ----- | ----------------------------------- | ----------- |
  111378. * | 0 | OPAQUE | |
  111379. * | 1 | ALPHATEST | |
  111380. * | 2 | ALPHABLEND | |
  111381. * | 3 | ALPHATESTANDBLEND | |
  111382. *
  111383. */
  111384. transparencyMode: Nullable<number>;
  111385. /**
  111386. * Returns true if alpha blending should be disabled.
  111387. */
  111388. private readonly _disableAlphaBlending;
  111389. /**
  111390. * Specifies whether or not this material should be rendered in alpha blend mode.
  111391. */
  111392. needAlphaBlending(): boolean;
  111393. /**
  111394. * Specifies if the mesh will require alpha blending.
  111395. * @param mesh - BJS mesh.
  111396. */
  111397. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111398. /**
  111399. * Specifies whether or not this material should be rendered in alpha test mode.
  111400. */
  111401. needAlphaTesting(): boolean;
  111402. /**
  111403. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111404. */
  111405. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111406. /**
  111407. * Gets the texture used for the alpha test.
  111408. */
  111409. getAlphaTestTexture(): Nullable<BaseTexture>;
  111410. /**
  111411. * Specifies that the submesh is ready to be used.
  111412. * @param mesh - BJS mesh.
  111413. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111414. * @param useInstances - Specifies that instances should be used.
  111415. * @returns - boolean indicating that the submesh is ready or not.
  111416. */
  111417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111418. /**
  111419. * Specifies if the material uses metallic roughness workflow.
  111420. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111421. */
  111422. isMetallicWorkflow(): boolean;
  111423. private _prepareEffect;
  111424. private _prepareDefines;
  111425. /**
  111426. * Force shader compilation
  111427. */
  111428. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111429. clipPlane: boolean;
  111430. }>): void;
  111431. /**
  111432. * Initializes the uniform buffer layout for the shader.
  111433. */
  111434. buildUniformLayout(): void;
  111435. /**
  111436. * Unbinds the material from the mesh
  111437. */
  111438. unbind(): void;
  111439. /**
  111440. * Binds the submesh data.
  111441. * @param world - The world matrix.
  111442. * @param mesh - The BJS mesh.
  111443. * @param subMesh - A submesh of the BJS mesh.
  111444. */
  111445. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111446. /**
  111447. * Returns the animatable textures.
  111448. * @returns - Array of animatable textures.
  111449. */
  111450. getAnimatables(): IAnimatable[];
  111451. /**
  111452. * Returns the texture used for reflections.
  111453. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111454. */
  111455. private _getReflectionTexture;
  111456. /**
  111457. * Returns an array of the actively used textures.
  111458. * @returns - Array of BaseTextures
  111459. */
  111460. getActiveTextures(): BaseTexture[];
  111461. /**
  111462. * Checks to see if a texture is used in the material.
  111463. * @param texture - Base texture to use.
  111464. * @returns - Boolean specifying if a texture is used in the material.
  111465. */
  111466. hasTexture(texture: BaseTexture): boolean;
  111467. /**
  111468. * Disposes the resources of the material.
  111469. * @param forceDisposeEffect - Forces the disposal of effects.
  111470. * @param forceDisposeTextures - Forces the disposal of all textures.
  111471. */
  111472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111473. }
  111474. }
  111475. declare module BABYLON {
  111476. /**
  111477. * The Physically based material of BJS.
  111478. *
  111479. * This offers the main features of a standard PBR material.
  111480. * For more information, please refer to the documentation :
  111481. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111482. */
  111483. export class PBRMaterial extends PBRBaseMaterial {
  111484. /**
  111485. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111486. */
  111487. static readonly PBRMATERIAL_OPAQUE: number;
  111488. /**
  111489. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111490. */
  111491. static readonly PBRMATERIAL_ALPHATEST: number;
  111492. /**
  111493. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111494. */
  111495. static readonly PBRMATERIAL_ALPHABLEND: number;
  111496. /**
  111497. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111498. * They are also discarded below the alpha cutoff threshold to improve performances.
  111499. */
  111500. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111501. /**
  111502. * Defines the default value of how much AO map is occluding the analytical lights
  111503. * (point spot...).
  111504. */
  111505. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111506. /**
  111507. * Intensity of the direct lights e.g. the four lights available in your scene.
  111508. * This impacts both the direct diffuse and specular highlights.
  111509. */
  111510. directIntensity: number;
  111511. /**
  111512. * Intensity of the emissive part of the material.
  111513. * This helps controlling the emissive effect without modifying the emissive color.
  111514. */
  111515. emissiveIntensity: number;
  111516. /**
  111517. * Intensity of the environment e.g. how much the environment will light the object
  111518. * either through harmonics for rough material or through the refelction for shiny ones.
  111519. */
  111520. environmentIntensity: number;
  111521. /**
  111522. * This is a special control allowing the reduction of the specular highlights coming from the
  111523. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111524. */
  111525. specularIntensity: number;
  111526. /**
  111527. * Debug Control allowing disabling the bump map on this material.
  111528. */
  111529. disableBumpMap: boolean;
  111530. /**
  111531. * AKA Diffuse Texture in standard nomenclature.
  111532. */
  111533. albedoTexture: BaseTexture;
  111534. /**
  111535. * AKA Occlusion Texture in other nomenclature.
  111536. */
  111537. ambientTexture: BaseTexture;
  111538. /**
  111539. * AKA Occlusion Texture Intensity in other nomenclature.
  111540. */
  111541. ambientTextureStrength: number;
  111542. /**
  111543. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111544. * 1 means it completely occludes it
  111545. * 0 mean it has no impact
  111546. */
  111547. ambientTextureImpactOnAnalyticalLights: number;
  111548. /**
  111549. * Stores the alpha values in a texture.
  111550. */
  111551. opacityTexture: BaseTexture;
  111552. /**
  111553. * Stores the reflection values in a texture.
  111554. */
  111555. reflectionTexture: Nullable<BaseTexture>;
  111556. /**
  111557. * Stores the emissive values in a texture.
  111558. */
  111559. emissiveTexture: BaseTexture;
  111560. /**
  111561. * AKA Specular texture in other nomenclature.
  111562. */
  111563. reflectivityTexture: BaseTexture;
  111564. /**
  111565. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111566. */
  111567. metallicTexture: BaseTexture;
  111568. /**
  111569. * Specifies the metallic scalar of the metallic/roughness workflow.
  111570. * Can also be used to scale the metalness values of the metallic texture.
  111571. */
  111572. metallic: Nullable<number>;
  111573. /**
  111574. * Specifies the roughness scalar of the metallic/roughness workflow.
  111575. * Can also be used to scale the roughness values of the metallic texture.
  111576. */
  111577. roughness: Nullable<number>;
  111578. /**
  111579. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111580. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111581. */
  111582. microSurfaceTexture: BaseTexture;
  111583. /**
  111584. * Stores surface normal data used to displace a mesh in a texture.
  111585. */
  111586. bumpTexture: BaseTexture;
  111587. /**
  111588. * Stores the pre-calculated light information of a mesh in a texture.
  111589. */
  111590. lightmapTexture: BaseTexture;
  111591. /**
  111592. * Stores the refracted light information in a texture.
  111593. */
  111594. refractionTexture: Nullable<BaseTexture>;
  111595. /**
  111596. * The color of a material in ambient lighting.
  111597. */
  111598. ambientColor: Color3;
  111599. /**
  111600. * AKA Diffuse Color in other nomenclature.
  111601. */
  111602. albedoColor: Color3;
  111603. /**
  111604. * AKA Specular Color in other nomenclature.
  111605. */
  111606. reflectivityColor: Color3;
  111607. /**
  111608. * The color reflected from the material.
  111609. */
  111610. reflectionColor: Color3;
  111611. /**
  111612. * The color emitted from the material.
  111613. */
  111614. emissiveColor: Color3;
  111615. /**
  111616. * AKA Glossiness in other nomenclature.
  111617. */
  111618. microSurface: number;
  111619. /**
  111620. * source material index of refraction (IOR)' / 'destination material IOR.
  111621. */
  111622. indexOfRefraction: number;
  111623. /**
  111624. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111625. */
  111626. invertRefractionY: boolean;
  111627. /**
  111628. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111629. * Materials half opaque for instance using refraction could benefit from this control.
  111630. */
  111631. linkRefractionWithTransparency: boolean;
  111632. /**
  111633. * If true, the light map contains occlusion information instead of lighting info.
  111634. */
  111635. useLightmapAsShadowmap: boolean;
  111636. /**
  111637. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111638. */
  111639. useAlphaFromAlbedoTexture: boolean;
  111640. /**
  111641. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111642. */
  111643. forceAlphaTest: boolean;
  111644. /**
  111645. * Defines the alpha limits in alpha test mode.
  111646. */
  111647. alphaCutOff: number;
  111648. /**
  111649. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111650. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111651. */
  111652. useSpecularOverAlpha: boolean;
  111653. /**
  111654. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111655. */
  111656. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111657. /**
  111658. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111659. */
  111660. useRoughnessFromMetallicTextureAlpha: boolean;
  111661. /**
  111662. * Specifies if the metallic texture contains the roughness information in its green channel.
  111663. */
  111664. useRoughnessFromMetallicTextureGreen: boolean;
  111665. /**
  111666. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111667. */
  111668. useMetallnessFromMetallicTextureBlue: boolean;
  111669. /**
  111670. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111671. */
  111672. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111673. /**
  111674. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111675. */
  111676. useAmbientInGrayScale: boolean;
  111677. /**
  111678. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111679. * The material will try to infer what glossiness each pixel should be.
  111680. */
  111681. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111682. /**
  111683. * BJS is using an harcoded light falloff based on a manually sets up range.
  111684. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111685. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111686. */
  111687. /**
  111688. * BJS is using an harcoded light falloff based on a manually sets up range.
  111689. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111690. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111691. */
  111692. usePhysicalLightFalloff: boolean;
  111693. /**
  111694. * In order to support the falloff compatibility with gltf, a special mode has been added
  111695. * to reproduce the gltf light falloff.
  111696. */
  111697. /**
  111698. * In order to support the falloff compatibility with gltf, a special mode has been added
  111699. * to reproduce the gltf light falloff.
  111700. */
  111701. useGLTFLightFalloff: boolean;
  111702. /**
  111703. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111704. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111705. */
  111706. useRadianceOverAlpha: boolean;
  111707. /**
  111708. * Allows using an object space normal map (instead of tangent space).
  111709. */
  111710. useObjectSpaceNormalMap: boolean;
  111711. /**
  111712. * Allows using the bump map in parallax mode.
  111713. */
  111714. useParallax: boolean;
  111715. /**
  111716. * Allows using the bump map in parallax occlusion mode.
  111717. */
  111718. useParallaxOcclusion: boolean;
  111719. /**
  111720. * Controls the scale bias of the parallax mode.
  111721. */
  111722. parallaxScaleBias: number;
  111723. /**
  111724. * If sets to true, disables all the lights affecting the material.
  111725. */
  111726. disableLighting: boolean;
  111727. /**
  111728. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111729. */
  111730. forceIrradianceInFragment: boolean;
  111731. /**
  111732. * Number of Simultaneous lights allowed on the material.
  111733. */
  111734. maxSimultaneousLights: number;
  111735. /**
  111736. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111737. */
  111738. invertNormalMapX: boolean;
  111739. /**
  111740. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111741. */
  111742. invertNormalMapY: boolean;
  111743. /**
  111744. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111745. */
  111746. twoSidedLighting: boolean;
  111747. /**
  111748. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111749. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111750. */
  111751. useAlphaFresnel: boolean;
  111752. /**
  111753. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111754. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111755. */
  111756. useLinearAlphaFresnel: boolean;
  111757. /**
  111758. * Let user defines the brdf lookup texture used for IBL.
  111759. * A default 8bit version is embedded but you could point at :
  111760. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111761. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111762. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111763. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111764. */
  111765. environmentBRDFTexture: Nullable<BaseTexture>;
  111766. /**
  111767. * Force normal to face away from face.
  111768. */
  111769. forceNormalForward: boolean;
  111770. /**
  111771. * Enables specular anti aliasing in the PBR shader.
  111772. * It will both interacts on the Geometry for analytical and IBL lighting.
  111773. * It also prefilter the roughness map based on the bump values.
  111774. */
  111775. enableSpecularAntiAliasing: boolean;
  111776. /**
  111777. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111778. * makes the reflect vector face the model (under horizon).
  111779. */
  111780. useHorizonOcclusion: boolean;
  111781. /**
  111782. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111783. * too much the area relying on ambient texture to define their ambient occlusion.
  111784. */
  111785. useRadianceOcclusion: boolean;
  111786. /**
  111787. * If set to true, no lighting calculations will be applied.
  111788. */
  111789. unlit: boolean;
  111790. /**
  111791. * Gets the image processing configuration used either in this material.
  111792. */
  111793. /**
  111794. * Sets the Default image processing configuration used either in the this material.
  111795. *
  111796. * If sets to null, the scene one is in use.
  111797. */
  111798. imageProcessingConfiguration: ImageProcessingConfiguration;
  111799. /**
  111800. * Gets wether the color curves effect is enabled.
  111801. */
  111802. /**
  111803. * Sets wether the color curves effect is enabled.
  111804. */
  111805. cameraColorCurvesEnabled: boolean;
  111806. /**
  111807. * Gets wether the color grading effect is enabled.
  111808. */
  111809. /**
  111810. * Gets wether the color grading effect is enabled.
  111811. */
  111812. cameraColorGradingEnabled: boolean;
  111813. /**
  111814. * Gets wether tonemapping is enabled or not.
  111815. */
  111816. /**
  111817. * Sets wether tonemapping is enabled or not
  111818. */
  111819. cameraToneMappingEnabled: boolean;
  111820. /**
  111821. * The camera exposure used on this material.
  111822. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111823. * This corresponds to a photographic exposure.
  111824. */
  111825. /**
  111826. * The camera exposure used on this material.
  111827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111828. * This corresponds to a photographic exposure.
  111829. */
  111830. cameraExposure: number;
  111831. /**
  111832. * Gets The camera contrast used on this material.
  111833. */
  111834. /**
  111835. * Sets The camera contrast used on this material.
  111836. */
  111837. cameraContrast: number;
  111838. /**
  111839. * Gets the Color Grading 2D Lookup Texture.
  111840. */
  111841. /**
  111842. * Sets the Color Grading 2D Lookup Texture.
  111843. */
  111844. cameraColorGradingTexture: Nullable<BaseTexture>;
  111845. /**
  111846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111848. * 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;
  111849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111850. */
  111851. /**
  111852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111854. * 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;
  111855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111856. */
  111857. cameraColorCurves: Nullable<ColorCurves>;
  111858. /**
  111859. * Instantiates a new PBRMaterial instance.
  111860. *
  111861. * @param name The material name
  111862. * @param scene The scene the material will be use in.
  111863. */
  111864. constructor(name: string, scene: Scene);
  111865. /**
  111866. * Returns the name of this material class.
  111867. */
  111868. getClassName(): string;
  111869. /**
  111870. * Makes a duplicate of the current material.
  111871. * @param name - name to use for the new material.
  111872. */
  111873. clone(name: string): PBRMaterial;
  111874. /**
  111875. * Serializes this PBR Material.
  111876. * @returns - An object with the serialized material.
  111877. */
  111878. serialize(): any;
  111879. /**
  111880. * Parses a PBR Material from a serialized object.
  111881. * @param source - Serialized object.
  111882. * @param scene - BJS scene instance.
  111883. * @param rootUrl - url for the scene object
  111884. * @returns - PBRMaterial
  111885. */
  111886. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111887. }
  111888. }
  111889. declare module BABYLON {
  111890. /**
  111891. * Direct draw surface info
  111892. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111893. */
  111894. export interface DDSInfo {
  111895. /**
  111896. * Width of the texture
  111897. */
  111898. width: number;
  111899. /**
  111900. * Width of the texture
  111901. */
  111902. height: number;
  111903. /**
  111904. * Number of Mipmaps for the texture
  111905. * @see https://en.wikipedia.org/wiki/Mipmap
  111906. */
  111907. mipmapCount: number;
  111908. /**
  111909. * If the textures format is a known fourCC format
  111910. * @see https://www.fourcc.org/
  111911. */
  111912. isFourCC: boolean;
  111913. /**
  111914. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111915. */
  111916. isRGB: boolean;
  111917. /**
  111918. * If the texture is a lumincance format
  111919. */
  111920. isLuminance: boolean;
  111921. /**
  111922. * If this is a cube texture
  111923. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111924. */
  111925. isCube: boolean;
  111926. /**
  111927. * If the texture is a compressed format eg. FOURCC_DXT1
  111928. */
  111929. isCompressed: boolean;
  111930. /**
  111931. * The dxgiFormat of the texture
  111932. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111933. */
  111934. dxgiFormat: number;
  111935. /**
  111936. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111937. */
  111938. textureType: number;
  111939. /**
  111940. * Sphericle polynomial created for the dds texture
  111941. */
  111942. sphericalPolynomial?: SphericalPolynomial;
  111943. }
  111944. /**
  111945. * Class used to provide DDS decompression tools
  111946. */
  111947. export class DDSTools {
  111948. /**
  111949. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111950. */
  111951. static StoreLODInAlphaChannel: boolean;
  111952. /**
  111953. * Gets DDS information from an array buffer
  111954. * @param arrayBuffer defines the array buffer to read data from
  111955. * @returns the DDS information
  111956. */
  111957. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111958. private static _FloatView;
  111959. private static _Int32View;
  111960. private static _ToHalfFloat;
  111961. private static _FromHalfFloat;
  111962. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111963. private static _GetHalfFloatRGBAArrayBuffer;
  111964. private static _GetFloatRGBAArrayBuffer;
  111965. private static _GetFloatAsUIntRGBAArrayBuffer;
  111966. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111967. private static _GetRGBAArrayBuffer;
  111968. private static _ExtractLongWordOrder;
  111969. private static _GetRGBArrayBuffer;
  111970. private static _GetLuminanceArrayBuffer;
  111971. /**
  111972. * Uploads DDS Levels to a Babylon Texture
  111973. * @hidden
  111974. */
  111975. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111976. }
  111977. interface Engine {
  111978. /**
  111979. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111980. * @param rootUrl defines the url where the file to load is located
  111981. * @param scene defines the current scene
  111982. * @param lodScale defines scale to apply to the mip map selection
  111983. * @param lodOffset defines offset to apply to the mip map selection
  111984. * @param onLoad defines an optional callback raised when the texture is loaded
  111985. * @param onError defines an optional callback raised if there is an issue to load the texture
  111986. * @param format defines the format of the data
  111987. * @param forcedExtension defines the extension to use to pick the right loader
  111988. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111989. * @returns the cube texture as an InternalTexture
  111990. */
  111991. 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;
  111992. }
  111993. }
  111994. declare module BABYLON {
  111995. /**
  111996. * Implementation of the DDS Texture Loader.
  111997. * @hidden
  111998. */
  111999. export class _DDSTextureLoader implements IInternalTextureLoader {
  112000. /**
  112001. * Defines wether the loader supports cascade loading the different faces.
  112002. */
  112003. readonly supportCascades: boolean;
  112004. /**
  112005. * This returns if the loader support the current file information.
  112006. * @param extension defines the file extension of the file being loaded
  112007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112008. * @param fallback defines the fallback internal texture if any
  112009. * @param isBase64 defines whether the texture is encoded as a base64
  112010. * @param isBuffer defines whether the texture data are stored as a buffer
  112011. * @returns true if the loader can load the specified file
  112012. */
  112013. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112014. /**
  112015. * Transform the url before loading if required.
  112016. * @param rootUrl the url of the texture
  112017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112018. * @returns the transformed texture
  112019. */
  112020. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112021. /**
  112022. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112023. * @param rootUrl the url of the texture
  112024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112025. * @returns the fallback texture
  112026. */
  112027. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112028. /**
  112029. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112030. * @param data contains the texture data
  112031. * @param texture defines the BabylonJS internal texture
  112032. * @param createPolynomials will be true if polynomials have been requested
  112033. * @param onLoad defines the callback to trigger once the texture is ready
  112034. * @param onError defines the callback to trigger in case of error
  112035. */
  112036. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112037. /**
  112038. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112039. * @param data contains the texture data
  112040. * @param texture defines the BabylonJS internal texture
  112041. * @param callback defines the method to call once ready to upload
  112042. */
  112043. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112044. }
  112045. }
  112046. declare module BABYLON {
  112047. /** @hidden */
  112048. export var rgbdEncodePixelShader: {
  112049. name: string;
  112050. shader: string;
  112051. };
  112052. }
  112053. declare module BABYLON {
  112054. /**
  112055. * Raw texture data and descriptor sufficient for WebGL texture upload
  112056. */
  112057. export interface EnvironmentTextureInfo {
  112058. /**
  112059. * Version of the environment map
  112060. */
  112061. version: number;
  112062. /**
  112063. * Width of image
  112064. */
  112065. width: number;
  112066. /**
  112067. * Irradiance information stored in the file.
  112068. */
  112069. irradiance: any;
  112070. /**
  112071. * Specular information stored in the file.
  112072. */
  112073. specular: any;
  112074. }
  112075. /**
  112076. * Sets of helpers addressing the serialization and deserialization of environment texture
  112077. * stored in a BabylonJS env file.
  112078. * Those files are usually stored as .env files.
  112079. */
  112080. export class EnvironmentTextureTools {
  112081. /**
  112082. * Magic number identifying the env file.
  112083. */
  112084. private static _MagicBytes;
  112085. /**
  112086. * Gets the environment info from an env file.
  112087. * @param data The array buffer containing the .env bytes.
  112088. * @returns the environment file info (the json header) if successfully parsed.
  112089. */
  112090. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112091. /**
  112092. * Creates an environment texture from a loaded cube texture.
  112093. * @param texture defines the cube texture to convert in env file
  112094. * @return a promise containing the environment data if succesfull.
  112095. */
  112096. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112097. /**
  112098. * Creates a JSON representation of the spherical data.
  112099. * @param texture defines the texture containing the polynomials
  112100. * @return the JSON representation of the spherical info
  112101. */
  112102. private static _CreateEnvTextureIrradiance;
  112103. /**
  112104. * Uploads the texture info contained in the env file to the GPU.
  112105. * @param texture defines the internal texture to upload to
  112106. * @param arrayBuffer defines the buffer cotaining the data to load
  112107. * @param info defines the texture info retrieved through the GetEnvInfo method
  112108. * @returns a promise
  112109. */
  112110. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112111. /**
  112112. * Uploads the levels of image data to the GPU.
  112113. * @param texture defines the internal texture to upload to
  112114. * @param imageData defines the array buffer views of image data [mipmap][face]
  112115. * @returns a promise
  112116. */
  112117. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112118. /**
  112119. * Uploads spherical polynomials information to the texture.
  112120. * @param texture defines the texture we are trying to upload the information to
  112121. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112122. */
  112123. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112124. /** @hidden */
  112125. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112126. }
  112127. }
  112128. declare module BABYLON {
  112129. /**
  112130. * Implementation of the ENV Texture Loader.
  112131. * @hidden
  112132. */
  112133. export class _ENVTextureLoader implements IInternalTextureLoader {
  112134. /**
  112135. * Defines wether the loader supports cascade loading the different faces.
  112136. */
  112137. readonly supportCascades: boolean;
  112138. /**
  112139. * This returns if the loader support the current file information.
  112140. * @param extension defines the file extension of the file being loaded
  112141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112142. * @param fallback defines the fallback internal texture if any
  112143. * @param isBase64 defines whether the texture is encoded as a base64
  112144. * @param isBuffer defines whether the texture data are stored as a buffer
  112145. * @returns true if the loader can load the specified file
  112146. */
  112147. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112148. /**
  112149. * Transform the url before loading if required.
  112150. * @param rootUrl the url of the texture
  112151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112152. * @returns the transformed texture
  112153. */
  112154. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112155. /**
  112156. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112157. * @param rootUrl the url of the texture
  112158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112159. * @returns the fallback texture
  112160. */
  112161. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112162. /**
  112163. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112164. * @param data contains the texture data
  112165. * @param texture defines the BabylonJS internal texture
  112166. * @param createPolynomials will be true if polynomials have been requested
  112167. * @param onLoad defines the callback to trigger once the texture is ready
  112168. * @param onError defines the callback to trigger in case of error
  112169. */
  112170. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112171. /**
  112172. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112173. * @param data contains the texture data
  112174. * @param texture defines the BabylonJS internal texture
  112175. * @param callback defines the method to call once ready to upload
  112176. */
  112177. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112178. }
  112179. }
  112180. declare module BABYLON {
  112181. /**
  112182. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112183. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112184. */
  112185. export class KhronosTextureContainer {
  112186. /** contents of the KTX container file */
  112187. arrayBuffer: any;
  112188. private static HEADER_LEN;
  112189. private static COMPRESSED_2D;
  112190. private static COMPRESSED_3D;
  112191. private static TEX_2D;
  112192. private static TEX_3D;
  112193. /**
  112194. * Gets the openGL type
  112195. */
  112196. glType: number;
  112197. /**
  112198. * Gets the openGL type size
  112199. */
  112200. glTypeSize: number;
  112201. /**
  112202. * Gets the openGL format
  112203. */
  112204. glFormat: number;
  112205. /**
  112206. * Gets the openGL internal format
  112207. */
  112208. glInternalFormat: number;
  112209. /**
  112210. * Gets the base internal format
  112211. */
  112212. glBaseInternalFormat: number;
  112213. /**
  112214. * Gets image width in pixel
  112215. */
  112216. pixelWidth: number;
  112217. /**
  112218. * Gets image height in pixel
  112219. */
  112220. pixelHeight: number;
  112221. /**
  112222. * Gets image depth in pixels
  112223. */
  112224. pixelDepth: number;
  112225. /**
  112226. * Gets the number of array elements
  112227. */
  112228. numberOfArrayElements: number;
  112229. /**
  112230. * Gets the number of faces
  112231. */
  112232. numberOfFaces: number;
  112233. /**
  112234. * Gets the number of mipmap levels
  112235. */
  112236. numberOfMipmapLevels: number;
  112237. /**
  112238. * Gets the bytes of key value data
  112239. */
  112240. bytesOfKeyValueData: number;
  112241. /**
  112242. * Gets the load type
  112243. */
  112244. loadType: number;
  112245. /**
  112246. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112247. */
  112248. isInvalid: boolean;
  112249. /**
  112250. * Creates a new KhronosTextureContainer
  112251. * @param arrayBuffer contents of the KTX container file
  112252. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112253. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112254. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112255. */
  112256. constructor(
  112257. /** contents of the KTX container file */
  112258. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112259. /**
  112260. * Uploads KTX content to a Babylon Texture.
  112261. * It is assumed that the texture has already been created & is currently bound
  112262. * @hidden
  112263. */
  112264. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112265. private _upload2DCompressedLevels;
  112266. }
  112267. }
  112268. declare module BABYLON {
  112269. /**
  112270. * Implementation of the KTX Texture Loader.
  112271. * @hidden
  112272. */
  112273. export class _KTXTextureLoader implements IInternalTextureLoader {
  112274. /**
  112275. * Defines wether the loader supports cascade loading the different faces.
  112276. */
  112277. readonly supportCascades: boolean;
  112278. /**
  112279. * This returns if the loader support the current file information.
  112280. * @param extension defines the file extension of the file being loaded
  112281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112282. * @param fallback defines the fallback internal texture if any
  112283. * @param isBase64 defines whether the texture is encoded as a base64
  112284. * @param isBuffer defines whether the texture data are stored as a buffer
  112285. * @returns true if the loader can load the specified file
  112286. */
  112287. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112288. /**
  112289. * Transform the url before loading if required.
  112290. * @param rootUrl the url of the texture
  112291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112292. * @returns the transformed texture
  112293. */
  112294. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112295. /**
  112296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112297. * @param rootUrl the url of the texture
  112298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112299. * @returns the fallback texture
  112300. */
  112301. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112302. /**
  112303. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112304. * @param data contains the texture data
  112305. * @param texture defines the BabylonJS internal texture
  112306. * @param createPolynomials will be true if polynomials have been requested
  112307. * @param onLoad defines the callback to trigger once the texture is ready
  112308. * @param onError defines the callback to trigger in case of error
  112309. */
  112310. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112311. /**
  112312. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112313. * @param data contains the texture data
  112314. * @param texture defines the BabylonJS internal texture
  112315. * @param callback defines the method to call once ready to upload
  112316. */
  112317. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112318. }
  112319. }
  112320. declare module BABYLON {
  112321. /**
  112322. * Options for the default xr helper
  112323. */
  112324. export class WebXRDefaultExperienceOptions {
  112325. /**
  112326. * Floor meshes that should be used for teleporting
  112327. */
  112328. floorMeshes: Array<AbstractMesh>;
  112329. }
  112330. /**
  112331. * Default experience which provides a similar setup to the previous webVRExperience
  112332. */
  112333. export class WebXRDefaultExperience {
  112334. /**
  112335. * Base experience
  112336. */
  112337. baseExperience: WebXRExperienceHelper;
  112338. /**
  112339. * Input experience extension
  112340. */
  112341. input: WebXRInput;
  112342. /**
  112343. * Loads the controller models
  112344. */
  112345. controllerModelLoader: WebXRControllerModelLoader;
  112346. /**
  112347. * Enables laser pointer and selection
  112348. */
  112349. pointerSelection: WebXRControllerPointerSelection;
  112350. /**
  112351. * Enables teleportation
  112352. */
  112353. teleportation: WebXRControllerTeleportation;
  112354. /**
  112355. * Enables ui for enetering/exiting xr
  112356. */
  112357. enterExitUI: WebXREnterExitUI;
  112358. /**
  112359. * Default output canvas xr should render to
  112360. */
  112361. outputCanvas: WebXRManagedOutputCanvas;
  112362. /**
  112363. * Creates the default xr experience
  112364. * @param scene scene
  112365. * @param options options for basic configuration
  112366. * @returns resulting WebXRDefaultExperience
  112367. */
  112368. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112369. private constructor();
  112370. /**
  112371. * DIsposes of the experience helper
  112372. */
  112373. dispose(): void;
  112374. }
  112375. }
  112376. declare module BABYLON {
  112377. /** @hidden */
  112378. export var _forceSceneHelpersToBundle: boolean;
  112379. interface Scene {
  112380. /**
  112381. * Creates a default light for the scene.
  112382. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112383. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112384. */
  112385. createDefaultLight(replace?: boolean): void;
  112386. /**
  112387. * Creates a default camera for the scene.
  112388. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112389. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112390. * @param replace has default false, when true replaces the active camera in the scene
  112391. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112392. */
  112393. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112394. /**
  112395. * Creates a default camera and a default light.
  112396. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112397. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112398. * @param replace has the default false, when true replaces the active camera/light in the scene
  112399. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112400. */
  112401. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112402. /**
  112403. * Creates a new sky box
  112404. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112405. * @param environmentTexture defines the texture to use as environment texture
  112406. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112407. * @param scale defines the overall scale of the skybox
  112408. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112409. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112410. * @returns a new mesh holding the sky box
  112411. */
  112412. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112413. /**
  112414. * Creates a new environment
  112415. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112416. * @param options defines the options you can use to configure the environment
  112417. * @returns the new EnvironmentHelper
  112418. */
  112419. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112420. /**
  112421. * Creates a new VREXperienceHelper
  112422. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112423. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112424. * @returns a new VREXperienceHelper
  112425. */
  112426. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112427. /**
  112428. * Creates a new WebXRDefaultExperience
  112429. * @see http://doc.babylonjs.com/how_to/webxr
  112430. * @param options experience options
  112431. * @returns a promise for a new WebXRDefaultExperience
  112432. */
  112433. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112434. }
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * Contains position and normal vectors for a vertex
  112439. */
  112440. export class PositionNormalVertex {
  112441. /** the position of the vertex (defaut: 0,0,0) */
  112442. position: Vector3;
  112443. /** the normal of the vertex (defaut: 0,1,0) */
  112444. normal: Vector3;
  112445. /**
  112446. * Creates a PositionNormalVertex
  112447. * @param position the position of the vertex (defaut: 0,0,0)
  112448. * @param normal the normal of the vertex (defaut: 0,1,0)
  112449. */
  112450. constructor(
  112451. /** the position of the vertex (defaut: 0,0,0) */
  112452. position?: Vector3,
  112453. /** the normal of the vertex (defaut: 0,1,0) */
  112454. normal?: Vector3);
  112455. /**
  112456. * Clones the PositionNormalVertex
  112457. * @returns the cloned PositionNormalVertex
  112458. */
  112459. clone(): PositionNormalVertex;
  112460. }
  112461. /**
  112462. * Contains position, normal and uv vectors for a vertex
  112463. */
  112464. export class PositionNormalTextureVertex {
  112465. /** the position of the vertex (defaut: 0,0,0) */
  112466. position: Vector3;
  112467. /** the normal of the vertex (defaut: 0,1,0) */
  112468. normal: Vector3;
  112469. /** the uv of the vertex (default: 0,0) */
  112470. uv: Vector2;
  112471. /**
  112472. * Creates a PositionNormalTextureVertex
  112473. * @param position the position of the vertex (defaut: 0,0,0)
  112474. * @param normal the normal of the vertex (defaut: 0,1,0)
  112475. * @param uv the uv of the vertex (default: 0,0)
  112476. */
  112477. constructor(
  112478. /** the position of the vertex (defaut: 0,0,0) */
  112479. position?: Vector3,
  112480. /** the normal of the vertex (defaut: 0,1,0) */
  112481. normal?: Vector3,
  112482. /** the uv of the vertex (default: 0,0) */
  112483. uv?: Vector2);
  112484. /**
  112485. * Clones the PositionNormalTextureVertex
  112486. * @returns the cloned PositionNormalTextureVertex
  112487. */
  112488. clone(): PositionNormalTextureVertex;
  112489. }
  112490. }
  112491. declare module BABYLON {
  112492. /**
  112493. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112494. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112495. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112496. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112497. */
  112498. export class VideoDome extends TransformNode {
  112499. /**
  112500. * Define the video source as a Monoscopic panoramic 360 video.
  112501. */
  112502. static readonly MODE_MONOSCOPIC: number;
  112503. /**
  112504. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112505. */
  112506. static readonly MODE_TOPBOTTOM: number;
  112507. /**
  112508. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112509. */
  112510. static readonly MODE_SIDEBYSIDE: number;
  112511. private _halfDome;
  112512. private _useDirectMapping;
  112513. /**
  112514. * The video texture being displayed on the sphere
  112515. */
  112516. protected _videoTexture: VideoTexture;
  112517. /**
  112518. * Gets the video texture being displayed on the sphere
  112519. */
  112520. readonly videoTexture: VideoTexture;
  112521. /**
  112522. * The skybox material
  112523. */
  112524. protected _material: BackgroundMaterial;
  112525. /**
  112526. * The surface used for the skybox
  112527. */
  112528. protected _mesh: Mesh;
  112529. /**
  112530. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  112531. */
  112532. private _halfDomeMask;
  112533. /**
  112534. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112535. * Also see the options.resolution property.
  112536. */
  112537. fovMultiplier: number;
  112538. private _videoMode;
  112539. /**
  112540. * Gets or set the current video mode for the video. It can be:
  112541. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112542. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112543. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112544. */
  112545. videoMode: number;
  112546. /**
  112547. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  112548. *
  112549. */
  112550. /**
  112551. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  112552. */
  112553. halfDome: boolean;
  112554. /**
  112555. * Oberserver used in Stereoscopic VR Mode.
  112556. */
  112557. private _onBeforeCameraRenderObserver;
  112558. /**
  112559. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112560. * @param name Element's name, child elements will append suffixes for their own names.
  112561. * @param urlsOrVideo defines the url(s) or the video element to use
  112562. * @param options An object containing optional or exposed sub element properties
  112563. */
  112564. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112565. resolution?: number;
  112566. clickToPlay?: boolean;
  112567. autoPlay?: boolean;
  112568. loop?: boolean;
  112569. size?: number;
  112570. poster?: string;
  112571. faceForward?: boolean;
  112572. useDirectMapping?: boolean;
  112573. halfDomeMode?: boolean;
  112574. }, scene: Scene);
  112575. private _changeVideoMode;
  112576. /**
  112577. * Releases resources associated with this node.
  112578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112580. */
  112581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112582. }
  112583. }
  112584. declare module BABYLON {
  112585. /**
  112586. * This class can be used to get instrumentation data from a Babylon engine
  112587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112588. */
  112589. export class EngineInstrumentation implements IDisposable {
  112590. /**
  112591. * Define the instrumented engine.
  112592. */
  112593. engine: Engine;
  112594. private _captureGPUFrameTime;
  112595. private _gpuFrameTimeToken;
  112596. private _gpuFrameTime;
  112597. private _captureShaderCompilationTime;
  112598. private _shaderCompilationTime;
  112599. private _onBeginFrameObserver;
  112600. private _onEndFrameObserver;
  112601. private _onBeforeShaderCompilationObserver;
  112602. private _onAfterShaderCompilationObserver;
  112603. /**
  112604. * Gets the perf counter used for GPU frame time
  112605. */
  112606. readonly gpuFrameTimeCounter: PerfCounter;
  112607. /**
  112608. * Gets the GPU frame time capture status
  112609. */
  112610. /**
  112611. * Enable or disable the GPU frame time capture
  112612. */
  112613. captureGPUFrameTime: boolean;
  112614. /**
  112615. * Gets the perf counter used for shader compilation time
  112616. */
  112617. readonly shaderCompilationTimeCounter: PerfCounter;
  112618. /**
  112619. * Gets the shader compilation time capture status
  112620. */
  112621. /**
  112622. * Enable or disable the shader compilation time capture
  112623. */
  112624. captureShaderCompilationTime: boolean;
  112625. /**
  112626. * Instantiates a new engine instrumentation.
  112627. * This class can be used to get instrumentation data from a Babylon engine
  112628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112629. * @param engine Defines the engine to instrument
  112630. */
  112631. constructor(
  112632. /**
  112633. * Define the instrumented engine.
  112634. */
  112635. engine: Engine);
  112636. /**
  112637. * Dispose and release associated resources.
  112638. */
  112639. dispose(): void;
  112640. }
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * This class can be used to get instrumentation data from a Babylon engine
  112645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112646. */
  112647. export class SceneInstrumentation implements IDisposable {
  112648. /**
  112649. * Defines the scene to instrument
  112650. */
  112651. scene: Scene;
  112652. private _captureActiveMeshesEvaluationTime;
  112653. private _activeMeshesEvaluationTime;
  112654. private _captureRenderTargetsRenderTime;
  112655. private _renderTargetsRenderTime;
  112656. private _captureFrameTime;
  112657. private _frameTime;
  112658. private _captureRenderTime;
  112659. private _renderTime;
  112660. private _captureInterFrameTime;
  112661. private _interFrameTime;
  112662. private _captureParticlesRenderTime;
  112663. private _particlesRenderTime;
  112664. private _captureSpritesRenderTime;
  112665. private _spritesRenderTime;
  112666. private _capturePhysicsTime;
  112667. private _physicsTime;
  112668. private _captureAnimationsTime;
  112669. private _animationsTime;
  112670. private _captureCameraRenderTime;
  112671. private _cameraRenderTime;
  112672. private _onBeforeActiveMeshesEvaluationObserver;
  112673. private _onAfterActiveMeshesEvaluationObserver;
  112674. private _onBeforeRenderTargetsRenderObserver;
  112675. private _onAfterRenderTargetsRenderObserver;
  112676. private _onAfterRenderObserver;
  112677. private _onBeforeDrawPhaseObserver;
  112678. private _onAfterDrawPhaseObserver;
  112679. private _onBeforeAnimationsObserver;
  112680. private _onBeforeParticlesRenderingObserver;
  112681. private _onAfterParticlesRenderingObserver;
  112682. private _onBeforeSpritesRenderingObserver;
  112683. private _onAfterSpritesRenderingObserver;
  112684. private _onBeforePhysicsObserver;
  112685. private _onAfterPhysicsObserver;
  112686. private _onAfterAnimationsObserver;
  112687. private _onBeforeCameraRenderObserver;
  112688. private _onAfterCameraRenderObserver;
  112689. /**
  112690. * Gets the perf counter used for active meshes evaluation time
  112691. */
  112692. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112693. /**
  112694. * Gets the active meshes evaluation time capture status
  112695. */
  112696. /**
  112697. * Enable or disable the active meshes evaluation time capture
  112698. */
  112699. captureActiveMeshesEvaluationTime: boolean;
  112700. /**
  112701. * Gets the perf counter used for render targets render time
  112702. */
  112703. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112704. /**
  112705. * Gets the render targets render time capture status
  112706. */
  112707. /**
  112708. * Enable or disable the render targets render time capture
  112709. */
  112710. captureRenderTargetsRenderTime: boolean;
  112711. /**
  112712. * Gets the perf counter used for particles render time
  112713. */
  112714. readonly particlesRenderTimeCounter: PerfCounter;
  112715. /**
  112716. * Gets the particles render time capture status
  112717. */
  112718. /**
  112719. * Enable or disable the particles render time capture
  112720. */
  112721. captureParticlesRenderTime: boolean;
  112722. /**
  112723. * Gets the perf counter used for sprites render time
  112724. */
  112725. readonly spritesRenderTimeCounter: PerfCounter;
  112726. /**
  112727. * Gets the sprites render time capture status
  112728. */
  112729. /**
  112730. * Enable or disable the sprites render time capture
  112731. */
  112732. captureSpritesRenderTime: boolean;
  112733. /**
  112734. * Gets the perf counter used for physics time
  112735. */
  112736. readonly physicsTimeCounter: PerfCounter;
  112737. /**
  112738. * Gets the physics time capture status
  112739. */
  112740. /**
  112741. * Enable or disable the physics time capture
  112742. */
  112743. capturePhysicsTime: boolean;
  112744. /**
  112745. * Gets the perf counter used for animations time
  112746. */
  112747. readonly animationsTimeCounter: PerfCounter;
  112748. /**
  112749. * Gets the animations time capture status
  112750. */
  112751. /**
  112752. * Enable or disable the animations time capture
  112753. */
  112754. captureAnimationsTime: boolean;
  112755. /**
  112756. * Gets the perf counter used for frame time capture
  112757. */
  112758. readonly frameTimeCounter: PerfCounter;
  112759. /**
  112760. * Gets the frame time capture status
  112761. */
  112762. /**
  112763. * Enable or disable the frame time capture
  112764. */
  112765. captureFrameTime: boolean;
  112766. /**
  112767. * Gets the perf counter used for inter-frames time capture
  112768. */
  112769. readonly interFrameTimeCounter: PerfCounter;
  112770. /**
  112771. * Gets the inter-frames time capture status
  112772. */
  112773. /**
  112774. * Enable or disable the inter-frames time capture
  112775. */
  112776. captureInterFrameTime: boolean;
  112777. /**
  112778. * Gets the perf counter used for render time capture
  112779. */
  112780. readonly renderTimeCounter: PerfCounter;
  112781. /**
  112782. * Gets the render time capture status
  112783. */
  112784. /**
  112785. * Enable or disable the render time capture
  112786. */
  112787. captureRenderTime: boolean;
  112788. /**
  112789. * Gets the perf counter used for camera render time capture
  112790. */
  112791. readonly cameraRenderTimeCounter: PerfCounter;
  112792. /**
  112793. * Gets the camera render time capture status
  112794. */
  112795. /**
  112796. * Enable or disable the camera render time capture
  112797. */
  112798. captureCameraRenderTime: boolean;
  112799. /**
  112800. * Gets the perf counter used for draw calls
  112801. */
  112802. readonly drawCallsCounter: PerfCounter;
  112803. /**
  112804. * Instantiates a new scene instrumentation.
  112805. * This class can be used to get instrumentation data from a Babylon engine
  112806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112807. * @param scene Defines the scene to instrument
  112808. */
  112809. constructor(
  112810. /**
  112811. * Defines the scene to instrument
  112812. */
  112813. scene: Scene);
  112814. /**
  112815. * Dispose and release associated resources.
  112816. */
  112817. dispose(): void;
  112818. }
  112819. }
  112820. declare module BABYLON {
  112821. /** @hidden */
  112822. export var glowMapGenerationPixelShader: {
  112823. name: string;
  112824. shader: string;
  112825. };
  112826. }
  112827. declare module BABYLON {
  112828. /** @hidden */
  112829. export var glowMapGenerationVertexShader: {
  112830. name: string;
  112831. shader: string;
  112832. };
  112833. }
  112834. declare module BABYLON {
  112835. /**
  112836. * Effect layer options. This helps customizing the behaviour
  112837. * of the effect layer.
  112838. */
  112839. export interface IEffectLayerOptions {
  112840. /**
  112841. * Multiplication factor apply to the canvas size to compute the render target size
  112842. * used to generated the objects (the smaller the faster).
  112843. */
  112844. mainTextureRatio: number;
  112845. /**
  112846. * Enforces a fixed size texture to ensure effect stability across devices.
  112847. */
  112848. mainTextureFixedSize?: number;
  112849. /**
  112850. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  112851. */
  112852. alphaBlendingMode: number;
  112853. /**
  112854. * The camera attached to the layer.
  112855. */
  112856. camera: Nullable<Camera>;
  112857. /**
  112858. * The rendering group to draw the layer in.
  112859. */
  112860. renderingGroupId: number;
  112861. }
  112862. /**
  112863. * The effect layer Helps adding post process effect blended with the main pass.
  112864. *
  112865. * This can be for instance use to generate glow or higlight effects on the scene.
  112866. *
  112867. * The effect layer class can not be used directly and is intented to inherited from to be
  112868. * customized per effects.
  112869. */
  112870. export abstract class EffectLayer {
  112871. private _vertexBuffers;
  112872. private _indexBuffer;
  112873. private _cachedDefines;
  112874. private _effectLayerMapGenerationEffect;
  112875. private _effectLayerOptions;
  112876. private _mergeEffect;
  112877. protected _scene: Scene;
  112878. protected _engine: Engine;
  112879. protected _maxSize: number;
  112880. protected _mainTextureDesiredSize: ISize;
  112881. protected _mainTexture: RenderTargetTexture;
  112882. protected _shouldRender: boolean;
  112883. protected _postProcesses: PostProcess[];
  112884. protected _textures: BaseTexture[];
  112885. protected _emissiveTextureAndColor: {
  112886. texture: Nullable<BaseTexture>;
  112887. color: Color4;
  112888. };
  112889. /**
  112890. * The name of the layer
  112891. */
  112892. name: string;
  112893. /**
  112894. * The clear color of the texture used to generate the glow map.
  112895. */
  112896. neutralColor: Color4;
  112897. /**
  112898. * Specifies wether the highlight layer is enabled or not.
  112899. */
  112900. isEnabled: boolean;
  112901. /**
  112902. * Gets the camera attached to the layer.
  112903. */
  112904. readonly camera: Nullable<Camera>;
  112905. /**
  112906. * Gets the rendering group id the layer should render in.
  112907. */
  112908. renderingGroupId: number;
  112909. /**
  112910. * An event triggered when the effect layer has been disposed.
  112911. */
  112912. onDisposeObservable: Observable<EffectLayer>;
  112913. /**
  112914. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112915. */
  112916. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112917. /**
  112918. * An event triggered when the generated texture is being merged in the scene.
  112919. */
  112920. onBeforeComposeObservable: Observable<EffectLayer>;
  112921. /**
  112922. * An event triggered when the generated texture has been merged in the scene.
  112923. */
  112924. onAfterComposeObservable: Observable<EffectLayer>;
  112925. /**
  112926. * An event triggered when the efffect layer changes its size.
  112927. */
  112928. onSizeChangedObservable: Observable<EffectLayer>;
  112929. /** @hidden */
  112930. static _SceneComponentInitialization: (scene: Scene) => void;
  112931. /**
  112932. * Instantiates a new effect Layer and references it in the scene.
  112933. * @param name The name of the layer
  112934. * @param scene The scene to use the layer in
  112935. */
  112936. constructor(
  112937. /** The Friendly of the effect in the scene */
  112938. name: string, scene: Scene);
  112939. /**
  112940. * Get the effect name of the layer.
  112941. * @return The effect name
  112942. */
  112943. abstract getEffectName(): string;
  112944. /**
  112945. * Checks for the readiness of the element composing the layer.
  112946. * @param subMesh the mesh to check for
  112947. * @param useInstances specify wether or not to use instances to render the mesh
  112948. * @return true if ready otherwise, false
  112949. */
  112950. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112951. /**
  112952. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112953. * @returns true if the effect requires stencil during the main canvas render pass.
  112954. */
  112955. abstract needStencil(): boolean;
  112956. /**
  112957. * Create the merge effect. This is the shader use to blit the information back
  112958. * to the main canvas at the end of the scene rendering.
  112959. * @returns The effect containing the shader used to merge the effect on the main canvas
  112960. */
  112961. protected abstract _createMergeEffect(): Effect;
  112962. /**
  112963. * Creates the render target textures and post processes used in the effect layer.
  112964. */
  112965. protected abstract _createTextureAndPostProcesses(): void;
  112966. /**
  112967. * Implementation specific of rendering the generating effect on the main canvas.
  112968. * @param effect The effect used to render through
  112969. */
  112970. protected abstract _internalRender(effect: Effect): void;
  112971. /**
  112972. * Sets the required values for both the emissive texture and and the main color.
  112973. */
  112974. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112975. /**
  112976. * Free any resources and references associated to a mesh.
  112977. * Internal use
  112978. * @param mesh The mesh to free.
  112979. */
  112980. abstract _disposeMesh(mesh: Mesh): void;
  112981. /**
  112982. * Serializes this layer (Glow or Highlight for example)
  112983. * @returns a serialized layer object
  112984. */
  112985. abstract serialize?(): any;
  112986. /**
  112987. * Initializes the effect layer with the required options.
  112988. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112989. */
  112990. protected _init(options: Partial<IEffectLayerOptions>): void;
  112991. /**
  112992. * Generates the index buffer of the full screen quad blending to the main canvas.
  112993. */
  112994. private _generateIndexBuffer;
  112995. /**
  112996. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112997. */
  112998. private _generateVertexBuffer;
  112999. /**
  113000. * Sets the main texture desired size which is the closest power of two
  113001. * of the engine canvas size.
  113002. */
  113003. private _setMainTextureSize;
  113004. /**
  113005. * Creates the main texture for the effect layer.
  113006. */
  113007. protected _createMainTexture(): void;
  113008. /**
  113009. * Adds specific effects defines.
  113010. * @param defines The defines to add specifics to.
  113011. */
  113012. protected _addCustomEffectDefines(defines: string[]): void;
  113013. /**
  113014. * Checks for the readiness of the element composing the layer.
  113015. * @param subMesh the mesh to check for
  113016. * @param useInstances specify wether or not to use instances to render the mesh
  113017. * @param emissiveTexture the associated emissive texture used to generate the glow
  113018. * @return true if ready otherwise, false
  113019. */
  113020. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113021. /**
  113022. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113023. */
  113024. render(): void;
  113025. /**
  113026. * Determine if a given mesh will be used in the current effect.
  113027. * @param mesh mesh to test
  113028. * @returns true if the mesh will be used
  113029. */
  113030. hasMesh(mesh: AbstractMesh): boolean;
  113031. /**
  113032. * Returns true if the layer contains information to display, otherwise false.
  113033. * @returns true if the glow layer should be rendered
  113034. */
  113035. shouldRender(): boolean;
  113036. /**
  113037. * Returns true if the mesh should render, otherwise false.
  113038. * @param mesh The mesh to render
  113039. * @returns true if it should render otherwise false
  113040. */
  113041. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113042. /**
  113043. * Returns true if the mesh can be rendered, otherwise false.
  113044. * @param mesh The mesh to render
  113045. * @param material The material used on the mesh
  113046. * @returns true if it can be rendered otherwise false
  113047. */
  113048. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113049. /**
  113050. * Returns true if the mesh should render, otherwise false.
  113051. * @param mesh The mesh to render
  113052. * @returns true if it should render otherwise false
  113053. */
  113054. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113055. /**
  113056. * Renders the submesh passed in parameter to the generation map.
  113057. */
  113058. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113059. /**
  113060. * Rebuild the required buffers.
  113061. * @hidden Internal use only.
  113062. */
  113063. _rebuild(): void;
  113064. /**
  113065. * Dispose only the render target textures and post process.
  113066. */
  113067. private _disposeTextureAndPostProcesses;
  113068. /**
  113069. * Dispose the highlight layer and free resources.
  113070. */
  113071. dispose(): void;
  113072. /**
  113073. * Gets the class name of the effect layer
  113074. * @returns the string with the class name of the effect layer
  113075. */
  113076. getClassName(): string;
  113077. /**
  113078. * Creates an effect layer from parsed effect layer data
  113079. * @param parsedEffectLayer defines effect layer data
  113080. * @param scene defines the current scene
  113081. * @param rootUrl defines the root URL containing the effect layer information
  113082. * @returns a parsed effect Layer
  113083. */
  113084. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113085. }
  113086. }
  113087. declare module BABYLON {
  113088. interface AbstractScene {
  113089. /**
  113090. * The list of effect layers (highlights/glow) added to the scene
  113091. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113092. * @see http://doc.babylonjs.com/how_to/glow_layer
  113093. */
  113094. effectLayers: Array<EffectLayer>;
  113095. /**
  113096. * Removes the given effect layer from this scene.
  113097. * @param toRemove defines the effect layer to remove
  113098. * @returns the index of the removed effect layer
  113099. */
  113100. removeEffectLayer(toRemove: EffectLayer): number;
  113101. /**
  113102. * Adds the given effect layer to this scene
  113103. * @param newEffectLayer defines the effect layer to add
  113104. */
  113105. addEffectLayer(newEffectLayer: EffectLayer): void;
  113106. }
  113107. /**
  113108. * Defines the layer scene component responsible to manage any effect layers
  113109. * in a given scene.
  113110. */
  113111. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113112. /**
  113113. * The component name helpfull to identify the component in the list of scene components.
  113114. */
  113115. readonly name: string;
  113116. /**
  113117. * The scene the component belongs to.
  113118. */
  113119. scene: Scene;
  113120. private _engine;
  113121. private _renderEffects;
  113122. private _needStencil;
  113123. private _previousStencilState;
  113124. /**
  113125. * Creates a new instance of the component for the given scene
  113126. * @param scene Defines the scene to register the component in
  113127. */
  113128. constructor(scene: Scene);
  113129. /**
  113130. * Registers the component in a given scene
  113131. */
  113132. register(): void;
  113133. /**
  113134. * Rebuilds the elements related to this component in case of
  113135. * context lost for instance.
  113136. */
  113137. rebuild(): void;
  113138. /**
  113139. * Serializes the component data to the specified json object
  113140. * @param serializationObject The object to serialize to
  113141. */
  113142. serialize(serializationObject: any): void;
  113143. /**
  113144. * Adds all the elements from the container to the scene
  113145. * @param container the container holding the elements
  113146. */
  113147. addFromContainer(container: AbstractScene): void;
  113148. /**
  113149. * Removes all the elements in the container from the scene
  113150. * @param container contains the elements to remove
  113151. * @param dispose if the removed element should be disposed (default: false)
  113152. */
  113153. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113154. /**
  113155. * Disposes the component and the associated ressources.
  113156. */
  113157. dispose(): void;
  113158. private _isReadyForMesh;
  113159. private _renderMainTexture;
  113160. private _setStencil;
  113161. private _setStencilBack;
  113162. private _draw;
  113163. private _drawCamera;
  113164. private _drawRenderingGroup;
  113165. }
  113166. }
  113167. declare module BABYLON {
  113168. /** @hidden */
  113169. export var glowMapMergePixelShader: {
  113170. name: string;
  113171. shader: string;
  113172. };
  113173. }
  113174. declare module BABYLON {
  113175. /** @hidden */
  113176. export var glowMapMergeVertexShader: {
  113177. name: string;
  113178. shader: string;
  113179. };
  113180. }
  113181. declare module BABYLON {
  113182. interface AbstractScene {
  113183. /**
  113184. * Return a the first highlight layer of the scene with a given name.
  113185. * @param name The name of the highlight layer to look for.
  113186. * @return The highlight layer if found otherwise null.
  113187. */
  113188. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113189. }
  113190. /**
  113191. * Glow layer options. This helps customizing the behaviour
  113192. * of the glow layer.
  113193. */
  113194. export interface IGlowLayerOptions {
  113195. /**
  113196. * Multiplication factor apply to the canvas size to compute the render target size
  113197. * used to generated the glowing objects (the smaller the faster).
  113198. */
  113199. mainTextureRatio: number;
  113200. /**
  113201. * Enforces a fixed size texture to ensure resize independant blur.
  113202. */
  113203. mainTextureFixedSize?: number;
  113204. /**
  113205. * How big is the kernel of the blur texture.
  113206. */
  113207. blurKernelSize: number;
  113208. /**
  113209. * The camera attached to the layer.
  113210. */
  113211. camera: Nullable<Camera>;
  113212. /**
  113213. * Enable MSAA by chosing the number of samples.
  113214. */
  113215. mainTextureSamples?: number;
  113216. /**
  113217. * The rendering group to draw the layer in.
  113218. */
  113219. renderingGroupId: number;
  113220. }
  113221. /**
  113222. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113223. *
  113224. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113225. * glowy meshes to your scene.
  113226. *
  113227. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113228. */
  113229. export class GlowLayer extends EffectLayer {
  113230. /**
  113231. * Effect Name of the layer.
  113232. */
  113233. static readonly EffectName: string;
  113234. /**
  113235. * The default blur kernel size used for the glow.
  113236. */
  113237. static DefaultBlurKernelSize: number;
  113238. /**
  113239. * The default texture size ratio used for the glow.
  113240. */
  113241. static DefaultTextureRatio: number;
  113242. /**
  113243. * Sets the kernel size of the blur.
  113244. */
  113245. /**
  113246. * Gets the kernel size of the blur.
  113247. */
  113248. blurKernelSize: number;
  113249. /**
  113250. * Sets the glow intensity.
  113251. */
  113252. /**
  113253. * Gets the glow intensity.
  113254. */
  113255. intensity: number;
  113256. private _options;
  113257. private _intensity;
  113258. private _horizontalBlurPostprocess1;
  113259. private _verticalBlurPostprocess1;
  113260. private _horizontalBlurPostprocess2;
  113261. private _verticalBlurPostprocess2;
  113262. private _blurTexture1;
  113263. private _blurTexture2;
  113264. private _postProcesses1;
  113265. private _postProcesses2;
  113266. private _includedOnlyMeshes;
  113267. private _excludedMeshes;
  113268. /**
  113269. * Callback used to let the user override the color selection on a per mesh basis
  113270. */
  113271. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113272. /**
  113273. * Callback used to let the user override the texture selection on a per mesh basis
  113274. */
  113275. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113276. /**
  113277. * Instantiates a new glow Layer and references it to the scene.
  113278. * @param name The name of the layer
  113279. * @param scene The scene to use the layer in
  113280. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113281. */
  113282. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113283. /**
  113284. * Get the effect name of the layer.
  113285. * @return The effect name
  113286. */
  113287. getEffectName(): string;
  113288. /**
  113289. * Create the merge effect. This is the shader use to blit the information back
  113290. * to the main canvas at the end of the scene rendering.
  113291. */
  113292. protected _createMergeEffect(): Effect;
  113293. /**
  113294. * Creates the render target textures and post processes used in the glow layer.
  113295. */
  113296. protected _createTextureAndPostProcesses(): void;
  113297. /**
  113298. * Checks for the readiness of the element composing the layer.
  113299. * @param subMesh the mesh to check for
  113300. * @param useInstances specify wether or not to use instances to render the mesh
  113301. * @param emissiveTexture the associated emissive texture used to generate the glow
  113302. * @return true if ready otherwise, false
  113303. */
  113304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113305. /**
  113306. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113307. */
  113308. needStencil(): boolean;
  113309. /**
  113310. * Returns true if the mesh can be rendered, otherwise false.
  113311. * @param mesh The mesh to render
  113312. * @param material The material used on the mesh
  113313. * @returns true if it can be rendered otherwise false
  113314. */
  113315. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113316. /**
  113317. * Implementation specific of rendering the generating effect on the main canvas.
  113318. * @param effect The effect used to render through
  113319. */
  113320. protected _internalRender(effect: Effect): void;
  113321. /**
  113322. * Sets the required values for both the emissive texture and and the main color.
  113323. */
  113324. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113325. /**
  113326. * Returns true if the mesh should render, otherwise false.
  113327. * @param mesh The mesh to render
  113328. * @returns true if it should render otherwise false
  113329. */
  113330. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113331. /**
  113332. * Adds specific effects defines.
  113333. * @param defines The defines to add specifics to.
  113334. */
  113335. protected _addCustomEffectDefines(defines: string[]): void;
  113336. /**
  113337. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113338. * @param mesh The mesh to exclude from the glow layer
  113339. */
  113340. addExcludedMesh(mesh: Mesh): void;
  113341. /**
  113342. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113343. * @param mesh The mesh to remove
  113344. */
  113345. removeExcludedMesh(mesh: Mesh): void;
  113346. /**
  113347. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113348. * @param mesh The mesh to include in the glow layer
  113349. */
  113350. addIncludedOnlyMesh(mesh: Mesh): void;
  113351. /**
  113352. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113353. * @param mesh The mesh to remove
  113354. */
  113355. removeIncludedOnlyMesh(mesh: Mesh): void;
  113356. /**
  113357. * Determine if a given mesh will be used in the glow layer
  113358. * @param mesh The mesh to test
  113359. * @returns true if the mesh will be highlighted by the current glow layer
  113360. */
  113361. hasMesh(mesh: AbstractMesh): boolean;
  113362. /**
  113363. * Free any resources and references associated to a mesh.
  113364. * Internal use
  113365. * @param mesh The mesh to free.
  113366. * @hidden
  113367. */
  113368. _disposeMesh(mesh: Mesh): void;
  113369. /**
  113370. * Gets the class name of the effect layer
  113371. * @returns the string with the class name of the effect layer
  113372. */
  113373. getClassName(): string;
  113374. /**
  113375. * Serializes this glow layer
  113376. * @returns a serialized glow layer object
  113377. */
  113378. serialize(): any;
  113379. /**
  113380. * Creates a Glow Layer from parsed glow layer data
  113381. * @param parsedGlowLayer defines glow layer data
  113382. * @param scene defines the current scene
  113383. * @param rootUrl defines the root URL containing the glow layer information
  113384. * @returns a parsed Glow Layer
  113385. */
  113386. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113387. }
  113388. }
  113389. declare module BABYLON {
  113390. /** @hidden */
  113391. export var glowBlurPostProcessPixelShader: {
  113392. name: string;
  113393. shader: string;
  113394. };
  113395. }
  113396. declare module BABYLON {
  113397. interface AbstractScene {
  113398. /**
  113399. * Return a the first highlight layer of the scene with a given name.
  113400. * @param name The name of the highlight layer to look for.
  113401. * @return The highlight layer if found otherwise null.
  113402. */
  113403. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113404. }
  113405. /**
  113406. * Highlight layer options. This helps customizing the behaviour
  113407. * of the highlight layer.
  113408. */
  113409. export interface IHighlightLayerOptions {
  113410. /**
  113411. * Multiplication factor apply to the canvas size to compute the render target size
  113412. * used to generated the glowing objects (the smaller the faster).
  113413. */
  113414. mainTextureRatio: number;
  113415. /**
  113416. * Enforces a fixed size texture to ensure resize independant blur.
  113417. */
  113418. mainTextureFixedSize?: number;
  113419. /**
  113420. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113421. * of the picture to blur (the smaller the faster).
  113422. */
  113423. blurTextureSizeRatio: number;
  113424. /**
  113425. * How big in texel of the blur texture is the vertical blur.
  113426. */
  113427. blurVerticalSize: number;
  113428. /**
  113429. * How big in texel of the blur texture is the horizontal blur.
  113430. */
  113431. blurHorizontalSize: number;
  113432. /**
  113433. * Alpha blending mode used to apply the blur. Default is combine.
  113434. */
  113435. alphaBlendingMode: number;
  113436. /**
  113437. * The camera attached to the layer.
  113438. */
  113439. camera: Nullable<Camera>;
  113440. /**
  113441. * Should we display highlight as a solid stroke?
  113442. */
  113443. isStroke?: boolean;
  113444. /**
  113445. * The rendering group to draw the layer in.
  113446. */
  113447. renderingGroupId: number;
  113448. }
  113449. /**
  113450. * The highlight layer Helps adding a glow effect around a mesh.
  113451. *
  113452. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113453. * glowy meshes to your scene.
  113454. *
  113455. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113456. */
  113457. export class HighlightLayer extends EffectLayer {
  113458. name: string;
  113459. /**
  113460. * Effect Name of the highlight layer.
  113461. */
  113462. static readonly EffectName: string;
  113463. /**
  113464. * The neutral color used during the preparation of the glow effect.
  113465. * This is black by default as the blend operation is a blend operation.
  113466. */
  113467. static NeutralColor: Color4;
  113468. /**
  113469. * Stencil value used for glowing meshes.
  113470. */
  113471. static GlowingMeshStencilReference: number;
  113472. /**
  113473. * Stencil value used for the other meshes in the scene.
  113474. */
  113475. static NormalMeshStencilReference: number;
  113476. /**
  113477. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113478. */
  113479. innerGlow: boolean;
  113480. /**
  113481. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113482. */
  113483. outerGlow: boolean;
  113484. /**
  113485. * Specifies the horizontal size of the blur.
  113486. */
  113487. /**
  113488. * Gets the horizontal size of the blur.
  113489. */
  113490. blurHorizontalSize: number;
  113491. /**
  113492. * Specifies the vertical size of the blur.
  113493. */
  113494. /**
  113495. * Gets the vertical size of the blur.
  113496. */
  113497. blurVerticalSize: number;
  113498. /**
  113499. * An event triggered when the highlight layer is being blurred.
  113500. */
  113501. onBeforeBlurObservable: Observable<HighlightLayer>;
  113502. /**
  113503. * An event triggered when the highlight layer has been blurred.
  113504. */
  113505. onAfterBlurObservable: Observable<HighlightLayer>;
  113506. private _instanceGlowingMeshStencilReference;
  113507. private _options;
  113508. private _downSamplePostprocess;
  113509. private _horizontalBlurPostprocess;
  113510. private _verticalBlurPostprocess;
  113511. private _blurTexture;
  113512. private _meshes;
  113513. private _excludedMeshes;
  113514. /**
  113515. * Instantiates a new highlight Layer and references it to the scene..
  113516. * @param name The name of the layer
  113517. * @param scene The scene to use the layer in
  113518. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113519. */
  113520. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113521. /**
  113522. * Get the effect name of the layer.
  113523. * @return The effect name
  113524. */
  113525. getEffectName(): string;
  113526. /**
  113527. * Create the merge effect. This is the shader use to blit the information back
  113528. * to the main canvas at the end of the scene rendering.
  113529. */
  113530. protected _createMergeEffect(): Effect;
  113531. /**
  113532. * Creates the render target textures and post processes used in the highlight layer.
  113533. */
  113534. protected _createTextureAndPostProcesses(): void;
  113535. /**
  113536. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113537. */
  113538. needStencil(): boolean;
  113539. /**
  113540. * Checks for the readiness of the element composing the layer.
  113541. * @param subMesh the mesh to check for
  113542. * @param useInstances specify wether or not to use instances to render the mesh
  113543. * @param emissiveTexture the associated emissive texture used to generate the glow
  113544. * @return true if ready otherwise, false
  113545. */
  113546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113547. /**
  113548. * Implementation specific of rendering the generating effect on the main canvas.
  113549. * @param effect The effect used to render through
  113550. */
  113551. protected _internalRender(effect: Effect): void;
  113552. /**
  113553. * Returns true if the layer contains information to display, otherwise false.
  113554. */
  113555. shouldRender(): boolean;
  113556. /**
  113557. * Returns true if the mesh should render, otherwise false.
  113558. * @param mesh The mesh to render
  113559. * @returns true if it should render otherwise false
  113560. */
  113561. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113562. /**
  113563. * Sets the required values for both the emissive texture and and the main color.
  113564. */
  113565. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113566. /**
  113567. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113568. * @param mesh The mesh to exclude from the highlight layer
  113569. */
  113570. addExcludedMesh(mesh: Mesh): void;
  113571. /**
  113572. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113573. * @param mesh The mesh to highlight
  113574. */
  113575. removeExcludedMesh(mesh: Mesh): void;
  113576. /**
  113577. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113578. * @param mesh mesh to test
  113579. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113580. */
  113581. hasMesh(mesh: AbstractMesh): boolean;
  113582. /**
  113583. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113584. * @param mesh The mesh to highlight
  113585. * @param color The color of the highlight
  113586. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113587. */
  113588. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113589. /**
  113590. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113591. * @param mesh The mesh to highlight
  113592. */
  113593. removeMesh(mesh: Mesh): void;
  113594. /**
  113595. * Force the stencil to the normal expected value for none glowing parts
  113596. */
  113597. private _defaultStencilReference;
  113598. /**
  113599. * Free any resources and references associated to a mesh.
  113600. * Internal use
  113601. * @param mesh The mesh to free.
  113602. * @hidden
  113603. */
  113604. _disposeMesh(mesh: Mesh): void;
  113605. /**
  113606. * Dispose the highlight layer and free resources.
  113607. */
  113608. dispose(): void;
  113609. /**
  113610. * Gets the class name of the effect layer
  113611. * @returns the string with the class name of the effect layer
  113612. */
  113613. getClassName(): string;
  113614. /**
  113615. * Serializes this Highlight layer
  113616. * @returns a serialized Highlight layer object
  113617. */
  113618. serialize(): any;
  113619. /**
  113620. * Creates a Highlight layer from parsed Highlight layer data
  113621. * @param parsedHightlightLayer defines the Highlight layer data
  113622. * @param scene defines the current scene
  113623. * @param rootUrl defines the root URL containing the Highlight layer information
  113624. * @returns a parsed Highlight layer
  113625. */
  113626. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113627. }
  113628. }
  113629. declare module BABYLON {
  113630. interface AbstractScene {
  113631. /**
  113632. * The list of layers (background and foreground) of the scene
  113633. */
  113634. layers: Array<Layer>;
  113635. }
  113636. /**
  113637. * Defines the layer scene component responsible to manage any layers
  113638. * in a given scene.
  113639. */
  113640. export class LayerSceneComponent implements ISceneComponent {
  113641. /**
  113642. * The component name helpfull to identify the component in the list of scene components.
  113643. */
  113644. readonly name: string;
  113645. /**
  113646. * The scene the component belongs to.
  113647. */
  113648. scene: Scene;
  113649. private _engine;
  113650. /**
  113651. * Creates a new instance of the component for the given scene
  113652. * @param scene Defines the scene to register the component in
  113653. */
  113654. constructor(scene: Scene);
  113655. /**
  113656. * Registers the component in a given scene
  113657. */
  113658. register(): void;
  113659. /**
  113660. * Rebuilds the elements related to this component in case of
  113661. * context lost for instance.
  113662. */
  113663. rebuild(): void;
  113664. /**
  113665. * Disposes the component and the associated ressources.
  113666. */
  113667. dispose(): void;
  113668. private _draw;
  113669. private _drawCameraPredicate;
  113670. private _drawCameraBackground;
  113671. private _drawCameraForeground;
  113672. private _drawRenderTargetPredicate;
  113673. private _drawRenderTargetBackground;
  113674. private _drawRenderTargetForeground;
  113675. /**
  113676. * Adds all the elements from the container to the scene
  113677. * @param container the container holding the elements
  113678. */
  113679. addFromContainer(container: AbstractScene): void;
  113680. /**
  113681. * Removes all the elements in the container from the scene
  113682. * @param container contains the elements to remove
  113683. * @param dispose if the removed element should be disposed (default: false)
  113684. */
  113685. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113686. }
  113687. }
  113688. declare module BABYLON {
  113689. /** @hidden */
  113690. export var layerPixelShader: {
  113691. name: string;
  113692. shader: string;
  113693. };
  113694. }
  113695. declare module BABYLON {
  113696. /** @hidden */
  113697. export var layerVertexShader: {
  113698. name: string;
  113699. shader: string;
  113700. };
  113701. }
  113702. declare module BABYLON {
  113703. /**
  113704. * This represents a full screen 2d layer.
  113705. * This can be useful to display a picture in the background of your scene for instance.
  113706. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113707. */
  113708. export class Layer {
  113709. /**
  113710. * Define the name of the layer.
  113711. */
  113712. name: string;
  113713. /**
  113714. * Define the texture the layer should display.
  113715. */
  113716. texture: Nullable<Texture>;
  113717. /**
  113718. * Is the layer in background or foreground.
  113719. */
  113720. isBackground: boolean;
  113721. /**
  113722. * Define the color of the layer (instead of texture).
  113723. */
  113724. color: Color4;
  113725. /**
  113726. * Define the scale of the layer in order to zoom in out of the texture.
  113727. */
  113728. scale: Vector2;
  113729. /**
  113730. * Define an offset for the layer in order to shift the texture.
  113731. */
  113732. offset: Vector2;
  113733. /**
  113734. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113735. */
  113736. alphaBlendingMode: number;
  113737. /**
  113738. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113739. * Alpha test will not mix with the background color in case of transparency.
  113740. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113741. */
  113742. alphaTest: boolean;
  113743. /**
  113744. * Define a mask to restrict the layer to only some of the scene cameras.
  113745. */
  113746. layerMask: number;
  113747. /**
  113748. * Define the list of render target the layer is visible into.
  113749. */
  113750. renderTargetTextures: RenderTargetTexture[];
  113751. /**
  113752. * Define if the layer is only used in renderTarget or if it also
  113753. * renders in the main frame buffer of the canvas.
  113754. */
  113755. renderOnlyInRenderTargetTextures: boolean;
  113756. private _scene;
  113757. private _vertexBuffers;
  113758. private _indexBuffer;
  113759. private _effect;
  113760. private _alphaTestEffect;
  113761. /**
  113762. * An event triggered when the layer is disposed.
  113763. */
  113764. onDisposeObservable: Observable<Layer>;
  113765. private _onDisposeObserver;
  113766. /**
  113767. * Back compatibility with callback before the onDisposeObservable existed.
  113768. * The set callback will be triggered when the layer has been disposed.
  113769. */
  113770. onDispose: () => void;
  113771. /**
  113772. * An event triggered before rendering the scene
  113773. */
  113774. onBeforeRenderObservable: Observable<Layer>;
  113775. private _onBeforeRenderObserver;
  113776. /**
  113777. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113778. * The set callback will be triggered just before rendering the layer.
  113779. */
  113780. onBeforeRender: () => void;
  113781. /**
  113782. * An event triggered after rendering the scene
  113783. */
  113784. onAfterRenderObservable: Observable<Layer>;
  113785. private _onAfterRenderObserver;
  113786. /**
  113787. * Back compatibility with callback before the onAfterRenderObservable existed.
  113788. * The set callback will be triggered just after rendering the layer.
  113789. */
  113790. onAfterRender: () => void;
  113791. /**
  113792. * Instantiates a new layer.
  113793. * This represents a full screen 2d layer.
  113794. * This can be useful to display a picture in the background of your scene for instance.
  113795. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113796. * @param name Define the name of the layer in the scene
  113797. * @param imgUrl Define the url of the texture to display in the layer
  113798. * @param scene Define the scene the layer belongs to
  113799. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113800. * @param color Defines a color for the layer
  113801. */
  113802. constructor(
  113803. /**
  113804. * Define the name of the layer.
  113805. */
  113806. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113807. private _createIndexBuffer;
  113808. /** @hidden */
  113809. _rebuild(): void;
  113810. /**
  113811. * Renders the layer in the scene.
  113812. */
  113813. render(): void;
  113814. /**
  113815. * Disposes and releases the associated ressources.
  113816. */
  113817. dispose(): void;
  113818. }
  113819. }
  113820. declare module BABYLON {
  113821. /** @hidden */
  113822. export var lensFlarePixelShader: {
  113823. name: string;
  113824. shader: string;
  113825. };
  113826. }
  113827. declare module BABYLON {
  113828. /** @hidden */
  113829. export var lensFlareVertexShader: {
  113830. name: string;
  113831. shader: string;
  113832. };
  113833. }
  113834. declare module BABYLON {
  113835. /**
  113836. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113837. * It is usually composed of several `lensFlare`.
  113838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113839. */
  113840. export class LensFlareSystem {
  113841. /**
  113842. * Define the name of the lens flare system
  113843. */
  113844. name: string;
  113845. /**
  113846. * List of lens flares used in this system.
  113847. */
  113848. lensFlares: LensFlare[];
  113849. /**
  113850. * Define a limit from the border the lens flare can be visible.
  113851. */
  113852. borderLimit: number;
  113853. /**
  113854. * Define a viewport border we do not want to see the lens flare in.
  113855. */
  113856. viewportBorder: number;
  113857. /**
  113858. * Define a predicate which could limit the list of meshes able to occlude the effect.
  113859. */
  113860. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113861. /**
  113862. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  113863. */
  113864. layerMask: number;
  113865. /**
  113866. * Define the id of the lens flare system in the scene.
  113867. * (equal to name by default)
  113868. */
  113869. id: string;
  113870. private _scene;
  113871. private _emitter;
  113872. private _vertexBuffers;
  113873. private _indexBuffer;
  113874. private _effect;
  113875. private _positionX;
  113876. private _positionY;
  113877. private _isEnabled;
  113878. /** @hidden */
  113879. static _SceneComponentInitialization: (scene: Scene) => void;
  113880. /**
  113881. * Instantiates a lens flare system.
  113882. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113883. * It is usually composed of several `lensFlare`.
  113884. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113885. * @param name Define the name of the lens flare system in the scene
  113886. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  113887. * @param scene Define the scene the lens flare system belongs to
  113888. */
  113889. constructor(
  113890. /**
  113891. * Define the name of the lens flare system
  113892. */
  113893. name: string, emitter: any, scene: Scene);
  113894. /**
  113895. * Define if the lens flare system is enabled.
  113896. */
  113897. isEnabled: boolean;
  113898. /**
  113899. * Get the scene the effects belongs to.
  113900. * @returns the scene holding the lens flare system
  113901. */
  113902. getScene(): Scene;
  113903. /**
  113904. * Get the emitter of the lens flare system.
  113905. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113906. * @returns the emitter of the lens flare system
  113907. */
  113908. getEmitter(): any;
  113909. /**
  113910. * Set the emitter of the lens flare system.
  113911. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113912. * @param newEmitter Define the new emitter of the system
  113913. */
  113914. setEmitter(newEmitter: any): void;
  113915. /**
  113916. * Get the lens flare system emitter position.
  113917. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113918. * @returns the position
  113919. */
  113920. getEmitterPosition(): Vector3;
  113921. /**
  113922. * @hidden
  113923. */
  113924. computeEffectivePosition(globalViewport: Viewport): boolean;
  113925. /** @hidden */
  113926. _isVisible(): boolean;
  113927. /**
  113928. * @hidden
  113929. */
  113930. render(): boolean;
  113931. /**
  113932. * Dispose and release the lens flare with its associated resources.
  113933. */
  113934. dispose(): void;
  113935. /**
  113936. * Parse a lens flare system from a JSON repressentation
  113937. * @param parsedLensFlareSystem Define the JSON to parse
  113938. * @param scene Define the scene the parsed system should be instantiated in
  113939. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113940. * @returns the parsed system
  113941. */
  113942. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113943. /**
  113944. * Serialize the current Lens Flare System into a JSON representation.
  113945. * @returns the serialized JSON
  113946. */
  113947. serialize(): any;
  113948. }
  113949. }
  113950. declare module BABYLON {
  113951. /**
  113952. * This represents one of the lens effect in a `lensFlareSystem`.
  113953. * It controls one of the indiviual texture used in the effect.
  113954. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113955. */
  113956. export class LensFlare {
  113957. /**
  113958. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113959. */
  113960. size: number;
  113961. /**
  113962. * 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.
  113963. */
  113964. position: number;
  113965. /**
  113966. * Define the lens color.
  113967. */
  113968. color: Color3;
  113969. /**
  113970. * Define the lens texture.
  113971. */
  113972. texture: Nullable<Texture>;
  113973. /**
  113974. * Define the alpha mode to render this particular lens.
  113975. */
  113976. alphaMode: number;
  113977. private _system;
  113978. /**
  113979. * Creates a new Lens Flare.
  113980. * This represents one of the lens effect in a `lensFlareSystem`.
  113981. * It controls one of the indiviual texture used in the effect.
  113982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113983. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113984. * @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.
  113985. * @param color Define the lens color
  113986. * @param imgUrl Define the lens texture url
  113987. * @param system Define the `lensFlareSystem` this flare is part of
  113988. * @returns The newly created Lens Flare
  113989. */
  113990. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113991. /**
  113992. * Instantiates a new Lens Flare.
  113993. * This represents one of the lens effect in a `lensFlareSystem`.
  113994. * It controls one of the indiviual texture used in the effect.
  113995. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113996. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113997. * @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.
  113998. * @param color Define the lens color
  113999. * @param imgUrl Define the lens texture url
  114000. * @param system Define the `lensFlareSystem` this flare is part of
  114001. */
  114002. constructor(
  114003. /**
  114004. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114005. */
  114006. size: number,
  114007. /**
  114008. * 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.
  114009. */
  114010. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114011. /**
  114012. * Dispose and release the lens flare with its associated resources.
  114013. */
  114014. dispose(): void;
  114015. }
  114016. }
  114017. declare module BABYLON {
  114018. interface AbstractScene {
  114019. /**
  114020. * The list of lens flare system added to the scene
  114021. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114022. */
  114023. lensFlareSystems: Array<LensFlareSystem>;
  114024. /**
  114025. * Removes the given lens flare system from this scene.
  114026. * @param toRemove The lens flare system to remove
  114027. * @returns The index of the removed lens flare system
  114028. */
  114029. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114030. /**
  114031. * Adds the given lens flare system to this scene
  114032. * @param newLensFlareSystem The lens flare system to add
  114033. */
  114034. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114035. /**
  114036. * Gets a lens flare system using its name
  114037. * @param name defines the name to look for
  114038. * @returns the lens flare system or null if not found
  114039. */
  114040. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114041. /**
  114042. * Gets a lens flare system using its id
  114043. * @param id defines the id to look for
  114044. * @returns the lens flare system or null if not found
  114045. */
  114046. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114047. }
  114048. /**
  114049. * Defines the lens flare scene component responsible to manage any lens flares
  114050. * in a given scene.
  114051. */
  114052. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114053. /**
  114054. * The component name helpfull to identify the component in the list of scene components.
  114055. */
  114056. readonly name: string;
  114057. /**
  114058. * The scene the component belongs to.
  114059. */
  114060. scene: Scene;
  114061. /**
  114062. * Creates a new instance of the component for the given scene
  114063. * @param scene Defines the scene to register the component in
  114064. */
  114065. constructor(scene: Scene);
  114066. /**
  114067. * Registers the component in a given scene
  114068. */
  114069. register(): void;
  114070. /**
  114071. * Rebuilds the elements related to this component in case of
  114072. * context lost for instance.
  114073. */
  114074. rebuild(): void;
  114075. /**
  114076. * Adds all the elements from the container to the scene
  114077. * @param container the container holding the elements
  114078. */
  114079. addFromContainer(container: AbstractScene): void;
  114080. /**
  114081. * Removes all the elements in the container from the scene
  114082. * @param container contains the elements to remove
  114083. * @param dispose if the removed element should be disposed (default: false)
  114084. */
  114085. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114086. /**
  114087. * Serializes the component data to the specified json object
  114088. * @param serializationObject The object to serialize to
  114089. */
  114090. serialize(serializationObject: any): void;
  114091. /**
  114092. * Disposes the component and the associated ressources.
  114093. */
  114094. dispose(): void;
  114095. private _draw;
  114096. }
  114097. }
  114098. declare module BABYLON {
  114099. /**
  114100. * Defines the shadow generator component responsible to manage any shadow generators
  114101. * in a given scene.
  114102. */
  114103. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114104. /**
  114105. * The component name helpfull to identify the component in the list of scene components.
  114106. */
  114107. readonly name: string;
  114108. /**
  114109. * The scene the component belongs to.
  114110. */
  114111. scene: Scene;
  114112. /**
  114113. * Creates a new instance of the component for the given scene
  114114. * @param scene Defines the scene to register the component in
  114115. */
  114116. constructor(scene: Scene);
  114117. /**
  114118. * Registers the component in a given scene
  114119. */
  114120. register(): void;
  114121. /**
  114122. * Rebuilds the elements related to this component in case of
  114123. * context lost for instance.
  114124. */
  114125. rebuild(): void;
  114126. /**
  114127. * Serializes the component data to the specified json object
  114128. * @param serializationObject The object to serialize to
  114129. */
  114130. serialize(serializationObject: any): void;
  114131. /**
  114132. * Adds all the elements from the container to the scene
  114133. * @param container the container holding the elements
  114134. */
  114135. addFromContainer(container: AbstractScene): void;
  114136. /**
  114137. * Removes all the elements in the container from the scene
  114138. * @param container contains the elements to remove
  114139. * @param dispose if the removed element should be disposed (default: false)
  114140. */
  114141. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114142. /**
  114143. * Rebuilds the elements related to this component in case of
  114144. * context lost for instance.
  114145. */
  114146. dispose(): void;
  114147. private _gatherRenderTargets;
  114148. }
  114149. }
  114150. declare module BABYLON {
  114151. /**
  114152. * A point light is a light defined by an unique point in world space.
  114153. * The light is emitted in every direction from this point.
  114154. * A good example of a point light is a standard light bulb.
  114155. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114156. */
  114157. export class PointLight extends ShadowLight {
  114158. private _shadowAngle;
  114159. /**
  114160. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114161. * This specifies what angle the shadow will use to be created.
  114162. *
  114163. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114164. */
  114165. /**
  114166. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114167. * This specifies what angle the shadow will use to be created.
  114168. *
  114169. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114170. */
  114171. shadowAngle: number;
  114172. /**
  114173. * Gets the direction if it has been set.
  114174. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114175. */
  114176. /**
  114177. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114178. */
  114179. direction: Vector3;
  114180. /**
  114181. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114182. * A PointLight emits the light in every direction.
  114183. * It can cast shadows.
  114184. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114185. * ```javascript
  114186. * var pointLight = new PointLight("pl", camera.position, scene);
  114187. * ```
  114188. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114189. * @param name The light friendly name
  114190. * @param position The position of the point light in the scene
  114191. * @param scene The scene the lights belongs to
  114192. */
  114193. constructor(name: string, position: Vector3, scene: Scene);
  114194. /**
  114195. * Returns the string "PointLight"
  114196. * @returns the class name
  114197. */
  114198. getClassName(): string;
  114199. /**
  114200. * Returns the integer 0.
  114201. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114202. */
  114203. getTypeID(): number;
  114204. /**
  114205. * Specifies wether or not the shadowmap should be a cube texture.
  114206. * @returns true if the shadowmap needs to be a cube texture.
  114207. */
  114208. needCube(): boolean;
  114209. /**
  114210. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114213. */
  114214. getShadowDirection(faceIndex?: number): Vector3;
  114215. /**
  114216. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114217. * - fov = PI / 2
  114218. * - aspect ratio : 1.0
  114219. * - z-near and far equal to the active camera minZ and maxZ.
  114220. * Returns the PointLight.
  114221. */
  114222. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114223. protected _buildUniformLayout(): void;
  114224. /**
  114225. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114226. * @param effect The effect to update
  114227. * @param lightIndex The index of the light in the effect to update
  114228. * @returns The point light
  114229. */
  114230. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114231. /**
  114232. * Prepares the list of defines specific to the light type.
  114233. * @param defines the list of defines
  114234. * @param lightIndex defines the index of the light for the effect
  114235. */
  114236. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114237. }
  114238. }
  114239. declare module BABYLON {
  114240. /**
  114241. * Header information of HDR texture files.
  114242. */
  114243. export interface HDRInfo {
  114244. /**
  114245. * The height of the texture in pixels.
  114246. */
  114247. height: number;
  114248. /**
  114249. * The width of the texture in pixels.
  114250. */
  114251. width: number;
  114252. /**
  114253. * The index of the beginning of the data in the binary file.
  114254. */
  114255. dataPosition: number;
  114256. }
  114257. /**
  114258. * This groups tools to convert HDR texture to native colors array.
  114259. */
  114260. export class HDRTools {
  114261. private static Ldexp;
  114262. private static Rgbe2float;
  114263. private static readStringLine;
  114264. /**
  114265. * Reads header information from an RGBE texture stored in a native array.
  114266. * More information on this format are available here:
  114267. * https://en.wikipedia.org/wiki/RGBE_image_format
  114268. *
  114269. * @param uint8array The binary file stored in native array.
  114270. * @return The header information.
  114271. */
  114272. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114273. /**
  114274. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114275. * This RGBE texture needs to store the information as a panorama.
  114276. *
  114277. * More information on this format are available here:
  114278. * https://en.wikipedia.org/wiki/RGBE_image_format
  114279. *
  114280. * @param buffer The binary file stored in an array buffer.
  114281. * @param size The expected size of the extracted cubemap.
  114282. * @return The Cube Map information.
  114283. */
  114284. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114285. /**
  114286. * Returns the pixels data extracted from an RGBE texture.
  114287. * This pixels will be stored left to right up to down in the R G B order in one array.
  114288. *
  114289. * More information on this format are available here:
  114290. * https://en.wikipedia.org/wiki/RGBE_image_format
  114291. *
  114292. * @param uint8array The binary file stored in an array buffer.
  114293. * @param hdrInfo The header information of the file.
  114294. * @return The pixels data in RGB right to left up to down order.
  114295. */
  114296. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114297. private static RGBE_ReadPixels_RLE;
  114298. }
  114299. }
  114300. declare module BABYLON {
  114301. /**
  114302. * This represents a texture coming from an HDR input.
  114303. *
  114304. * The only supported format is currently panorama picture stored in RGBE format.
  114305. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114306. */
  114307. export class HDRCubeTexture extends BaseTexture {
  114308. private static _facesMapping;
  114309. private _generateHarmonics;
  114310. private _noMipmap;
  114311. private _textureMatrix;
  114312. private _size;
  114313. private _onLoad;
  114314. private _onError;
  114315. /**
  114316. * The texture URL.
  114317. */
  114318. url: string;
  114319. /**
  114320. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114321. */
  114322. coordinatesMode: number;
  114323. protected _isBlocking: boolean;
  114324. /**
  114325. * Sets wether or not the texture is blocking during loading.
  114326. */
  114327. /**
  114328. * Gets wether or not the texture is blocking during loading.
  114329. */
  114330. isBlocking: boolean;
  114331. protected _rotationY: number;
  114332. /**
  114333. * Sets texture matrix rotation angle around Y axis in radians.
  114334. */
  114335. /**
  114336. * Gets texture matrix rotation angle around Y axis radians.
  114337. */
  114338. rotationY: number;
  114339. /**
  114340. * Gets or sets the center of the bounding box associated with the cube texture
  114341. * It must define where the camera used to render the texture was set
  114342. */
  114343. boundingBoxPosition: Vector3;
  114344. private _boundingBoxSize;
  114345. /**
  114346. * Gets or sets the size of the bounding box associated with the cube texture
  114347. * When defined, the cubemap will switch to local mode
  114348. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114349. * @example https://www.babylonjs-playground.com/#RNASML
  114350. */
  114351. boundingBoxSize: Vector3;
  114352. /**
  114353. * Instantiates an HDRTexture from the following parameters.
  114354. *
  114355. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114356. * @param scene The scene the texture will be used in
  114357. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114358. * @param noMipmap Forces to not generate the mipmap if true
  114359. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114360. * @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)
  114361. * @param reserved Reserved flag for internal use.
  114362. */
  114363. 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>);
  114364. /**
  114365. * Get the current class name of the texture useful for serialization or dynamic coding.
  114366. * @returns "HDRCubeTexture"
  114367. */
  114368. getClassName(): string;
  114369. /**
  114370. * Occurs when the file is raw .hdr file.
  114371. */
  114372. private loadTexture;
  114373. clone(): HDRCubeTexture;
  114374. delayLoad(): void;
  114375. /**
  114376. * Get the texture reflection matrix used to rotate/transform the reflection.
  114377. * @returns the reflection matrix
  114378. */
  114379. getReflectionTextureMatrix(): Matrix;
  114380. /**
  114381. * Set the texture reflection matrix used to rotate/transform the reflection.
  114382. * @param value Define the reflection matrix to set
  114383. */
  114384. setReflectionTextureMatrix(value: Matrix): void;
  114385. /**
  114386. * Parses a JSON representation of an HDR Texture in order to create the texture
  114387. * @param parsedTexture Define the JSON representation
  114388. * @param scene Define the scene the texture should be created in
  114389. * @param rootUrl Define the root url in case we need to load relative dependencies
  114390. * @returns the newly created texture after parsing
  114391. */
  114392. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114393. serialize(): any;
  114394. }
  114395. }
  114396. declare module BABYLON {
  114397. /**
  114398. * Class used to control physics engine
  114399. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114400. */
  114401. export class PhysicsEngine implements IPhysicsEngine {
  114402. private _physicsPlugin;
  114403. /**
  114404. * Global value used to control the smallest number supported by the simulation
  114405. */
  114406. static Epsilon: number;
  114407. private _impostors;
  114408. private _joints;
  114409. /**
  114410. * Gets the gravity vector used by the simulation
  114411. */
  114412. gravity: Vector3;
  114413. /**
  114414. * Factory used to create the default physics plugin.
  114415. * @returns The default physics plugin
  114416. */
  114417. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114418. /**
  114419. * Creates a new Physics Engine
  114420. * @param gravity defines the gravity vector used by the simulation
  114421. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114422. */
  114423. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114424. /**
  114425. * Sets the gravity vector used by the simulation
  114426. * @param gravity defines the gravity vector to use
  114427. */
  114428. setGravity(gravity: Vector3): void;
  114429. /**
  114430. * Set the time step of the physics engine.
  114431. * Default is 1/60.
  114432. * To slow it down, enter 1/600 for example.
  114433. * To speed it up, 1/30
  114434. * @param newTimeStep defines the new timestep to apply to this world.
  114435. */
  114436. setTimeStep(newTimeStep?: number): void;
  114437. /**
  114438. * Get the time step of the physics engine.
  114439. * @returns the current time step
  114440. */
  114441. getTimeStep(): number;
  114442. /**
  114443. * Release all resources
  114444. */
  114445. dispose(): void;
  114446. /**
  114447. * Gets the name of the current physics plugin
  114448. * @returns the name of the plugin
  114449. */
  114450. getPhysicsPluginName(): string;
  114451. /**
  114452. * Adding a new impostor for the impostor tracking.
  114453. * This will be done by the impostor itself.
  114454. * @param impostor the impostor to add
  114455. */
  114456. addImpostor(impostor: PhysicsImpostor): void;
  114457. /**
  114458. * Remove an impostor from the engine.
  114459. * This impostor and its mesh will not longer be updated by the physics engine.
  114460. * @param impostor the impostor to remove
  114461. */
  114462. removeImpostor(impostor: PhysicsImpostor): void;
  114463. /**
  114464. * Add a joint to the physics engine
  114465. * @param mainImpostor defines the main impostor to which the joint is added.
  114466. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114467. * @param joint defines the joint that will connect both impostors.
  114468. */
  114469. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114470. /**
  114471. * Removes a joint from the simulation
  114472. * @param mainImpostor defines the impostor used with the joint
  114473. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114474. * @param joint defines the joint to remove
  114475. */
  114476. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114477. /**
  114478. * Called by the scene. No need to call it.
  114479. * @param delta defines the timespam between frames
  114480. */
  114481. _step(delta: number): void;
  114482. /**
  114483. * Gets the current plugin used to run the simulation
  114484. * @returns current plugin
  114485. */
  114486. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114487. /**
  114488. * Gets the list of physic impostors
  114489. * @returns an array of PhysicsImpostor
  114490. */
  114491. getImpostors(): Array<PhysicsImpostor>;
  114492. /**
  114493. * Gets the impostor for a physics enabled object
  114494. * @param object defines the object impersonated by the impostor
  114495. * @returns the PhysicsImpostor or null if not found
  114496. */
  114497. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114498. /**
  114499. * Gets the impostor for a physics body object
  114500. * @param body defines physics body used by the impostor
  114501. * @returns the PhysicsImpostor or null if not found
  114502. */
  114503. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114504. /**
  114505. * Does a raycast in the physics world
  114506. * @param from when should the ray start?
  114507. * @param to when should the ray end?
  114508. * @returns PhysicsRaycastResult
  114509. */
  114510. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114511. }
  114512. }
  114513. declare module BABYLON {
  114514. /** @hidden */
  114515. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114516. private _useDeltaForWorldStep;
  114517. world: any;
  114518. name: string;
  114519. private _physicsMaterials;
  114520. private _fixedTimeStep;
  114521. private _cannonRaycastResult;
  114522. private _raycastResult;
  114523. private _physicsBodysToRemoveAfterStep;
  114524. BJSCANNON: any;
  114525. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114526. setGravity(gravity: Vector3): void;
  114527. setTimeStep(timeStep: number): void;
  114528. getTimeStep(): number;
  114529. executeStep(delta: number): void;
  114530. private _removeMarkedPhysicsBodiesFromWorld;
  114531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114534. private _processChildMeshes;
  114535. removePhysicsBody(impostor: PhysicsImpostor): void;
  114536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114538. private _addMaterial;
  114539. private _checkWithEpsilon;
  114540. private _createShape;
  114541. private _createHeightmap;
  114542. private _minus90X;
  114543. private _plus90X;
  114544. private _tmpPosition;
  114545. private _tmpDeltaPosition;
  114546. private _tmpUnityRotation;
  114547. private _updatePhysicsBodyTransformation;
  114548. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114549. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114550. isSupported(): boolean;
  114551. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114552. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114553. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114554. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114555. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114556. getBodyMass(impostor: PhysicsImpostor): number;
  114557. getBodyFriction(impostor: PhysicsImpostor): number;
  114558. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114559. getBodyRestitution(impostor: PhysicsImpostor): number;
  114560. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114561. sleepBody(impostor: PhysicsImpostor): void;
  114562. wakeUpBody(impostor: PhysicsImpostor): void;
  114563. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114564. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114565. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114566. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114567. getRadius(impostor: PhysicsImpostor): number;
  114568. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114569. dispose(): void;
  114570. private _extendNamespace;
  114571. /**
  114572. * Does a raycast in the physics world
  114573. * @param from when should the ray start?
  114574. * @param to when should the ray end?
  114575. * @returns PhysicsRaycastResult
  114576. */
  114577. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114578. }
  114579. }
  114580. declare module BABYLON {
  114581. /** @hidden */
  114582. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114583. world: any;
  114584. name: string;
  114585. BJSOIMO: any;
  114586. private _raycastResult;
  114587. constructor(iterations?: number, oimoInjection?: any);
  114588. setGravity(gravity: Vector3): void;
  114589. setTimeStep(timeStep: number): void;
  114590. getTimeStep(): number;
  114591. private _tmpImpostorsArray;
  114592. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114593. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114594. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114595. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114596. private _tmpPositionVector;
  114597. removePhysicsBody(impostor: PhysicsImpostor): void;
  114598. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114599. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114600. isSupported(): boolean;
  114601. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114602. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114603. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114604. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114605. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114606. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114607. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114608. getBodyMass(impostor: PhysicsImpostor): number;
  114609. getBodyFriction(impostor: PhysicsImpostor): number;
  114610. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114611. getBodyRestitution(impostor: PhysicsImpostor): number;
  114612. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114613. sleepBody(impostor: PhysicsImpostor): void;
  114614. wakeUpBody(impostor: PhysicsImpostor): void;
  114615. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114616. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114617. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114618. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114619. getRadius(impostor: PhysicsImpostor): number;
  114620. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114621. dispose(): void;
  114622. /**
  114623. * Does a raycast in the physics world
  114624. * @param from when should the ray start?
  114625. * @param to when should the ray end?
  114626. * @returns PhysicsRaycastResult
  114627. */
  114628. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114629. }
  114630. }
  114631. declare module BABYLON {
  114632. /**
  114633. * Class containing static functions to help procedurally build meshes
  114634. */
  114635. export class RibbonBuilder {
  114636. /**
  114637. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114638. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114639. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114640. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114641. * * 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
  114642. * * 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
  114643. * * 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
  114644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114647. * * 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
  114648. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114649. * * 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
  114650. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114652. * @param name defines the name of the mesh
  114653. * @param options defines the options used to create the mesh
  114654. * @param scene defines the hosting scene
  114655. * @returns the ribbon mesh
  114656. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114658. */
  114659. static CreateRibbon(name: string, options: {
  114660. pathArray: Vector3[][];
  114661. closeArray?: boolean;
  114662. closePath?: boolean;
  114663. offset?: number;
  114664. updatable?: boolean;
  114665. sideOrientation?: number;
  114666. frontUVs?: Vector4;
  114667. backUVs?: Vector4;
  114668. instance?: Mesh;
  114669. invertUV?: boolean;
  114670. uvs?: Vector2[];
  114671. colors?: Color4[];
  114672. }, scene?: Nullable<Scene>): Mesh;
  114673. }
  114674. }
  114675. declare module BABYLON {
  114676. /**
  114677. * Class containing static functions to help procedurally build meshes
  114678. */
  114679. export class ShapeBuilder {
  114680. /**
  114681. * 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.
  114682. * * 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.
  114683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114684. * * 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.
  114685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114686. * * 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
  114687. * * 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
  114688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114693. * @param name defines the name of the mesh
  114694. * @param options defines the options used to create the mesh
  114695. * @param scene defines the hosting scene
  114696. * @returns the extruded shape mesh
  114697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114699. */
  114700. static ExtrudeShape(name: string, options: {
  114701. shape: Vector3[];
  114702. path: Vector3[];
  114703. scale?: number;
  114704. rotation?: number;
  114705. cap?: number;
  114706. updatable?: boolean;
  114707. sideOrientation?: number;
  114708. frontUVs?: Vector4;
  114709. backUVs?: Vector4;
  114710. instance?: Mesh;
  114711. invertUV?: boolean;
  114712. }, scene?: Nullable<Scene>): Mesh;
  114713. /**
  114714. * Creates an custom extruded shape mesh.
  114715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114716. * * 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.
  114717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114718. * * 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
  114719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114720. * * 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
  114721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114724. * * 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
  114725. * * 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
  114726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114731. * @param name defines the name of the mesh
  114732. * @param options defines the options used to create the mesh
  114733. * @param scene defines the hosting scene
  114734. * @returns the custom extruded shape mesh
  114735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114738. */
  114739. static ExtrudeShapeCustom(name: string, options: {
  114740. shape: Vector3[];
  114741. path: Vector3[];
  114742. scaleFunction?: any;
  114743. rotationFunction?: any;
  114744. ribbonCloseArray?: boolean;
  114745. ribbonClosePath?: boolean;
  114746. cap?: number;
  114747. updatable?: boolean;
  114748. sideOrientation?: number;
  114749. frontUVs?: Vector4;
  114750. backUVs?: Vector4;
  114751. instance?: Mesh;
  114752. invertUV?: boolean;
  114753. }, scene?: Nullable<Scene>): Mesh;
  114754. private static _ExtrudeShapeGeneric;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. /**
  114759. * AmmoJS Physics plugin
  114760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114761. * @see https://github.com/kripken/ammo.js/
  114762. */
  114763. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114764. private _useDeltaForWorldStep;
  114765. /**
  114766. * Reference to the Ammo library
  114767. */
  114768. bjsAMMO: any;
  114769. /**
  114770. * Created ammoJS world which physics bodies are added to
  114771. */
  114772. world: any;
  114773. /**
  114774. * Name of the plugin
  114775. */
  114776. name: string;
  114777. private _timeStep;
  114778. private _fixedTimeStep;
  114779. private _maxSteps;
  114780. private _tmpQuaternion;
  114781. private _tmpAmmoTransform;
  114782. private _tmpAmmoQuaternion;
  114783. private _tmpAmmoConcreteContactResultCallback;
  114784. private _collisionConfiguration;
  114785. private _dispatcher;
  114786. private _overlappingPairCache;
  114787. private _solver;
  114788. private _softBodySolver;
  114789. private _tmpAmmoVectorA;
  114790. private _tmpAmmoVectorB;
  114791. private _tmpAmmoVectorC;
  114792. private _tmpAmmoVectorD;
  114793. private _tmpContactCallbackResult;
  114794. private _tmpAmmoVectorRCA;
  114795. private _tmpAmmoVectorRCB;
  114796. private _raycastResult;
  114797. private static readonly DISABLE_COLLISION_FLAG;
  114798. private static readonly KINEMATIC_FLAG;
  114799. private static readonly DISABLE_DEACTIVATION_FLAG;
  114800. /**
  114801. * Initializes the ammoJS plugin
  114802. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114803. * @param ammoInjection can be used to inject your own ammo reference
  114804. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114805. */
  114806. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114807. /**
  114808. * Sets the gravity of the physics world (m/(s^2))
  114809. * @param gravity Gravity to set
  114810. */
  114811. setGravity(gravity: Vector3): void;
  114812. /**
  114813. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114814. * @param timeStep timestep to use in seconds
  114815. */
  114816. setTimeStep(timeStep: number): void;
  114817. /**
  114818. * 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)
  114819. * @param fixedTimeStep fixedTimeStep to use in seconds
  114820. */
  114821. setFixedTimeStep(fixedTimeStep: number): void;
  114822. /**
  114823. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114824. * @param maxSteps the maximum number of steps by the physics engine per frame
  114825. */
  114826. setMaxSteps(maxSteps: number): void;
  114827. /**
  114828. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114829. * @returns the current timestep in seconds
  114830. */
  114831. getTimeStep(): number;
  114832. private _isImpostorInContact;
  114833. private _isImpostorPairInContact;
  114834. private _stepSimulation;
  114835. /**
  114836. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114837. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114838. * After the step the babylon meshes are set to the position of the physics imposters
  114839. * @param delta amount of time to step forward
  114840. * @param impostors array of imposters to update before/after the step
  114841. */
  114842. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114843. /**
  114844. * Update babylon mesh to match physics world object
  114845. * @param impostor imposter to match
  114846. */
  114847. private _afterSoftStep;
  114848. /**
  114849. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114850. * @param impostor imposter to match
  114851. */
  114852. private _ropeStep;
  114853. /**
  114854. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114855. * @param impostor imposter to match
  114856. */
  114857. private _softbodyOrClothStep;
  114858. private _tmpVector;
  114859. private _tmpMatrix;
  114860. /**
  114861. * Applies an impulse on the imposter
  114862. * @param impostor imposter to apply impulse to
  114863. * @param force amount of force to be applied to the imposter
  114864. * @param contactPoint the location to apply the impulse on the imposter
  114865. */
  114866. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114867. /**
  114868. * Applies a force on the imposter
  114869. * @param impostor imposter to apply force
  114870. * @param force amount of force to be applied to the imposter
  114871. * @param contactPoint the location to apply the force on the imposter
  114872. */
  114873. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114874. /**
  114875. * Creates a physics body using the plugin
  114876. * @param impostor the imposter to create the physics body on
  114877. */
  114878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114879. /**
  114880. * Removes the physics body from the imposter and disposes of the body's memory
  114881. * @param impostor imposter to remove the physics body from
  114882. */
  114883. removePhysicsBody(impostor: PhysicsImpostor): void;
  114884. /**
  114885. * Generates a joint
  114886. * @param impostorJoint the imposter joint to create the joint with
  114887. */
  114888. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114889. /**
  114890. * Removes a joint
  114891. * @param impostorJoint the imposter joint to remove the joint from
  114892. */
  114893. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114894. private _addMeshVerts;
  114895. /**
  114896. * Initialise the soft body vertices to match its object's (mesh) vertices
  114897. * Softbody vertices (nodes) are in world space and to match this
  114898. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114899. * @param impostor to create the softbody for
  114900. */
  114901. private _softVertexData;
  114902. /**
  114903. * Create an impostor's soft body
  114904. * @param impostor to create the softbody for
  114905. */
  114906. private _createSoftbody;
  114907. /**
  114908. * Create cloth for an impostor
  114909. * @param impostor to create the softbody for
  114910. */
  114911. private _createCloth;
  114912. /**
  114913. * Create rope for an impostor
  114914. * @param impostor to create the softbody for
  114915. */
  114916. private _createRope;
  114917. private _addHullVerts;
  114918. private _createShape;
  114919. /**
  114920. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114921. * @param impostor imposter containing the physics body and babylon object
  114922. */
  114923. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114924. /**
  114925. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114926. * @param impostor imposter containing the physics body and babylon object
  114927. * @param newPosition new position
  114928. * @param newRotation new rotation
  114929. */
  114930. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114931. /**
  114932. * If this plugin is supported
  114933. * @returns true if its supported
  114934. */
  114935. isSupported(): boolean;
  114936. /**
  114937. * Sets the linear velocity of the physics body
  114938. * @param impostor imposter to set the velocity on
  114939. * @param velocity velocity to set
  114940. */
  114941. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114942. /**
  114943. * Sets the angular velocity of the physics body
  114944. * @param impostor imposter to set the velocity on
  114945. * @param velocity velocity to set
  114946. */
  114947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114948. /**
  114949. * gets the linear velocity
  114950. * @param impostor imposter to get linear velocity from
  114951. * @returns linear velocity
  114952. */
  114953. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114954. /**
  114955. * gets the angular velocity
  114956. * @param impostor imposter to get angular velocity from
  114957. * @returns angular velocity
  114958. */
  114959. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114960. /**
  114961. * Sets the mass of physics body
  114962. * @param impostor imposter to set the mass on
  114963. * @param mass mass to set
  114964. */
  114965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114966. /**
  114967. * Gets the mass of the physics body
  114968. * @param impostor imposter to get the mass from
  114969. * @returns mass
  114970. */
  114971. getBodyMass(impostor: PhysicsImpostor): number;
  114972. /**
  114973. * Gets friction of the impostor
  114974. * @param impostor impostor to get friction from
  114975. * @returns friction value
  114976. */
  114977. getBodyFriction(impostor: PhysicsImpostor): number;
  114978. /**
  114979. * Sets friction of the impostor
  114980. * @param impostor impostor to set friction on
  114981. * @param friction friction value
  114982. */
  114983. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114984. /**
  114985. * Gets restitution of the impostor
  114986. * @param impostor impostor to get restitution from
  114987. * @returns restitution value
  114988. */
  114989. getBodyRestitution(impostor: PhysicsImpostor): number;
  114990. /**
  114991. * Sets resitution of the impostor
  114992. * @param impostor impostor to set resitution on
  114993. * @param restitution resitution value
  114994. */
  114995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114996. /**
  114997. * Gets pressure inside the impostor
  114998. * @param impostor impostor to get pressure from
  114999. * @returns pressure value
  115000. */
  115001. getBodyPressure(impostor: PhysicsImpostor): number;
  115002. /**
  115003. * Sets pressure inside a soft body impostor
  115004. * Cloth and rope must remain 0 pressure
  115005. * @param impostor impostor to set pressure on
  115006. * @param pressure pressure value
  115007. */
  115008. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115009. /**
  115010. * Gets stiffness of the impostor
  115011. * @param impostor impostor to get stiffness from
  115012. * @returns pressure value
  115013. */
  115014. getBodyStiffness(impostor: PhysicsImpostor): number;
  115015. /**
  115016. * Sets stiffness of the impostor
  115017. * @param impostor impostor to set stiffness on
  115018. * @param stiffness stiffness value from 0 to 1
  115019. */
  115020. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115021. /**
  115022. * Gets velocityIterations of the impostor
  115023. * @param impostor impostor to get velocity iterations from
  115024. * @returns velocityIterations value
  115025. */
  115026. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115027. /**
  115028. * Sets velocityIterations of the impostor
  115029. * @param impostor impostor to set velocity iterations on
  115030. * @param velocityIterations velocityIterations value
  115031. */
  115032. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115033. /**
  115034. * Gets positionIterations of the impostor
  115035. * @param impostor impostor to get position iterations from
  115036. * @returns positionIterations value
  115037. */
  115038. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115039. /**
  115040. * Sets positionIterations of the impostor
  115041. * @param impostor impostor to set position on
  115042. * @param positionIterations positionIterations value
  115043. */
  115044. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115045. /**
  115046. * Append an anchor to a cloth object
  115047. * @param impostor is the cloth impostor to add anchor to
  115048. * @param otherImpostor is the rigid impostor to anchor to
  115049. * @param width ratio across width from 0 to 1
  115050. * @param height ratio up height from 0 to 1
  115051. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115052. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115053. */
  115054. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115055. /**
  115056. * Append an hook to a rope object
  115057. * @param impostor is the rope impostor to add hook to
  115058. * @param otherImpostor is the rigid impostor to hook to
  115059. * @param length ratio along the rope from 0 to 1
  115060. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115061. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115062. */
  115063. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115064. /**
  115065. * Sleeps the physics body and stops it from being active
  115066. * @param impostor impostor to sleep
  115067. */
  115068. sleepBody(impostor: PhysicsImpostor): void;
  115069. /**
  115070. * Activates the physics body
  115071. * @param impostor impostor to activate
  115072. */
  115073. wakeUpBody(impostor: PhysicsImpostor): void;
  115074. /**
  115075. * Updates the distance parameters of the joint
  115076. * @param joint joint to update
  115077. * @param maxDistance maximum distance of the joint
  115078. * @param minDistance minimum distance of the joint
  115079. */
  115080. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115081. /**
  115082. * Sets a motor on the joint
  115083. * @param joint joint to set motor on
  115084. * @param speed speed of the motor
  115085. * @param maxForce maximum force of the motor
  115086. * @param motorIndex index of the motor
  115087. */
  115088. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115089. /**
  115090. * Sets the motors limit
  115091. * @param joint joint to set limit on
  115092. * @param upperLimit upper limit
  115093. * @param lowerLimit lower limit
  115094. */
  115095. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115096. /**
  115097. * Syncs the position and rotation of a mesh with the impostor
  115098. * @param mesh mesh to sync
  115099. * @param impostor impostor to update the mesh with
  115100. */
  115101. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115102. /**
  115103. * Gets the radius of the impostor
  115104. * @param impostor impostor to get radius from
  115105. * @returns the radius
  115106. */
  115107. getRadius(impostor: PhysicsImpostor): number;
  115108. /**
  115109. * Gets the box size of the impostor
  115110. * @param impostor impostor to get box size from
  115111. * @param result the resulting box size
  115112. */
  115113. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115114. /**
  115115. * Disposes of the impostor
  115116. */
  115117. dispose(): void;
  115118. /**
  115119. * Does a raycast in the physics world
  115120. * @param from when should the ray start?
  115121. * @param to when should the ray end?
  115122. * @returns PhysicsRaycastResult
  115123. */
  115124. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115125. }
  115126. }
  115127. declare module BABYLON {
  115128. interface AbstractScene {
  115129. /**
  115130. * The list of reflection probes added to the scene
  115131. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115132. */
  115133. reflectionProbes: Array<ReflectionProbe>;
  115134. /**
  115135. * Removes the given reflection probe from this scene.
  115136. * @param toRemove The reflection probe to remove
  115137. * @returns The index of the removed reflection probe
  115138. */
  115139. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115140. /**
  115141. * Adds the given reflection probe to this scene.
  115142. * @param newReflectionProbe The reflection probe to add
  115143. */
  115144. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115145. }
  115146. /**
  115147. * Class used to generate realtime reflection / refraction cube textures
  115148. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115149. */
  115150. export class ReflectionProbe {
  115151. /** defines the name of the probe */
  115152. name: string;
  115153. private _scene;
  115154. private _renderTargetTexture;
  115155. private _projectionMatrix;
  115156. private _viewMatrix;
  115157. private _target;
  115158. private _add;
  115159. private _attachedMesh;
  115160. private _invertYAxis;
  115161. /** Gets or sets probe position (center of the cube map) */
  115162. position: Vector3;
  115163. /**
  115164. * Creates a new reflection probe
  115165. * @param name defines the name of the probe
  115166. * @param size defines the texture resolution (for each face)
  115167. * @param scene defines the hosting scene
  115168. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115169. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115170. */
  115171. constructor(
  115172. /** defines the name of the probe */
  115173. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115174. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115175. samples: number;
  115176. /** Gets or sets the refresh rate to use (on every frame by default) */
  115177. refreshRate: number;
  115178. /**
  115179. * Gets the hosting scene
  115180. * @returns a Scene
  115181. */
  115182. getScene(): Scene;
  115183. /** Gets the internal CubeTexture used to render to */
  115184. readonly cubeTexture: RenderTargetTexture;
  115185. /** Gets the list of meshes to render */
  115186. readonly renderList: Nullable<AbstractMesh[]>;
  115187. /**
  115188. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115189. * @param mesh defines the mesh to attach to
  115190. */
  115191. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115192. /**
  115193. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115194. * @param renderingGroupId The rendering group id corresponding to its index
  115195. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115196. */
  115197. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115198. /**
  115199. * Clean all associated resources
  115200. */
  115201. dispose(): void;
  115202. /**
  115203. * Converts the reflection probe information to a readable string for debug purpose.
  115204. * @param fullDetails Supports for multiple levels of logging within scene loading
  115205. * @returns the human readable reflection probe info
  115206. */
  115207. toString(fullDetails?: boolean): string;
  115208. /**
  115209. * Get the class name of the relfection probe.
  115210. * @returns "ReflectionProbe"
  115211. */
  115212. getClassName(): string;
  115213. /**
  115214. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115215. * @returns The JSON representation of the texture
  115216. */
  115217. serialize(): any;
  115218. /**
  115219. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115220. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115221. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115222. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115223. * @returns The parsed reflection probe if successful
  115224. */
  115225. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115226. }
  115227. }
  115228. declare module BABYLON {
  115229. /** @hidden */
  115230. export var _BabylonLoaderRegistered: boolean;
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * The Physically based simple base material of BJS.
  115235. *
  115236. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115237. * It is used as the base class for both the specGloss and metalRough conventions.
  115238. */
  115239. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115240. /**
  115241. * Number of Simultaneous lights allowed on the material.
  115242. */
  115243. maxSimultaneousLights: number;
  115244. /**
  115245. * If sets to true, disables all the lights affecting the material.
  115246. */
  115247. disableLighting: boolean;
  115248. /**
  115249. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115250. */
  115251. environmentTexture: BaseTexture;
  115252. /**
  115253. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115254. */
  115255. invertNormalMapX: boolean;
  115256. /**
  115257. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115258. */
  115259. invertNormalMapY: boolean;
  115260. /**
  115261. * Normal map used in the model.
  115262. */
  115263. normalTexture: BaseTexture;
  115264. /**
  115265. * Emissivie color used to self-illuminate the model.
  115266. */
  115267. emissiveColor: Color3;
  115268. /**
  115269. * Emissivie texture used to self-illuminate the model.
  115270. */
  115271. emissiveTexture: BaseTexture;
  115272. /**
  115273. * Occlusion Channel Strenght.
  115274. */
  115275. occlusionStrength: number;
  115276. /**
  115277. * Occlusion Texture of the material (adding extra occlusion effects).
  115278. */
  115279. occlusionTexture: BaseTexture;
  115280. /**
  115281. * Defines the alpha limits in alpha test mode.
  115282. */
  115283. alphaCutOff: number;
  115284. /**
  115285. * Gets the current double sided mode.
  115286. */
  115287. /**
  115288. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115289. */
  115290. doubleSided: boolean;
  115291. /**
  115292. * Stores the pre-calculated light information of a mesh in a texture.
  115293. */
  115294. lightmapTexture: BaseTexture;
  115295. /**
  115296. * If true, the light map contains occlusion information instead of lighting info.
  115297. */
  115298. useLightmapAsShadowmap: boolean;
  115299. /**
  115300. * Instantiates a new PBRMaterial instance.
  115301. *
  115302. * @param name The material name
  115303. * @param scene The scene the material will be use in.
  115304. */
  115305. constructor(name: string, scene: Scene);
  115306. getClassName(): string;
  115307. }
  115308. }
  115309. declare module BABYLON {
  115310. /**
  115311. * The PBR material of BJS following the metal roughness convention.
  115312. *
  115313. * This fits to the PBR convention in the GLTF definition:
  115314. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115315. */
  115316. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115317. /**
  115318. * The base color has two different interpretations depending on the value of metalness.
  115319. * When the material is a metal, the base color is the specific measured reflectance value
  115320. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115321. * of the material.
  115322. */
  115323. baseColor: Color3;
  115324. /**
  115325. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115326. * well as opacity information in the alpha channel.
  115327. */
  115328. baseTexture: BaseTexture;
  115329. /**
  115330. * Specifies the metallic scalar value of the material.
  115331. * Can also be used to scale the metalness values of the metallic texture.
  115332. */
  115333. metallic: number;
  115334. /**
  115335. * Specifies the roughness scalar value of the material.
  115336. * Can also be used to scale the roughness values of the metallic texture.
  115337. */
  115338. roughness: number;
  115339. /**
  115340. * Texture containing both the metallic value in the B channel and the
  115341. * roughness value in the G channel to keep better precision.
  115342. */
  115343. metallicRoughnessTexture: BaseTexture;
  115344. /**
  115345. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115346. *
  115347. * @param name The material name
  115348. * @param scene The scene the material will be use in.
  115349. */
  115350. constructor(name: string, scene: Scene);
  115351. /**
  115352. * Return the currrent class name of the material.
  115353. */
  115354. getClassName(): string;
  115355. /**
  115356. * Makes a duplicate of the current material.
  115357. * @param name - name to use for the new material.
  115358. */
  115359. clone(name: string): PBRMetallicRoughnessMaterial;
  115360. /**
  115361. * Serialize the material to a parsable JSON object.
  115362. */
  115363. serialize(): any;
  115364. /**
  115365. * Parses a JSON object correponding to the serialize function.
  115366. */
  115367. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115368. }
  115369. }
  115370. declare module BABYLON {
  115371. /**
  115372. * The PBR material of BJS following the specular glossiness convention.
  115373. *
  115374. * This fits to the PBR convention in the GLTF definition:
  115375. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115376. */
  115377. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115378. /**
  115379. * Specifies the diffuse color of the material.
  115380. */
  115381. diffuseColor: Color3;
  115382. /**
  115383. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115384. * channel.
  115385. */
  115386. diffuseTexture: BaseTexture;
  115387. /**
  115388. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115389. */
  115390. specularColor: Color3;
  115391. /**
  115392. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115393. */
  115394. glossiness: number;
  115395. /**
  115396. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115397. */
  115398. specularGlossinessTexture: BaseTexture;
  115399. /**
  115400. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115401. *
  115402. * @param name The material name
  115403. * @param scene The scene the material will be use in.
  115404. */
  115405. constructor(name: string, scene: Scene);
  115406. /**
  115407. * Return the currrent class name of the material.
  115408. */
  115409. getClassName(): string;
  115410. /**
  115411. * Makes a duplicate of the current material.
  115412. * @param name - name to use for the new material.
  115413. */
  115414. clone(name: string): PBRSpecularGlossinessMaterial;
  115415. /**
  115416. * Serialize the material to a parsable JSON object.
  115417. */
  115418. serialize(): any;
  115419. /**
  115420. * Parses a JSON object correponding to the serialize function.
  115421. */
  115422. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115423. }
  115424. }
  115425. declare module BABYLON {
  115426. /**
  115427. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115428. * It can help converting any input color in a desired output one. This can then be used to create effects
  115429. * from sepia, black and white to sixties or futuristic rendering...
  115430. *
  115431. * The only supported format is currently 3dl.
  115432. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115433. */
  115434. export class ColorGradingTexture extends BaseTexture {
  115435. /**
  115436. * The current texture matrix. (will always be identity in color grading texture)
  115437. */
  115438. private _textureMatrix;
  115439. /**
  115440. * The texture URL.
  115441. */
  115442. url: string;
  115443. /**
  115444. * Empty line regex stored for GC.
  115445. */
  115446. private static _noneEmptyLineRegex;
  115447. private _engine;
  115448. /**
  115449. * Instantiates a ColorGradingTexture from the following parameters.
  115450. *
  115451. * @param url The location of the color gradind data (currently only supporting 3dl)
  115452. * @param scene The scene the texture will be used in
  115453. */
  115454. constructor(url: string, scene: Scene);
  115455. /**
  115456. * Returns the texture matrix used in most of the material.
  115457. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115458. */
  115459. getTextureMatrix(): Matrix;
  115460. /**
  115461. * Occurs when the file being loaded is a .3dl LUT file.
  115462. */
  115463. private load3dlTexture;
  115464. /**
  115465. * Starts the loading process of the texture.
  115466. */
  115467. private loadTexture;
  115468. /**
  115469. * Clones the color gradind texture.
  115470. */
  115471. clone(): ColorGradingTexture;
  115472. /**
  115473. * Called during delayed load for textures.
  115474. */
  115475. delayLoad(): void;
  115476. /**
  115477. * Parses a color grading texture serialized by Babylon.
  115478. * @param parsedTexture The texture information being parsedTexture
  115479. * @param scene The scene to load the texture in
  115480. * @param rootUrl The root url of the data assets to load
  115481. * @return A color gradind texture
  115482. */
  115483. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115484. /**
  115485. * Serializes the LUT texture to json format.
  115486. */
  115487. serialize(): any;
  115488. }
  115489. }
  115490. declare module BABYLON {
  115491. /**
  115492. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115493. */
  115494. export class EquiRectangularCubeTexture extends BaseTexture {
  115495. /** The six faces of the cube. */
  115496. private static _FacesMapping;
  115497. private _noMipmap;
  115498. private _onLoad;
  115499. private _onError;
  115500. /** The size of the cubemap. */
  115501. private _size;
  115502. /** The buffer of the image. */
  115503. private _buffer;
  115504. /** The width of the input image. */
  115505. private _width;
  115506. /** The height of the input image. */
  115507. private _height;
  115508. /** The URL to the image. */
  115509. url: string;
  115510. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115511. coordinatesMode: number;
  115512. /**
  115513. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115514. * @param url The location of the image
  115515. * @param scene The scene the texture will be used in
  115516. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115517. * @param noMipmap Forces to not generate the mipmap if true
  115518. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115519. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115520. * @param onLoad — defines a callback called when texture is loaded
  115521. * @param onError — defines a callback called if there is an error
  115522. */
  115523. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115524. /**
  115525. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115526. */
  115527. private loadImage;
  115528. /**
  115529. * Convert the image buffer into a cubemap and create a CubeTexture.
  115530. */
  115531. private loadTexture;
  115532. /**
  115533. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115534. * @param buffer The ArrayBuffer that should be converted.
  115535. * @returns The buffer as Float32Array.
  115536. */
  115537. private getFloat32ArrayFromArrayBuffer;
  115538. /**
  115539. * Get the current class name of the texture useful for serialization or dynamic coding.
  115540. * @returns "EquiRectangularCubeTexture"
  115541. */
  115542. getClassName(): string;
  115543. /**
  115544. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115545. * @returns A clone of the current EquiRectangularCubeTexture.
  115546. */
  115547. clone(): EquiRectangularCubeTexture;
  115548. }
  115549. }
  115550. declare module BABYLON {
  115551. /**
  115552. * Based on jsTGALoader - Javascript loader for TGA file
  115553. * By Vincent Thibault
  115554. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115555. */
  115556. export class TGATools {
  115557. private static _TYPE_INDEXED;
  115558. private static _TYPE_RGB;
  115559. private static _TYPE_GREY;
  115560. private static _TYPE_RLE_INDEXED;
  115561. private static _TYPE_RLE_RGB;
  115562. private static _TYPE_RLE_GREY;
  115563. private static _ORIGIN_MASK;
  115564. private static _ORIGIN_SHIFT;
  115565. private static _ORIGIN_BL;
  115566. private static _ORIGIN_BR;
  115567. private static _ORIGIN_UL;
  115568. private static _ORIGIN_UR;
  115569. /**
  115570. * Gets the header of a TGA file
  115571. * @param data defines the TGA data
  115572. * @returns the header
  115573. */
  115574. static GetTGAHeader(data: Uint8Array): any;
  115575. /**
  115576. * Uploads TGA content to a Babylon Texture
  115577. * @hidden
  115578. */
  115579. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115580. /** @hidden */
  115581. 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;
  115582. /** @hidden */
  115583. 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;
  115584. /** @hidden */
  115585. 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;
  115586. /** @hidden */
  115587. 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;
  115588. /** @hidden */
  115589. 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;
  115590. /** @hidden */
  115591. 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;
  115592. }
  115593. }
  115594. declare module BABYLON {
  115595. /**
  115596. * Implementation of the TGA Texture Loader.
  115597. * @hidden
  115598. */
  115599. export class _TGATextureLoader implements IInternalTextureLoader {
  115600. /**
  115601. * Defines wether the loader supports cascade loading the different faces.
  115602. */
  115603. readonly supportCascades: boolean;
  115604. /**
  115605. * This returns if the loader support the current file information.
  115606. * @param extension defines the file extension of the file being loaded
  115607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115608. * @param fallback defines the fallback internal texture if any
  115609. * @param isBase64 defines whether the texture is encoded as a base64
  115610. * @param isBuffer defines whether the texture data are stored as a buffer
  115611. * @returns true if the loader can load the specified file
  115612. */
  115613. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115614. /**
  115615. * Transform the url before loading if required.
  115616. * @param rootUrl the url of the texture
  115617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115618. * @returns the transformed texture
  115619. */
  115620. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115621. /**
  115622. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115623. * @param rootUrl the url of the texture
  115624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115625. * @returns the fallback texture
  115626. */
  115627. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115628. /**
  115629. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115630. * @param data contains the texture data
  115631. * @param texture defines the BabylonJS internal texture
  115632. * @param createPolynomials will be true if polynomials have been requested
  115633. * @param onLoad defines the callback to trigger once the texture is ready
  115634. * @param onError defines the callback to trigger in case of error
  115635. */
  115636. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115637. /**
  115638. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115639. * @param data contains the texture data
  115640. * @param texture defines the BabylonJS internal texture
  115641. * @param callback defines the method to call once ready to upload
  115642. */
  115643. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115644. }
  115645. }
  115646. declare module BABYLON {
  115647. /**
  115648. * Info about the .basis files
  115649. */
  115650. class BasisFileInfo {
  115651. /**
  115652. * If the file has alpha
  115653. */
  115654. hasAlpha: boolean;
  115655. /**
  115656. * Info about each image of the basis file
  115657. */
  115658. images: Array<{
  115659. levels: Array<{
  115660. width: number;
  115661. height: number;
  115662. transcodedPixels: ArrayBufferView;
  115663. }>;
  115664. }>;
  115665. }
  115666. /**
  115667. * Result of transcoding a basis file
  115668. */
  115669. class TranscodeResult {
  115670. /**
  115671. * Info about the .basis file
  115672. */
  115673. fileInfo: BasisFileInfo;
  115674. /**
  115675. * Format to use when loading the file
  115676. */
  115677. format: number;
  115678. }
  115679. /**
  115680. * Configuration options for the Basis transcoder
  115681. */
  115682. export class BasisTranscodeConfiguration {
  115683. /**
  115684. * Supported compression formats used to determine the supported output format of the transcoder
  115685. */
  115686. supportedCompressionFormats?: {
  115687. /**
  115688. * etc1 compression format
  115689. */
  115690. etc1?: boolean;
  115691. /**
  115692. * s3tc compression format
  115693. */
  115694. s3tc?: boolean;
  115695. /**
  115696. * pvrtc compression format
  115697. */
  115698. pvrtc?: boolean;
  115699. /**
  115700. * etc2 compression format
  115701. */
  115702. etc2?: boolean;
  115703. };
  115704. /**
  115705. * If mipmap levels should be loaded for transcoded images (Default: true)
  115706. */
  115707. loadMipmapLevels?: boolean;
  115708. /**
  115709. * Index of a single image to load (Default: all images)
  115710. */
  115711. loadSingleImage?: number;
  115712. }
  115713. /**
  115714. * Used to load .Basis files
  115715. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115716. */
  115717. export class BasisTools {
  115718. private static _IgnoreSupportedFormats;
  115719. /**
  115720. * URL to use when loading the basis transcoder
  115721. */
  115722. static JSModuleURL: string;
  115723. /**
  115724. * URL to use when loading the wasm module for the transcoder
  115725. */
  115726. static WasmModuleURL: string;
  115727. /**
  115728. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115729. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115730. * @returns internal format corresponding to the Basis format
  115731. */
  115732. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115733. private static _WorkerPromise;
  115734. private static _Worker;
  115735. private static _actionId;
  115736. private static _CreateWorkerAsync;
  115737. /**
  115738. * Transcodes a loaded image file to compressed pixel data
  115739. * @param imageData image data to transcode
  115740. * @param config configuration options for the transcoding
  115741. * @returns a promise resulting in the transcoded image
  115742. */
  115743. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115744. /**
  115745. * Loads a texture from the transcode result
  115746. * @param texture texture load to
  115747. * @param transcodeResult the result of transcoding the basis file to load from
  115748. */
  115749. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115750. }
  115751. }
  115752. declare module BABYLON {
  115753. /**
  115754. * Loader for .basis file format
  115755. */
  115756. export class _BasisTextureLoader implements IInternalTextureLoader {
  115757. /**
  115758. * Defines whether the loader supports cascade loading the different faces.
  115759. */
  115760. readonly supportCascades: boolean;
  115761. /**
  115762. * This returns if the loader support the current file information.
  115763. * @param extension defines the file extension of the file being loaded
  115764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115765. * @param fallback defines the fallback internal texture if any
  115766. * @param isBase64 defines whether the texture is encoded as a base64
  115767. * @param isBuffer defines whether the texture data are stored as a buffer
  115768. * @returns true if the loader can load the specified file
  115769. */
  115770. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115771. /**
  115772. * Transform the url before loading if required.
  115773. * @param rootUrl the url of the texture
  115774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115775. * @returns the transformed texture
  115776. */
  115777. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115778. /**
  115779. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115780. * @param rootUrl the url of the texture
  115781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115782. * @returns the fallback texture
  115783. */
  115784. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115785. /**
  115786. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115787. * @param data contains the texture data
  115788. * @param texture defines the BabylonJS internal texture
  115789. * @param createPolynomials will be true if polynomials have been requested
  115790. * @param onLoad defines the callback to trigger once the texture is ready
  115791. * @param onError defines the callback to trigger in case of error
  115792. */
  115793. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115794. /**
  115795. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115796. * @param data contains the texture data
  115797. * @param texture defines the BabylonJS internal texture
  115798. * @param callback defines the method to call once ready to upload
  115799. */
  115800. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115801. }
  115802. }
  115803. declare module BABYLON {
  115804. /**
  115805. * 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.
  115806. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115808. */
  115809. export class CustomProceduralTexture extends ProceduralTexture {
  115810. private _animate;
  115811. private _time;
  115812. private _config;
  115813. private _texturePath;
  115814. /**
  115815. * Instantiates a new Custom Procedural Texture.
  115816. * 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.
  115817. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115818. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115819. * @param name Define the name of the texture
  115820. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115821. * @param size Define the size of the texture to create
  115822. * @param scene Define the scene the texture belongs to
  115823. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115824. * @param generateMipMaps Define if the texture should creates mip maps or not
  115825. */
  115826. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115827. private _loadJson;
  115828. /**
  115829. * Is the texture ready to be used ? (rendered at least once)
  115830. * @returns true if ready, otherwise, false.
  115831. */
  115832. isReady(): boolean;
  115833. /**
  115834. * Render the texture to its associated render target.
  115835. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  115836. */
  115837. render(useCameraPostProcess?: boolean): void;
  115838. /**
  115839. * Update the list of dependant textures samplers in the shader.
  115840. */
  115841. updateTextures(): void;
  115842. /**
  115843. * Update the uniform values of the procedural texture in the shader.
  115844. */
  115845. updateShaderUniforms(): void;
  115846. /**
  115847. * Define if the texture animates or not.
  115848. */
  115849. animate: boolean;
  115850. }
  115851. }
  115852. declare module BABYLON {
  115853. /** @hidden */
  115854. export var noisePixelShader: {
  115855. name: string;
  115856. shader: string;
  115857. };
  115858. }
  115859. declare module BABYLON {
  115860. /**
  115861. * Class used to generate noise procedural textures
  115862. */
  115863. export class NoiseProceduralTexture extends ProceduralTexture {
  115864. private _time;
  115865. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  115866. brightness: number;
  115867. /** Defines the number of octaves to process */
  115868. octaves: number;
  115869. /** Defines the level of persistence (0.8 by default) */
  115870. persistence: number;
  115871. /** Gets or sets animation speed factor (default is 1) */
  115872. animationSpeedFactor: number;
  115873. /**
  115874. * Creates a new NoiseProceduralTexture
  115875. * @param name defines the name fo the texture
  115876. * @param size defines the size of the texture (default is 256)
  115877. * @param scene defines the hosting scene
  115878. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  115879. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  115880. */
  115881. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115882. private _updateShaderUniforms;
  115883. protected _getDefines(): string;
  115884. /** Generate the current state of the procedural texture */
  115885. render(useCameraPostProcess?: boolean): void;
  115886. /**
  115887. * Serializes this noise procedural texture
  115888. * @returns a serialized noise procedural texture object
  115889. */
  115890. serialize(): any;
  115891. /**
  115892. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  115893. * @param parsedTexture defines parsed texture data
  115894. * @param scene defines the current scene
  115895. * @param rootUrl defines the root URL containing noise procedural texture information
  115896. * @returns a parsed NoiseProceduralTexture
  115897. */
  115898. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  115899. }
  115900. }
  115901. declare module BABYLON {
  115902. /**
  115903. * Raw cube texture where the raw buffers are passed in
  115904. */
  115905. export class RawCubeTexture extends CubeTexture {
  115906. /**
  115907. * Creates a cube texture where the raw buffers are passed in.
  115908. * @param scene defines the scene the texture is attached to
  115909. * @param data defines the array of data to use to create each face
  115910. * @param size defines the size of the textures
  115911. * @param format defines the format of the data
  115912. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115913. * @param generateMipMaps defines if the engine should generate the mip levels
  115914. * @param invertY defines if data must be stored with Y axis inverted
  115915. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115916. * @param compression defines the compression used (null by default)
  115917. */
  115918. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115919. /**
  115920. * Updates the raw cube texture.
  115921. * @param data defines the data to store
  115922. * @param format defines the data format
  115923. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115924. * @param invertY defines if data must be stored with Y axis inverted
  115925. * @param compression defines the compression used (null by default)
  115926. * @param level defines which level of the texture to update
  115927. */
  115928. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115929. /**
  115930. * Updates a raw cube texture with RGBD encoded data.
  115931. * @param data defines the array of data [mipmap][face] to use to create each face
  115932. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115933. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115934. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115935. * @returns a promsie that resolves when the operation is complete
  115936. */
  115937. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115938. /**
  115939. * Clones the raw cube texture.
  115940. * @return a new cube texture
  115941. */
  115942. clone(): CubeTexture;
  115943. /** @hidden */
  115944. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115945. }
  115946. }
  115947. declare module BABYLON {
  115948. /**
  115949. * Class used to store 3D textures containing user data
  115950. */
  115951. export class RawTexture3D extends Texture {
  115952. /** Gets or sets the texture format to use */
  115953. format: number;
  115954. private _engine;
  115955. /**
  115956. * Create a new RawTexture3D
  115957. * @param data defines the data of the texture
  115958. * @param width defines the width of the texture
  115959. * @param height defines the height of the texture
  115960. * @param depth defines the depth of the texture
  115961. * @param format defines the texture format to use
  115962. * @param scene defines the hosting scene
  115963. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115964. * @param invertY defines if texture must be stored with Y axis inverted
  115965. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115966. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115967. */
  115968. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115969. /** Gets or sets the texture format to use */
  115970. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115971. /**
  115972. * Update the texture with new data
  115973. * @param data defines the data to store in the texture
  115974. */
  115975. update(data: ArrayBufferView): void;
  115976. }
  115977. }
  115978. declare module BABYLON {
  115979. /**
  115980. * Creates a refraction texture used by refraction channel of the standard material.
  115981. * It is like a mirror but to see through a material.
  115982. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115983. */
  115984. export class RefractionTexture extends RenderTargetTexture {
  115985. /**
  115986. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115987. * 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.
  115988. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115989. */
  115990. refractionPlane: Plane;
  115991. /**
  115992. * Define how deep under the surface we should see.
  115993. */
  115994. depth: number;
  115995. /**
  115996. * Creates a refraction texture used by refraction channel of the standard material.
  115997. * It is like a mirror but to see through a material.
  115998. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115999. * @param name Define the texture name
  116000. * @param size Define the size of the underlying texture
  116001. * @param scene Define the scene the refraction belongs to
  116002. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116003. */
  116004. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116005. /**
  116006. * Clone the refraction texture.
  116007. * @returns the cloned texture
  116008. */
  116009. clone(): RefractionTexture;
  116010. /**
  116011. * Serialize the texture to a JSON representation you could use in Parse later on
  116012. * @returns the serialized JSON representation
  116013. */
  116014. serialize(): any;
  116015. }
  116016. }
  116017. declare module BABYLON {
  116018. /**
  116019. * Defines the options related to the creation of an HtmlElementTexture
  116020. */
  116021. export interface IHtmlElementTextureOptions {
  116022. /**
  116023. * Defines wether mip maps should be created or not.
  116024. */
  116025. generateMipMaps?: boolean;
  116026. /**
  116027. * Defines the sampling mode of the texture.
  116028. */
  116029. samplingMode?: number;
  116030. /**
  116031. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116032. */
  116033. engine: Nullable<Engine>;
  116034. /**
  116035. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116036. */
  116037. scene: Nullable<Scene>;
  116038. }
  116039. /**
  116040. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116041. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116042. * is automatically managed.
  116043. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116044. * in your application.
  116045. *
  116046. * As the update is not automatic, you need to call them manually.
  116047. */
  116048. export class HtmlElementTexture extends BaseTexture {
  116049. /**
  116050. * The texture URL.
  116051. */
  116052. element: HTMLVideoElement | HTMLCanvasElement;
  116053. private static readonly DefaultOptions;
  116054. private _textureMatrix;
  116055. private _engine;
  116056. private _isVideo;
  116057. private _generateMipMaps;
  116058. private _samplingMode;
  116059. /**
  116060. * Instantiates a HtmlElementTexture from the following parameters.
  116061. *
  116062. * @param name Defines the name of the texture
  116063. * @param element Defines the video or canvas the texture is filled with
  116064. * @param options Defines the other none mandatory texture creation options
  116065. */
  116066. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116067. private _createInternalTexture;
  116068. /**
  116069. * Returns the texture matrix used in most of the material.
  116070. */
  116071. getTextureMatrix(): Matrix;
  116072. /**
  116073. * Updates the content of the texture.
  116074. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116075. */
  116076. update(invertY?: Nullable<boolean>): void;
  116077. }
  116078. }
  116079. declare module BABYLON {
  116080. /**
  116081. * Enum used to define the target of a block
  116082. */
  116083. export enum NodeMaterialBlockTargets {
  116084. /** Vertex shader */
  116085. Vertex = 1,
  116086. /** Fragment shader */
  116087. Fragment = 2,
  116088. /** Neutral */
  116089. Neutral = 4,
  116090. /** Vertex and Fragment */
  116091. VertexAndFragment = 3
  116092. }
  116093. }
  116094. declare module BABYLON {
  116095. /**
  116096. * Defines the kind of connection point for node based material
  116097. */
  116098. export enum NodeMaterialBlockConnectionPointTypes {
  116099. /** Float */
  116100. Float = 1,
  116101. /** Int */
  116102. Int = 2,
  116103. /** Vector2 */
  116104. Vector2 = 4,
  116105. /** Vector3 */
  116106. Vector3 = 8,
  116107. /** Vector4 */
  116108. Vector4 = 16,
  116109. /** Color3 */
  116110. Color3 = 32,
  116111. /** Color4 */
  116112. Color4 = 64,
  116113. /** Matrix */
  116114. Matrix = 128,
  116115. /** Detect type based on connection */
  116116. AutoDetect = 1024,
  116117. /** Output type that will be defined by input type */
  116118. BasedOnInput = 2048
  116119. }
  116120. }
  116121. declare module BABYLON {
  116122. /**
  116123. * Root class for all node material optimizers
  116124. */
  116125. export class NodeMaterialOptimizer {
  116126. /**
  116127. * Function used to optimize a NodeMaterial graph
  116128. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116129. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116130. */
  116131. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116132. }
  116133. }
  116134. declare module BABYLON {
  116135. /**
  116136. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116137. */
  116138. export class TransformBlock extends NodeMaterialBlock {
  116139. /**
  116140. * Defines the value to use to complement W value to transform it to a Vector4
  116141. */
  116142. complementW: number;
  116143. /**
  116144. * Defines the value to use to complement z value to transform it to a Vector4
  116145. */
  116146. complementZ: number;
  116147. /**
  116148. * Creates a new TransformBlock
  116149. * @param name defines the block name
  116150. */
  116151. constructor(name: string);
  116152. /**
  116153. * Gets the current class name
  116154. * @returns the class name
  116155. */
  116156. getClassName(): string;
  116157. /**
  116158. * Gets the vector input
  116159. */
  116160. readonly vector: NodeMaterialConnectionPoint;
  116161. /**
  116162. * Gets the output component
  116163. */
  116164. readonly output: NodeMaterialConnectionPoint;
  116165. /**
  116166. * Gets the matrix transform input
  116167. */
  116168. readonly transform: NodeMaterialConnectionPoint;
  116169. protected _buildBlock(state: NodeMaterialBuildState): this;
  116170. serialize(): any;
  116171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116172. }
  116173. }
  116174. declare module BABYLON {
  116175. /**
  116176. * Block used to output the vertex position
  116177. */
  116178. export class VertexOutputBlock extends NodeMaterialBlock {
  116179. /**
  116180. * Creates a new VertexOutputBlock
  116181. * @param name defines the block name
  116182. */
  116183. constructor(name: string);
  116184. /**
  116185. * Gets the current class name
  116186. * @returns the class name
  116187. */
  116188. getClassName(): string;
  116189. /**
  116190. * Gets the vector input component
  116191. */
  116192. readonly vector: NodeMaterialConnectionPoint;
  116193. protected _buildBlock(state: NodeMaterialBuildState): this;
  116194. }
  116195. }
  116196. declare module BABYLON {
  116197. /**
  116198. * Block used to output the final color
  116199. */
  116200. export class FragmentOutputBlock extends NodeMaterialBlock {
  116201. /**
  116202. * Create a new FragmentOutputBlock
  116203. * @param name defines the block name
  116204. */
  116205. constructor(name: string);
  116206. /**
  116207. * Gets the current class name
  116208. * @returns the class name
  116209. */
  116210. getClassName(): string;
  116211. /**
  116212. * Gets the rgba input component
  116213. */
  116214. readonly rgba: NodeMaterialConnectionPoint;
  116215. /**
  116216. * Gets the rgb input component
  116217. */
  116218. readonly rgb: NodeMaterialConnectionPoint;
  116219. /**
  116220. * Gets the a input component
  116221. */
  116222. readonly a: NodeMaterialConnectionPoint;
  116223. protected _buildBlock(state: NodeMaterialBuildState): this;
  116224. }
  116225. }
  116226. declare module BABYLON {
  116227. /**
  116228. * Interface used to configure the node material editor
  116229. */
  116230. export interface INodeMaterialEditorOptions {
  116231. /** Define the URl to load node editor script */
  116232. editorURL?: string;
  116233. }
  116234. /** @hidden */
  116235. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116236. /** BONES */
  116237. NUM_BONE_INFLUENCERS: number;
  116238. BonesPerMesh: number;
  116239. BONETEXTURE: boolean;
  116240. /** MORPH TARGETS */
  116241. MORPHTARGETS: boolean;
  116242. MORPHTARGETS_NORMAL: boolean;
  116243. MORPHTARGETS_TANGENT: boolean;
  116244. MORPHTARGETS_UV: boolean;
  116245. NUM_MORPH_INFLUENCERS: number;
  116246. /** IMAGE PROCESSING */
  116247. IMAGEPROCESSING: boolean;
  116248. VIGNETTE: boolean;
  116249. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116250. VIGNETTEBLENDMODEOPAQUE: boolean;
  116251. TONEMAPPING: boolean;
  116252. TONEMAPPING_ACES: boolean;
  116253. CONTRAST: boolean;
  116254. EXPOSURE: boolean;
  116255. COLORCURVES: boolean;
  116256. COLORGRADING: boolean;
  116257. COLORGRADING3D: boolean;
  116258. SAMPLER3DGREENDEPTH: boolean;
  116259. SAMPLER3DBGRMAP: boolean;
  116260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116261. constructor();
  116262. setValue(name: string, value: boolean): void;
  116263. }
  116264. /**
  116265. * Class used to configure NodeMaterial
  116266. */
  116267. export interface INodeMaterialOptions {
  116268. /**
  116269. * Defines if blocks should emit comments
  116270. */
  116271. emitComments: boolean;
  116272. }
  116273. /**
  116274. * Class used to create a node based material built by assembling shader blocks
  116275. */
  116276. export class NodeMaterial extends PushMaterial {
  116277. private static _BuildIdGenerator;
  116278. private _options;
  116279. private _vertexCompilationState;
  116280. private _fragmentCompilationState;
  116281. private _sharedData;
  116282. private _buildId;
  116283. private _buildWasSuccessful;
  116284. private _cachedWorldViewMatrix;
  116285. private _cachedWorldViewProjectionMatrix;
  116286. private _optimizers;
  116287. private _animationFrame;
  116288. /** Define the URl to load node editor script */
  116289. static EditorURL: string;
  116290. private BJSNODEMATERIALEDITOR;
  116291. /** Get the inspector from bundle or global */
  116292. private _getGlobalNodeMaterialEditor;
  116293. /**
  116294. * 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)
  116295. */
  116296. ignoreAlpha: boolean;
  116297. /**
  116298. * Defines the maximum number of lights that can be used in the material
  116299. */
  116300. maxSimultaneousLights: number;
  116301. /**
  116302. * Observable raised when the material is built
  116303. */
  116304. onBuildObservable: Observable<NodeMaterial>;
  116305. /**
  116306. * Gets or sets the root nodes of the material vertex shader
  116307. */
  116308. _vertexOutputNodes: NodeMaterialBlock[];
  116309. /**
  116310. * Gets or sets the root nodes of the material fragment (pixel) shader
  116311. */
  116312. _fragmentOutputNodes: NodeMaterialBlock[];
  116313. /** Gets or sets options to control the node material overall behavior */
  116314. options: INodeMaterialOptions;
  116315. /**
  116316. * Default configuration related to image processing available in the standard Material.
  116317. */
  116318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116319. /**
  116320. * Gets the image processing configuration used either in this material.
  116321. */
  116322. /**
  116323. * Sets the Default image processing configuration used either in the this material.
  116324. *
  116325. * If sets to null, the scene one is in use.
  116326. */
  116327. imageProcessingConfiguration: ImageProcessingConfiguration;
  116328. /**
  116329. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116330. */
  116331. attachedBlocks: NodeMaterialBlock[];
  116332. /**
  116333. * Create a new node based material
  116334. * @param name defines the material name
  116335. * @param scene defines the hosting scene
  116336. * @param options defines creation option
  116337. */
  116338. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116339. /**
  116340. * Gets the current class name of the material e.g. "NodeMaterial"
  116341. * @returns the class name
  116342. */
  116343. getClassName(): string;
  116344. /**
  116345. * Keep track of the image processing observer to allow dispose and replace.
  116346. */
  116347. private _imageProcessingObserver;
  116348. /**
  116349. * Attaches a new image processing configuration to the Standard Material.
  116350. * @param configuration
  116351. */
  116352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116353. /**
  116354. * Adds a new optimizer to the list of optimizers
  116355. * @param optimizer defines the optimizers to add
  116356. * @returns the current material
  116357. */
  116358. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116359. /**
  116360. * Remove an optimizer from the list of optimizers
  116361. * @param optimizer defines the optimizers to remove
  116362. * @returns the current material
  116363. */
  116364. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116365. /**
  116366. * Add a new block to the list of output nodes
  116367. * @param node defines the node to add
  116368. * @returns the current material
  116369. */
  116370. addOutputNode(node: NodeMaterialBlock): this;
  116371. /**
  116372. * Remove a block from the list of root nodes
  116373. * @param node defines the node to remove
  116374. * @returns the current material
  116375. */
  116376. removeOutputNode(node: NodeMaterialBlock): this;
  116377. private _addVertexOutputNode;
  116378. private _removeVertexOutputNode;
  116379. private _addFragmentOutputNode;
  116380. private _removeFragmentOutputNode;
  116381. /**
  116382. * Specifies if the material will require alpha blending
  116383. * @returns a boolean specifying if alpha blending is needed
  116384. */
  116385. needAlphaBlending(): boolean;
  116386. /**
  116387. * Specifies if this material should be rendered in alpha test mode
  116388. * @returns a boolean specifying if an alpha test is needed.
  116389. */
  116390. needAlphaTesting(): boolean;
  116391. private _initializeBlock;
  116392. private _resetDualBlocks;
  116393. /**
  116394. * Build the material and generates the inner effect
  116395. * @param verbose defines if the build should log activity
  116396. */
  116397. build(verbose?: boolean): void;
  116398. /**
  116399. * Runs an otpimization phase to try to improve the shader code
  116400. */
  116401. optimize(): void;
  116402. private _prepareDefinesForAttributes;
  116403. /**
  116404. * Get if the submesh is ready to be used and all its information available.
  116405. * Child classes can use it to update shaders
  116406. * @param mesh defines the mesh to check
  116407. * @param subMesh defines which submesh to check
  116408. * @param useInstances specifies that instances should be used
  116409. * @returns a boolean indicating that the submesh is ready or not
  116410. */
  116411. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116412. /**
  116413. * Get a string representing the shaders built by the current node graph
  116414. */
  116415. readonly compiledShaders: string;
  116416. /**
  116417. * Binds the world matrix to the material
  116418. * @param world defines the world transformation matrix
  116419. */
  116420. bindOnlyWorldMatrix(world: Matrix): void;
  116421. /**
  116422. * Binds the submesh to this material by preparing the effect and shader to draw
  116423. * @param world defines the world transformation matrix
  116424. * @param mesh defines the mesh containing the submesh
  116425. * @param subMesh defines the submesh to bind the material to
  116426. */
  116427. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116428. /**
  116429. * Gets the active textures from the material
  116430. * @returns an array of textures
  116431. */
  116432. getActiveTextures(): BaseTexture[];
  116433. /**
  116434. * Specifies if the material uses a texture
  116435. * @param texture defines the texture to check against the material
  116436. * @returns a boolean specifying if the material uses the texture
  116437. */
  116438. hasTexture(texture: BaseTexture): boolean;
  116439. /**
  116440. * Disposes the material
  116441. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116442. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116443. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116444. */
  116445. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116446. /** Creates the node editor window. */
  116447. private _createNodeEditor;
  116448. /**
  116449. * Launch the node material editor
  116450. * @param config Define the configuration of the editor
  116451. * @return a promise fulfilled when the node editor is visible
  116452. */
  116453. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116454. /**
  116455. * Clear the current material
  116456. */
  116457. clear(): void;
  116458. /**
  116459. * Clear the current material and set it to a default state
  116460. */
  116461. setToDefault(): void;
  116462. private _gatherBlocks;
  116463. /**
  116464. * Serializes this material in a JSON representation
  116465. * @returns the serialized material object
  116466. */
  116467. serialize(): any;
  116468. /**
  116469. * Clear the current graph and load a new one from a serialization object
  116470. * @param source defines the JSON representation of the material
  116471. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116472. */
  116473. loadFromSerialization(source: any, rootUrl?: string): void;
  116474. /**
  116475. * Creates a node material from parsed material data
  116476. * @param source defines the JSON representation of the material
  116477. * @param scene defines the hosting scene
  116478. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116479. * @returns a new node material
  116480. */
  116481. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116482. }
  116483. }
  116484. declare module BABYLON {
  116485. /**
  116486. * Block used to read a texture from a sampler
  116487. */
  116488. export class TextureBlock extends NodeMaterialBlock {
  116489. private _defineName;
  116490. private _samplerName;
  116491. private _transformedUVName;
  116492. private _textureTransformName;
  116493. private _textureInfoName;
  116494. private _mainUVName;
  116495. private _mainUVDefineName;
  116496. /**
  116497. * Gets or sets the texture associated with the node
  116498. */
  116499. texture: Nullable<BaseTexture>;
  116500. /**
  116501. * Create a new TextureBlock
  116502. * @param name defines the block name
  116503. */
  116504. constructor(name: string);
  116505. /**
  116506. * Gets the current class name
  116507. * @returns the class name
  116508. */
  116509. getClassName(): string;
  116510. /**
  116511. * Gets the uv input component
  116512. */
  116513. readonly uv: NodeMaterialConnectionPoint;
  116514. /**
  116515. * Gets the rgba output component
  116516. */
  116517. readonly rgba: NodeMaterialConnectionPoint;
  116518. /**
  116519. * Gets the rgb output component
  116520. */
  116521. readonly rgb: NodeMaterialConnectionPoint;
  116522. /**
  116523. * Gets the r output component
  116524. */
  116525. readonly r: NodeMaterialConnectionPoint;
  116526. /**
  116527. * Gets the g output component
  116528. */
  116529. readonly g: NodeMaterialConnectionPoint;
  116530. /**
  116531. * Gets the b output component
  116532. */
  116533. readonly b: NodeMaterialConnectionPoint;
  116534. /**
  116535. * Gets the a output component
  116536. */
  116537. readonly a: NodeMaterialConnectionPoint;
  116538. autoConfigure(): void;
  116539. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116541. isReady(): boolean;
  116542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116543. private _injectVertexCode;
  116544. private _writeOutput;
  116545. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116546. serialize(): any;
  116547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116548. }
  116549. }
  116550. declare module BABYLON {
  116551. /**
  116552. * Enum used to define well known values e.g. values automatically provided by the system
  116553. */
  116554. export enum NodeMaterialWellKnownValues {
  116555. /** World */
  116556. World = 1,
  116557. /** View */
  116558. View = 2,
  116559. /** Projection */
  116560. Projection = 3,
  116561. /** ViewProjection */
  116562. ViewProjection = 4,
  116563. /** WorldView */
  116564. WorldView = 5,
  116565. /** WorldViewProjection */
  116566. WorldViewProjection = 6,
  116567. /** CameraPosition */
  116568. CameraPosition = 7,
  116569. /** Fog Color */
  116570. FogColor = 8
  116571. }
  116572. }
  116573. declare module BABYLON {
  116574. /**
  116575. * Block used to read a reflection texture from a sampler
  116576. */
  116577. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116578. private _define3DName;
  116579. private _defineCubicName;
  116580. private _defineExplicitName;
  116581. private _defineProjectionName;
  116582. private _defineLocalCubicName;
  116583. private _defineSphericalName;
  116584. private _definePlanarName;
  116585. private _defineEquirectangularName;
  116586. private _defineMirroredEquirectangularFixedName;
  116587. private _defineEquirectangularFixedName;
  116588. private _defineSkyboxName;
  116589. private _cubeSamplerName;
  116590. private _2DSamplerName;
  116591. private _positionUVWName;
  116592. private _directionWName;
  116593. private _reflectionCoordsName;
  116594. private _reflection2DCoordsName;
  116595. private _reflectionColorName;
  116596. private _reflectionMatrixName;
  116597. /**
  116598. * Gets or sets the texture associated with the node
  116599. */
  116600. texture: Nullable<BaseTexture>;
  116601. /**
  116602. * Create a new TextureBlock
  116603. * @param name defines the block name
  116604. */
  116605. constructor(name: string);
  116606. /**
  116607. * Gets the current class name
  116608. * @returns the class name
  116609. */
  116610. getClassName(): string;
  116611. /**
  116612. * Gets the world position input component
  116613. */
  116614. readonly position: NodeMaterialConnectionPoint;
  116615. /**
  116616. * Gets the world position input component
  116617. */
  116618. readonly worldPosition: NodeMaterialConnectionPoint;
  116619. /**
  116620. * Gets the world normal input component
  116621. */
  116622. readonly worldNormal: NodeMaterialConnectionPoint;
  116623. /**
  116624. * Gets the world input component
  116625. */
  116626. readonly world: NodeMaterialConnectionPoint;
  116627. /**
  116628. * Gets the camera (or eye) position component
  116629. */
  116630. readonly cameraPosition: NodeMaterialConnectionPoint;
  116631. /**
  116632. * Gets the view input component
  116633. */
  116634. readonly view: NodeMaterialConnectionPoint;
  116635. /**
  116636. * Gets the rgb output component
  116637. */
  116638. readonly rgb: NodeMaterialConnectionPoint;
  116639. /**
  116640. * Gets the r output component
  116641. */
  116642. readonly r: NodeMaterialConnectionPoint;
  116643. /**
  116644. * Gets the g output component
  116645. */
  116646. readonly g: NodeMaterialConnectionPoint;
  116647. /**
  116648. * Gets the b output component
  116649. */
  116650. readonly b: NodeMaterialConnectionPoint;
  116651. autoConfigure(): void;
  116652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116653. isReady(): boolean;
  116654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116655. private _injectVertexCode;
  116656. private _writeOutput;
  116657. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116658. serialize(): any;
  116659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116660. }
  116661. }
  116662. declare module BABYLON {
  116663. /**
  116664. * Class used to store shared data between 2 NodeMaterialBuildState
  116665. */
  116666. export class NodeMaterialBuildStateSharedData {
  116667. /**
  116668. * Gets the list of emitted varyings
  116669. */
  116670. varyings: string[];
  116671. /**
  116672. * Gets the varying declaration string
  116673. */
  116674. varyingDeclaration: string;
  116675. /**
  116676. * Input blocks
  116677. */
  116678. inputBlocks: InputBlock[];
  116679. /**
  116680. * Input blocks
  116681. */
  116682. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  116683. /**
  116684. * Bindable blocks (Blocks that need to set data to the effect)
  116685. */
  116686. bindableBlocks: NodeMaterialBlock[];
  116687. /**
  116688. * List of blocks that can provide a compilation fallback
  116689. */
  116690. blocksWithFallbacks: NodeMaterialBlock[];
  116691. /**
  116692. * List of blocks that can provide a define update
  116693. */
  116694. blocksWithDefines: NodeMaterialBlock[];
  116695. /**
  116696. * List of blocks that can provide a repeatable content
  116697. */
  116698. repeatableContentBlocks: NodeMaterialBlock[];
  116699. /**
  116700. * List of blocks that can provide a dynamic list of uniforms
  116701. */
  116702. dynamicUniformBlocks: NodeMaterialBlock[];
  116703. /**
  116704. * List of blocks that can block the isReady function for the material
  116705. */
  116706. blockingBlocks: NodeMaterialBlock[];
  116707. /**
  116708. * Gets the list of animated inputs
  116709. */
  116710. animatedInputs: InputBlock[];
  116711. /**
  116712. * Build Id used to avoid multiple recompilations
  116713. */
  116714. buildId: number;
  116715. /** List of emitted variables */
  116716. variableNames: {
  116717. [key: string]: number;
  116718. };
  116719. /** List of emitted defines */
  116720. defineNames: {
  116721. [key: string]: number;
  116722. };
  116723. /** Should emit comments? */
  116724. emitComments: boolean;
  116725. /** Emit build activity */
  116726. verbose: boolean;
  116727. /**
  116728. * Gets the compilation hints emitted at compilation time
  116729. */
  116730. hints: {
  116731. needWorldViewMatrix: boolean;
  116732. needWorldViewProjectionMatrix: boolean;
  116733. needAlphaBlending: boolean;
  116734. needAlphaTesting: boolean;
  116735. };
  116736. /**
  116737. * List of compilation checks
  116738. */
  116739. checks: {
  116740. emitVertex: boolean;
  116741. emitFragment: boolean;
  116742. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116743. };
  116744. /** Creates a new shared data */
  116745. constructor();
  116746. /**
  116747. * Emits console errors and exceptions if there is a failing check
  116748. */
  116749. emitErrors(): void;
  116750. }
  116751. }
  116752. declare module BABYLON {
  116753. /**
  116754. * Class used to store node based material build state
  116755. */
  116756. export class NodeMaterialBuildState {
  116757. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116758. supportUniformBuffers: boolean;
  116759. /**
  116760. * Gets the list of emitted attributes
  116761. */
  116762. attributes: string[];
  116763. /**
  116764. * Gets the list of emitted uniforms
  116765. */
  116766. uniforms: string[];
  116767. /**
  116768. * Gets the list of emitted uniform buffers
  116769. */
  116770. uniformBuffers: string[];
  116771. /**
  116772. * Gets the list of emitted samplers
  116773. */
  116774. samplers: string[];
  116775. /**
  116776. * Gets the list of emitted functions
  116777. */
  116778. functions: {
  116779. [key: string]: string;
  116780. };
  116781. /**
  116782. * Gets the target of the compilation state
  116783. */
  116784. target: NodeMaterialBlockTargets;
  116785. /**
  116786. * Gets the list of emitted counters
  116787. */
  116788. counters: {
  116789. [key: string]: number;
  116790. };
  116791. /**
  116792. * Shared data between multiple NodeMaterialBuildState instances
  116793. */
  116794. sharedData: NodeMaterialBuildStateSharedData;
  116795. /** @hidden */
  116796. _vertexState: NodeMaterialBuildState;
  116797. /** @hidden */
  116798. _attributeDeclaration: string;
  116799. /** @hidden */
  116800. _uniformDeclaration: string;
  116801. /** @hidden */
  116802. _samplerDeclaration: string;
  116803. /** @hidden */
  116804. _varyingTransfer: string;
  116805. private _repeatableContentAnchorIndex;
  116806. /** @hidden */
  116807. _builtCompilationString: string;
  116808. /**
  116809. * Gets the emitted compilation strings
  116810. */
  116811. compilationString: string;
  116812. /**
  116813. * Finalize the compilation strings
  116814. * @param state defines the current compilation state
  116815. */
  116816. finalize(state: NodeMaterialBuildState): void;
  116817. /** @hidden */
  116818. readonly _repeatableContentAnchor: string;
  116819. /** @hidden */
  116820. _getFreeVariableName(prefix: string): string;
  116821. /** @hidden */
  116822. _getFreeDefineName(prefix: string): string;
  116823. /** @hidden */
  116824. _excludeVariableName(name: string): void;
  116825. /** @hidden */
  116826. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  116827. /** @hidden */
  116828. _emitFunction(name: string, code: string, comments: string): void;
  116829. /** @hidden */
  116830. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  116831. replaceStrings?: {
  116832. search: RegExp;
  116833. replace: string;
  116834. }[];
  116835. repeatKey?: string;
  116836. }): string;
  116837. /** @hidden */
  116838. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  116839. repeatKey?: string;
  116840. removeAttributes?: boolean;
  116841. removeUniforms?: boolean;
  116842. removeVaryings?: boolean;
  116843. removeIfDef?: boolean;
  116844. replaceStrings?: {
  116845. search: RegExp;
  116846. replace: string;
  116847. }[];
  116848. }, storeKey?: string): void;
  116849. /** @hidden */
  116850. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  116851. /** @hidden */
  116852. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116853. }
  116854. }
  116855. declare module BABYLON {
  116856. /**
  116857. * Defines a block that can be used inside a node based material
  116858. */
  116859. export class NodeMaterialBlock {
  116860. private _buildId;
  116861. private _buildTarget;
  116862. private _target;
  116863. private _isFinalMerger;
  116864. private _isInput;
  116865. /** @hidden */
  116866. _inputs: NodeMaterialConnectionPoint[];
  116867. /** @hidden */
  116868. _outputs: NodeMaterialConnectionPoint[];
  116869. /**
  116870. * Gets or sets the name of the block
  116871. */
  116872. name: string;
  116873. /**
  116874. * Gets or sets the unique id of the node
  116875. */
  116876. uniqueId: number;
  116877. /**
  116878. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  116879. */
  116880. readonly isFinalMerger: boolean;
  116881. /**
  116882. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  116883. */
  116884. readonly isInput: boolean;
  116885. /**
  116886. * Gets or sets the build Id
  116887. */
  116888. buildId: number;
  116889. /**
  116890. * Gets or sets the target of the block
  116891. */
  116892. target: NodeMaterialBlockTargets;
  116893. /**
  116894. * Gets the list of input points
  116895. */
  116896. readonly inputs: NodeMaterialConnectionPoint[];
  116897. /** Gets the list of output points */
  116898. readonly outputs: NodeMaterialConnectionPoint[];
  116899. /**
  116900. * Find an input by its name
  116901. * @param name defines the name of the input to look for
  116902. * @returns the input or null if not found
  116903. */
  116904. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116905. /**
  116906. * Find an output by its name
  116907. * @param name defines the name of the outputto look for
  116908. * @returns the output or null if not found
  116909. */
  116910. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116911. /**
  116912. * Creates a new NodeMaterialBlock
  116913. * @param name defines the block name
  116914. * @param target defines the target of that block (Vertex by default)
  116915. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  116916. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  116917. */
  116918. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  116919. /**
  116920. * Initialize the block and prepare the context for build
  116921. * @param state defines the state that will be used for the build
  116922. */
  116923. initialize(state: NodeMaterialBuildState): void;
  116924. /**
  116925. * Bind data to effect. Will only be called for blocks with isBindable === true
  116926. * @param effect defines the effect to bind data to
  116927. * @param nodeMaterial defines the hosting NodeMaterial
  116928. * @param mesh defines the mesh that will be rendered
  116929. */
  116930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116931. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  116932. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  116933. protected _writeFloat(value: number): string;
  116934. /**
  116935. * Gets the current class name e.g. "NodeMaterialBlock"
  116936. * @returns the class name
  116937. */
  116938. getClassName(): string;
  116939. /**
  116940. * Register a new input. Must be called inside a block constructor
  116941. * @param name defines the connection point name
  116942. * @param type defines the connection point type
  116943. * @param isOptional defines a boolean indicating that this input can be omitted
  116944. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116945. * @returns the current block
  116946. */
  116947. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  116948. /**
  116949. * Register a new output. Must be called inside a block constructor
  116950. * @param name defines the connection point name
  116951. * @param type defines the connection point type
  116952. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116953. * @returns the current block
  116954. */
  116955. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  116956. /**
  116957. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  116958. * @param forOutput defines an optional connection point to check compatibility with
  116959. * @returns the first available input or null
  116960. */
  116961. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  116962. /**
  116963. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  116964. * @param forBlock defines an optional block to check compatibility with
  116965. * @returns the first available input or null
  116966. */
  116967. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  116968. /**
  116969. * Gets the sibling of the given output
  116970. * @param current defines the current output
  116971. * @returns the next output in the list or null
  116972. */
  116973. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  116974. /**
  116975. * Connect current block with another block
  116976. * @param other defines the block to connect with
  116977. * @param options define the various options to help pick the right connections
  116978. * @returns the current block
  116979. */
  116980. connectTo(other: NodeMaterialBlock, options?: {
  116981. input?: string;
  116982. output?: string;
  116983. outputSwizzle?: string;
  116984. }): this | undefined;
  116985. protected _buildBlock(state: NodeMaterialBuildState): void;
  116986. /**
  116987. * Add uniforms, samplers and uniform buffers at compilation time
  116988. * @param state defines the state to update
  116989. * @param nodeMaterial defines the node material requesting the update
  116990. * @param defines defines the material defines to update
  116991. */
  116992. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116993. /**
  116994. * Add potential fallbacks if shader compilation fails
  116995. * @param mesh defines the mesh to be rendered
  116996. * @param fallbacks defines the current prioritized list of fallbacks
  116997. */
  116998. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116999. /**
  117000. * Update defines for shader compilation
  117001. * @param mesh defines the mesh to be rendered
  117002. * @param nodeMaterial defines the node material requesting the update
  117003. * @param defines defines the material defines to update
  117004. * @param useInstances specifies that instances should be used
  117005. */
  117006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117007. /**
  117008. * Initialize defines for shader compilation
  117009. * @param mesh defines the mesh to be rendered
  117010. * @param nodeMaterial defines the node material requesting the update
  117011. * @param defines defines the material defines to be prepared
  117012. * @param useInstances specifies that instances should be used
  117013. */
  117014. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117015. /**
  117016. * Lets the block try to connect some inputs automatically
  117017. */
  117018. autoConfigure(): void;
  117019. /**
  117020. * Function called when a block is declared as repeatable content generator
  117021. * @param vertexShaderState defines the current compilation state for the vertex shader
  117022. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117023. * @param mesh defines the mesh to be rendered
  117024. * @param defines defines the material defines to update
  117025. */
  117026. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117027. /**
  117028. * Checks if the block is ready
  117029. * @param mesh defines the mesh to be rendered
  117030. * @param nodeMaterial defines the node material requesting the update
  117031. * @param defines defines the material defines to update
  117032. * @param useInstances specifies that instances should be used
  117033. * @returns true if the block is ready
  117034. */
  117035. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117036. private _processBuild;
  117037. /**
  117038. * Compile the current node and generate the shader code
  117039. * @param state defines the current compilation state (uniforms, samplers, current string)
  117040. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  117041. * @returns true if already built
  117042. */
  117043. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  117044. /**
  117045. * Clone the current block to a new identical block
  117046. * @param scene defines the hosting scene
  117047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117048. * @returns a copy of the current block
  117049. */
  117050. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117051. /**
  117052. * Serializes this block in a JSON representation
  117053. * @returns the serialized block object
  117054. */
  117055. serialize(): any;
  117056. /** @hidden */
  117057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117058. }
  117059. }
  117060. declare module BABYLON {
  117061. /**
  117062. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117063. */
  117064. export enum NodeMaterialBlockConnectionPointMode {
  117065. /** Value is an uniform */
  117066. Uniform = 0,
  117067. /** Value is a mesh attribute */
  117068. Attribute = 1,
  117069. /** Value is a varying between vertex and fragment shaders */
  117070. Varying = 2,
  117071. /** Mode is undefined */
  117072. Undefined = 3
  117073. }
  117074. }
  117075. declare module BABYLON {
  117076. /**
  117077. * Enum defining the type of animations supported by InputBlock
  117078. */
  117079. export enum AnimatedInputBlockTypes {
  117080. /** No animation */
  117081. None = 0,
  117082. /** Time based animation. Will only work for floats */
  117083. Time = 1
  117084. }
  117085. }
  117086. declare module BABYLON {
  117087. /**
  117088. * Block used to expose an input value
  117089. */
  117090. export class InputBlock extends NodeMaterialBlock {
  117091. private _mode;
  117092. private _associatedVariableName;
  117093. private _storedValue;
  117094. private _valueCallback;
  117095. private _type;
  117096. private _animationType;
  117097. /** @hidden */
  117098. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117099. /**
  117100. * Gets or sets the connection point type (default is float)
  117101. */
  117102. readonly type: NodeMaterialBlockConnectionPointTypes;
  117103. /**
  117104. * Creates a new InputBlock
  117105. * @param name defines the block name
  117106. * @param target defines the target of that block (Vertex by default)
  117107. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117108. */
  117109. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117110. /**
  117111. * Gets the output component
  117112. */
  117113. readonly output: NodeMaterialConnectionPoint;
  117114. /**
  117115. * Set the source of this connection point to a vertex attribute
  117116. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117117. * @returns the current connection point
  117118. */
  117119. setAsAttribute(attributeName?: string): InputBlock;
  117120. /**
  117121. * Set the source of this connection point to a well known value
  117122. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117123. * @returns the current connection point
  117124. */
  117125. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117126. /**
  117127. * Gets or sets the value of that point.
  117128. * Please note that this value will be ignored if valueCallback is defined
  117129. */
  117130. value: any;
  117131. /**
  117132. * Gets or sets a callback used to get the value of that point.
  117133. * Please note that setting this value will force the connection point to ignore the value property
  117134. */
  117135. valueCallback: () => any;
  117136. /**
  117137. * Gets or sets the associated variable name in the shader
  117138. */
  117139. associatedVariableName: string;
  117140. /** Gets or sets the type of animation applied to the input */
  117141. animationType: AnimatedInputBlockTypes;
  117142. /**
  117143. * Gets a boolean indicating that this connection point not defined yet
  117144. */
  117145. readonly isUndefined: boolean;
  117146. /**
  117147. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117148. * In this case the connection point name must be the name of the uniform to use.
  117149. * Can only be set on inputs
  117150. */
  117151. isUniform: boolean;
  117152. /**
  117153. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117154. * In this case the connection point name must be the name of the attribute to use
  117155. * Can only be set on inputs
  117156. */
  117157. isAttribute: boolean;
  117158. /**
  117159. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117160. * Can only be set on exit points
  117161. */
  117162. isVarying: boolean;
  117163. /**
  117164. * Gets a boolean indicating that the current connection point is a well known value
  117165. */
  117166. readonly isWellKnownValue: boolean;
  117167. /**
  117168. * Gets or sets the current well known value or null if not defined as well know value
  117169. */
  117170. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117171. /**
  117172. * Gets the current class name
  117173. * @returns the class name
  117174. */
  117175. getClassName(): string;
  117176. /**
  117177. * Animate the input if animationType !== None
  117178. * @param scene defines the rendering scene
  117179. */
  117180. animate(scene: Scene): void;
  117181. private _emitDefine;
  117182. /**
  117183. * Set the input block to its default value (based on its type)
  117184. */
  117185. setDefaultValue(): void;
  117186. private _emit;
  117187. /** @hidden */
  117188. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117189. /** @hidden */
  117190. _transmit(effect: Effect, scene: Scene): void;
  117191. protected _buildBlock(state: NodeMaterialBuildState): void;
  117192. serialize(): any;
  117193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117194. }
  117195. }
  117196. declare module BABYLON {
  117197. /**
  117198. * Defines a connection point for a block
  117199. */
  117200. export class NodeMaterialConnectionPoint {
  117201. /** @hidden */
  117202. _ownerBlock: NodeMaterialBlock;
  117203. /** @hidden */
  117204. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117205. private _endpoints;
  117206. private _associatedVariableName;
  117207. /** @hidden */
  117208. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117209. private _type;
  117210. /** @hidden */
  117211. _enforceAssociatedVariableName: boolean;
  117212. /**
  117213. * Gets or sets the additional types supported byt this connection point
  117214. */
  117215. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117216. /**
  117217. * Gets or sets the associated variable name in the shader
  117218. */
  117219. associatedVariableName: string;
  117220. /**
  117221. * Gets or sets the connection point type (default is float)
  117222. */
  117223. type: NodeMaterialBlockConnectionPointTypes;
  117224. /**
  117225. * Gets or sets the connection point name
  117226. */
  117227. name: string;
  117228. /**
  117229. * Gets or sets a boolean indicating that this connection point can be omitted
  117230. */
  117231. isOptional: boolean;
  117232. /**
  117233. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117234. */
  117235. define: string;
  117236. /** Gets or sets the target of that connection point */
  117237. target: NodeMaterialBlockTargets;
  117238. /**
  117239. * Gets a boolean indicating that the current point is connected
  117240. */
  117241. readonly isConnected: boolean;
  117242. /**
  117243. * Gets a boolean indicating that the current point is connected to an input block
  117244. */
  117245. readonly isConnectedToInput: boolean;
  117246. /**
  117247. * Gets a the connected input block (if any)
  117248. */
  117249. readonly connectInputBlock: Nullable<InputBlock>;
  117250. /** Get the other side of the connection (if any) */
  117251. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117252. /** Get the block that owns this connection point */
  117253. readonly ownerBlock: NodeMaterialBlock;
  117254. /** Get the block connected on the other side of this connection (if any) */
  117255. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117256. /** Get the block connected on the endpoints of this connection (if any) */
  117257. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117258. /** Gets the list of connected endpoints */
  117259. readonly endpoints: NodeMaterialConnectionPoint[];
  117260. /**
  117261. * Creates a new connection point
  117262. * @param name defines the connection point name
  117263. * @param ownerBlock defines the block hosting this connection point
  117264. */
  117265. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117266. /**
  117267. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117268. * @returns the class name
  117269. */
  117270. getClassName(): string;
  117271. /**
  117272. * Gets an boolean indicating if the current point can be connected to another point
  117273. * @param connectionPoint defines the other connection point
  117274. * @returns true if the connection is possible
  117275. */
  117276. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117277. /**
  117278. * Connect this point to another connection point
  117279. * @param connectionPoint defines the other connection point
  117280. * @returns the current connection point
  117281. */
  117282. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117283. /**
  117284. * Disconnect this point from one of his endpoint
  117285. * @param endpoint defines the other connection point
  117286. * @returns the current connection point
  117287. */
  117288. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117289. /**
  117290. * Serializes this point in a JSON representation
  117291. * @returns the serialized point object
  117292. */
  117293. serialize(): any;
  117294. }
  117295. }
  117296. declare module BABYLON {
  117297. /**
  117298. * Block used to add support for vertex skinning (bones)
  117299. */
  117300. export class BonesBlock extends NodeMaterialBlock {
  117301. /**
  117302. * Creates a new BonesBlock
  117303. * @param name defines the block name
  117304. */
  117305. constructor(name: string);
  117306. /**
  117307. * Initialize the block and prepare the context for build
  117308. * @param state defines the state that will be used for the build
  117309. */
  117310. initialize(state: NodeMaterialBuildState): void;
  117311. /**
  117312. * Gets the current class name
  117313. * @returns the class name
  117314. */
  117315. getClassName(): string;
  117316. /**
  117317. * Gets the matrix indices input component
  117318. */
  117319. readonly matricesIndices: NodeMaterialConnectionPoint;
  117320. /**
  117321. * Gets the matrix weights input component
  117322. */
  117323. readonly matricesWeights: NodeMaterialConnectionPoint;
  117324. /**
  117325. * Gets the extra matrix indices input component
  117326. */
  117327. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117328. /**
  117329. * Gets the extra matrix weights input component
  117330. */
  117331. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117332. /**
  117333. * Gets the world input component
  117334. */
  117335. readonly world: NodeMaterialConnectionPoint;
  117336. /**
  117337. * Gets the output component
  117338. */
  117339. readonly output: NodeMaterialConnectionPoint;
  117340. autoConfigure(): void;
  117341. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117344. protected _buildBlock(state: NodeMaterialBuildState): this;
  117345. }
  117346. }
  117347. declare module BABYLON {
  117348. /**
  117349. * Block used to add support for instances
  117350. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117351. */
  117352. export class InstancesBlock extends NodeMaterialBlock {
  117353. /**
  117354. * Creates a new InstancesBlock
  117355. * @param name defines the block name
  117356. */
  117357. constructor(name: string);
  117358. /**
  117359. * Gets the current class name
  117360. * @returns the class name
  117361. */
  117362. getClassName(): string;
  117363. /**
  117364. * Gets the first world row input component
  117365. */
  117366. readonly world0: NodeMaterialConnectionPoint;
  117367. /**
  117368. * Gets the second world row input component
  117369. */
  117370. readonly world1: NodeMaterialConnectionPoint;
  117371. /**
  117372. * Gets the third world row input component
  117373. */
  117374. readonly world2: NodeMaterialConnectionPoint;
  117375. /**
  117376. * Gets the forth world row input component
  117377. */
  117378. readonly world3: NodeMaterialConnectionPoint;
  117379. /**
  117380. * Gets the world input component
  117381. */
  117382. readonly world: NodeMaterialConnectionPoint;
  117383. /**
  117384. * Gets the output component
  117385. */
  117386. readonly output: NodeMaterialConnectionPoint;
  117387. autoConfigure(): void;
  117388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117389. protected _buildBlock(state: NodeMaterialBuildState): this;
  117390. }
  117391. }
  117392. declare module BABYLON {
  117393. /**
  117394. * Block used to add morph targets support to vertex shader
  117395. */
  117396. export class MorphTargetsBlock extends NodeMaterialBlock {
  117397. private _repeatableContentAnchor;
  117398. private _repeatebleContentGenerated;
  117399. /**
  117400. * Create a new MorphTargetsBlock
  117401. * @param name defines the block name
  117402. */
  117403. constructor(name: string);
  117404. /**
  117405. * Gets the current class name
  117406. * @returns the class name
  117407. */
  117408. getClassName(): string;
  117409. /**
  117410. * Gets the position input component
  117411. */
  117412. readonly position: NodeMaterialConnectionPoint;
  117413. /**
  117414. * Gets the normal input component
  117415. */
  117416. readonly normal: NodeMaterialConnectionPoint;
  117417. /**
  117418. * Gets the tangent input component
  117419. */
  117420. readonly tangent: NodeMaterialConnectionPoint;
  117421. /**
  117422. * Gets the tangent input component
  117423. */
  117424. readonly uv: NodeMaterialConnectionPoint;
  117425. /**
  117426. * Gets the position output component
  117427. */
  117428. readonly positionOutput: NodeMaterialConnectionPoint;
  117429. /**
  117430. * Gets the normal output component
  117431. */
  117432. readonly normalOutput: NodeMaterialConnectionPoint;
  117433. /**
  117434. * Gets the tangent output component
  117435. */
  117436. readonly tangentOutput: NodeMaterialConnectionPoint;
  117437. /**
  117438. * Gets the tangent output component
  117439. */
  117440. readonly uvOutput: NodeMaterialConnectionPoint;
  117441. initialize(state: NodeMaterialBuildState): void;
  117442. autoConfigure(): void;
  117443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117445. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117446. protected _buildBlock(state: NodeMaterialBuildState): this;
  117447. }
  117448. }
  117449. declare module BABYLON {
  117450. /**
  117451. * Block used to add an alpha test in the fragment shader
  117452. */
  117453. export class AlphaTestBlock extends NodeMaterialBlock {
  117454. /**
  117455. * Gets or sets the alpha value where alpha testing happens
  117456. */
  117457. alphaCutOff: number;
  117458. /**
  117459. * Create a new AlphaTestBlock
  117460. * @param name defines the block name
  117461. */
  117462. constructor(name: string);
  117463. /**
  117464. * Gets the current class name
  117465. * @returns the class name
  117466. */
  117467. getClassName(): string;
  117468. /**
  117469. * Gets the color input component
  117470. */
  117471. readonly color: NodeMaterialConnectionPoint;
  117472. /**
  117473. * Gets the alpha input component
  117474. */
  117475. readonly alpha: NodeMaterialConnectionPoint;
  117476. protected _buildBlock(state: NodeMaterialBuildState): this;
  117477. }
  117478. }
  117479. declare module BABYLON {
  117480. /**
  117481. * Block used to create a Color3/4 out of individual inputs (one for each component)
  117482. */
  117483. export class ColorMergerBlock extends NodeMaterialBlock {
  117484. /**
  117485. * Create a new ColorMergerBlock
  117486. * @param name defines the block name
  117487. */
  117488. constructor(name: string);
  117489. /**
  117490. * Gets the current class name
  117491. * @returns the class name
  117492. */
  117493. getClassName(): string;
  117494. /**
  117495. * Gets the r component (input)
  117496. */
  117497. readonly r: NodeMaterialConnectionPoint;
  117498. /**
  117499. * Gets the g component (input)
  117500. */
  117501. readonly g: NodeMaterialConnectionPoint;
  117502. /**
  117503. * Gets the b component (input)
  117504. */
  117505. readonly b: NodeMaterialConnectionPoint;
  117506. /**
  117507. * Gets the a component (input)
  117508. */
  117509. readonly a: NodeMaterialConnectionPoint;
  117510. /**
  117511. * Gets the rgba component (output)
  117512. */
  117513. readonly rgba: NodeMaterialConnectionPoint;
  117514. /**
  117515. * Gets the rgb component (output)
  117516. */
  117517. readonly rgb: NodeMaterialConnectionPoint;
  117518. protected _buildBlock(state: NodeMaterialBuildState): this;
  117519. }
  117520. }
  117521. declare module BABYLON {
  117522. /**
  117523. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  117524. */
  117525. export class VectorMergerBlock extends NodeMaterialBlock {
  117526. /**
  117527. * Create a new VectorMergerBlock
  117528. * @param name defines the block name
  117529. */
  117530. constructor(name: string);
  117531. /**
  117532. * Gets the current class name
  117533. * @returns the class name
  117534. */
  117535. getClassName(): string;
  117536. /**
  117537. * Gets the x component (input)
  117538. */
  117539. readonly x: NodeMaterialConnectionPoint;
  117540. /**
  117541. * Gets the y component (input)
  117542. */
  117543. readonly y: NodeMaterialConnectionPoint;
  117544. /**
  117545. * Gets the z component (input)
  117546. */
  117547. readonly z: NodeMaterialConnectionPoint;
  117548. /**
  117549. * Gets the w component (input)
  117550. */
  117551. readonly w: NodeMaterialConnectionPoint;
  117552. /**
  117553. * Gets the xyzw component (output)
  117554. */
  117555. readonly xyzw: NodeMaterialConnectionPoint;
  117556. /**
  117557. * Gets the xyz component (output)
  117558. */
  117559. readonly xyz: NodeMaterialConnectionPoint;
  117560. /**
  117561. * Gets the xy component (output)
  117562. */
  117563. readonly xy: NodeMaterialConnectionPoint;
  117564. protected _buildBlock(state: NodeMaterialBuildState): this;
  117565. }
  117566. }
  117567. declare module BABYLON {
  117568. /**
  117569. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  117570. */
  117571. export class ColorSplitterBlock extends NodeMaterialBlock {
  117572. /**
  117573. * Create a new ColorSplitterBlock
  117574. * @param name defines the block name
  117575. */
  117576. constructor(name: string);
  117577. /**
  117578. * Gets the current class name
  117579. * @returns the class name
  117580. */
  117581. getClassName(): string;
  117582. /**
  117583. * Gets the rgba component (input)
  117584. */
  117585. readonly rgba: NodeMaterialConnectionPoint;
  117586. /**
  117587. * Gets the rgb component (input)
  117588. */
  117589. readonly rgbIn: NodeMaterialConnectionPoint;
  117590. /**
  117591. * Gets the rgb component (output)
  117592. */
  117593. readonly rgbOut: NodeMaterialConnectionPoint;
  117594. /**
  117595. * Gets the r component (output)
  117596. */
  117597. readonly r: NodeMaterialConnectionPoint;
  117598. /**
  117599. * Gets the g component (output)
  117600. */
  117601. readonly g: NodeMaterialConnectionPoint;
  117602. /**
  117603. * Gets the b component (output)
  117604. */
  117605. readonly b: NodeMaterialConnectionPoint;
  117606. /**
  117607. * Gets the a component (output)
  117608. */
  117609. readonly a: NodeMaterialConnectionPoint;
  117610. protected _buildBlock(state: NodeMaterialBuildState): this;
  117611. }
  117612. }
  117613. declare module BABYLON {
  117614. /**
  117615. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  117616. */
  117617. export class VectorSplitterBlock extends NodeMaterialBlock {
  117618. /**
  117619. * Create a new VectorSplitterBlock
  117620. * @param name defines the block name
  117621. */
  117622. constructor(name: string);
  117623. /**
  117624. * Gets the current class name
  117625. * @returns the class name
  117626. */
  117627. getClassName(): string;
  117628. /**
  117629. * Gets the xyzw component (input)
  117630. */
  117631. readonly xyzw: NodeMaterialConnectionPoint;
  117632. /**
  117633. * Gets the xyz component (input)
  117634. */
  117635. readonly xyzIn: NodeMaterialConnectionPoint;
  117636. /**
  117637. * Gets the xy component (input)
  117638. */
  117639. readonly xyIn: NodeMaterialConnectionPoint;
  117640. /**
  117641. * Gets the xyz component (output)
  117642. */
  117643. readonly xyzOut: NodeMaterialConnectionPoint;
  117644. /**
  117645. * Gets the xy component (output)
  117646. */
  117647. readonly xyOut: NodeMaterialConnectionPoint;
  117648. /**
  117649. * Gets the x component (output)
  117650. */
  117651. readonly x: NodeMaterialConnectionPoint;
  117652. /**
  117653. * Gets the y component (output)
  117654. */
  117655. readonly y: NodeMaterialConnectionPoint;
  117656. /**
  117657. * Gets the z component (output)
  117658. */
  117659. readonly z: NodeMaterialConnectionPoint;
  117660. /**
  117661. * Gets the w component (output)
  117662. */
  117663. readonly w: NodeMaterialConnectionPoint;
  117664. protected _buildBlock(state: NodeMaterialBuildState): this;
  117665. }
  117666. }
  117667. declare module BABYLON {
  117668. /**
  117669. * Block used to add image processing support to fragment shader
  117670. */
  117671. export class ImageProcessingBlock extends NodeMaterialBlock {
  117672. /**
  117673. * Create a new ImageProcessingBlock
  117674. * @param name defines the block name
  117675. */
  117676. constructor(name: string);
  117677. /**
  117678. * Gets the current class name
  117679. * @returns the class name
  117680. */
  117681. getClassName(): string;
  117682. /**
  117683. * Gets the color input component
  117684. */
  117685. readonly color: NodeMaterialConnectionPoint;
  117686. /**
  117687. * Gets the output component
  117688. */
  117689. readonly output: NodeMaterialConnectionPoint;
  117690. /**
  117691. * Initialize the block and prepare the context for build
  117692. * @param state defines the state that will be used for the build
  117693. */
  117694. initialize(state: NodeMaterialBuildState): void;
  117695. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117698. protected _buildBlock(state: NodeMaterialBuildState): this;
  117699. }
  117700. }
  117701. declare module BABYLON {
  117702. /**
  117703. * Block used to add support for scene fog
  117704. */
  117705. export class FogBlock extends NodeMaterialBlock {
  117706. private _fogDistanceName;
  117707. private _fogParameters;
  117708. /**
  117709. * Create a new FogBlock
  117710. * @param name defines the block name
  117711. */
  117712. constructor(name: string);
  117713. /**
  117714. * Gets the current class name
  117715. * @returns the class name
  117716. */
  117717. getClassName(): string;
  117718. /**
  117719. * Gets the world position input component
  117720. */
  117721. readonly worldPosition: NodeMaterialConnectionPoint;
  117722. /**
  117723. * Gets the view input component
  117724. */
  117725. readonly view: NodeMaterialConnectionPoint;
  117726. /**
  117727. * Gets the color input component
  117728. */
  117729. readonly color: NodeMaterialConnectionPoint;
  117730. /**
  117731. * Gets the fog color input component
  117732. */
  117733. readonly fogColor: NodeMaterialConnectionPoint;
  117734. /**
  117735. * Gets the output component
  117736. */
  117737. readonly output: NodeMaterialConnectionPoint;
  117738. autoConfigure(): void;
  117739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117741. protected _buildBlock(state: NodeMaterialBuildState): this;
  117742. }
  117743. }
  117744. declare module BABYLON {
  117745. /**
  117746. * Block used to add light in the fragment shader
  117747. */
  117748. export class LightBlock extends NodeMaterialBlock {
  117749. private _lightId;
  117750. /**
  117751. * Gets or sets the light associated with this block
  117752. */
  117753. light: Nullable<Light>;
  117754. /**
  117755. * Create a new LightBlock
  117756. * @param name defines the block name
  117757. */
  117758. constructor(name: string);
  117759. /**
  117760. * Gets the current class name
  117761. * @returns the class name
  117762. */
  117763. getClassName(): string;
  117764. /**
  117765. * Gets the world position input component
  117766. */
  117767. readonly worldPosition: NodeMaterialConnectionPoint;
  117768. /**
  117769. * Gets the world normal input component
  117770. */
  117771. readonly worldNormal: NodeMaterialConnectionPoint;
  117772. /**
  117773. * Gets the camera (or eye) position component
  117774. */
  117775. readonly cameraPosition: NodeMaterialConnectionPoint;
  117776. /**
  117777. * Gets the diffuse output component
  117778. */
  117779. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117780. /**
  117781. * Gets the specular output component
  117782. */
  117783. readonly specularOutput: NodeMaterialConnectionPoint;
  117784. autoConfigure(): void;
  117785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117786. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117787. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117788. private _injectVertexCode;
  117789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117790. serialize(): any;
  117791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117792. }
  117793. }
  117794. declare module BABYLON {
  117795. /**
  117796. * Block used to multiply 2 values
  117797. */
  117798. export class MultiplyBlock extends NodeMaterialBlock {
  117799. /**
  117800. * Creates a new MultiplyBlock
  117801. * @param name defines the block name
  117802. */
  117803. constructor(name: string);
  117804. /**
  117805. * Gets the current class name
  117806. * @returns the class name
  117807. */
  117808. getClassName(): string;
  117809. /**
  117810. * Gets the left operand input component
  117811. */
  117812. readonly left: NodeMaterialConnectionPoint;
  117813. /**
  117814. * Gets the right operand input component
  117815. */
  117816. readonly right: NodeMaterialConnectionPoint;
  117817. /**
  117818. * Gets the output component
  117819. */
  117820. readonly output: NodeMaterialConnectionPoint;
  117821. protected _buildBlock(state: NodeMaterialBuildState): this;
  117822. }
  117823. }
  117824. declare module BABYLON {
  117825. /**
  117826. * Block used to add 2 vectors
  117827. */
  117828. export class AddBlock extends NodeMaterialBlock {
  117829. /**
  117830. * Creates a new AddBlock
  117831. * @param name defines the block name
  117832. */
  117833. constructor(name: string);
  117834. /**
  117835. * Gets the current class name
  117836. * @returns the class name
  117837. */
  117838. getClassName(): string;
  117839. /**
  117840. * Gets the left operand input component
  117841. */
  117842. readonly left: NodeMaterialConnectionPoint;
  117843. /**
  117844. * Gets the right operand input component
  117845. */
  117846. readonly right: NodeMaterialConnectionPoint;
  117847. /**
  117848. * Gets the output component
  117849. */
  117850. readonly output: NodeMaterialConnectionPoint;
  117851. protected _buildBlock(state: NodeMaterialBuildState): this;
  117852. }
  117853. }
  117854. declare module BABYLON {
  117855. /**
  117856. * Block used to scale a vector by a float
  117857. */
  117858. export class ScaleBlock extends NodeMaterialBlock {
  117859. /**
  117860. * Creates a new ScaleBlock
  117861. * @param name defines the block name
  117862. */
  117863. constructor(name: string);
  117864. /**
  117865. * Gets the current class name
  117866. * @returns the class name
  117867. */
  117868. getClassName(): string;
  117869. /**
  117870. * Gets the input component
  117871. */
  117872. readonly input: NodeMaterialConnectionPoint;
  117873. /**
  117874. * Gets the factor input component
  117875. */
  117876. readonly factor: NodeMaterialConnectionPoint;
  117877. /**
  117878. * Gets the output component
  117879. */
  117880. readonly output: NodeMaterialConnectionPoint;
  117881. protected _buildBlock(state: NodeMaterialBuildState): this;
  117882. }
  117883. }
  117884. declare module BABYLON {
  117885. /**
  117886. * Block used to clamp a float
  117887. */
  117888. export class ClampBlock extends NodeMaterialBlock {
  117889. /** Gets or sets the minimum range */
  117890. minimum: number;
  117891. /** Gets or sets the maximum range */
  117892. maximum: number;
  117893. /**
  117894. * Creates a new ClampBlock
  117895. * @param name defines the block name
  117896. */
  117897. constructor(name: string);
  117898. /**
  117899. * Gets the current class name
  117900. * @returns the class name
  117901. */
  117902. getClassName(): string;
  117903. /**
  117904. * Gets the value input component
  117905. */
  117906. readonly value: NodeMaterialConnectionPoint;
  117907. /**
  117908. * Gets the output component
  117909. */
  117910. readonly output: NodeMaterialConnectionPoint;
  117911. protected _buildBlock(state: NodeMaterialBuildState): this;
  117912. }
  117913. }
  117914. declare module BABYLON {
  117915. /**
  117916. * Block used to apply a cross product between 2 vectors
  117917. */
  117918. export class CrossBlock extends NodeMaterialBlock {
  117919. /**
  117920. * Creates a new CrossBlock
  117921. * @param name defines the block name
  117922. */
  117923. constructor(name: string);
  117924. /**
  117925. * Gets the current class name
  117926. * @returns the class name
  117927. */
  117928. getClassName(): string;
  117929. /**
  117930. * Gets the left operand input component
  117931. */
  117932. readonly left: NodeMaterialConnectionPoint;
  117933. /**
  117934. * Gets the right operand input component
  117935. */
  117936. readonly right: NodeMaterialConnectionPoint;
  117937. /**
  117938. * Gets the output component
  117939. */
  117940. readonly output: NodeMaterialConnectionPoint;
  117941. protected _buildBlock(state: NodeMaterialBuildState): this;
  117942. }
  117943. }
  117944. declare module BABYLON {
  117945. /**
  117946. * Block used to apply a dot product between 2 vectors
  117947. */
  117948. export class DotBlock extends NodeMaterialBlock {
  117949. /**
  117950. * Creates a new DotBlock
  117951. * @param name defines the block name
  117952. */
  117953. constructor(name: string);
  117954. /**
  117955. * Gets the current class name
  117956. * @returns the class name
  117957. */
  117958. getClassName(): string;
  117959. /**
  117960. * Gets the left operand input component
  117961. */
  117962. readonly left: NodeMaterialConnectionPoint;
  117963. /**
  117964. * Gets the right operand input component
  117965. */
  117966. readonly right: NodeMaterialConnectionPoint;
  117967. /**
  117968. * Gets the output component
  117969. */
  117970. readonly output: NodeMaterialConnectionPoint;
  117971. protected _buildBlock(state: NodeMaterialBuildState): this;
  117972. }
  117973. }
  117974. declare module BABYLON {
  117975. /**
  117976. * Block used to remap a float from a range to a new one
  117977. */
  117978. export class RemapBlock extends NodeMaterialBlock {
  117979. /**
  117980. * Gets or sets the source range
  117981. */
  117982. sourceRange: Vector2;
  117983. /**
  117984. * Gets or sets the target range
  117985. */
  117986. targetRange: Vector2;
  117987. /**
  117988. * Creates a new RemapBlock
  117989. * @param name defines the block name
  117990. */
  117991. constructor(name: string);
  117992. /**
  117993. * Gets the current class name
  117994. * @returns the class name
  117995. */
  117996. getClassName(): string;
  117997. /**
  117998. * Gets the input component
  117999. */
  118000. readonly input: NodeMaterialConnectionPoint;
  118001. /**
  118002. * Gets the output component
  118003. */
  118004. readonly output: NodeMaterialConnectionPoint;
  118005. protected _buildBlock(state: NodeMaterialBuildState): this;
  118006. }
  118007. }
  118008. declare module BABYLON {
  118009. /**
  118010. * Block used to normalize a vector
  118011. */
  118012. export class NormalizeBlock extends NodeMaterialBlock {
  118013. /**
  118014. * Creates a new NormalizeBlock
  118015. * @param name defines the block name
  118016. */
  118017. constructor(name: string);
  118018. /**
  118019. * Gets the current class name
  118020. * @returns the class name
  118021. */
  118022. getClassName(): string;
  118023. /**
  118024. * Gets the input component
  118025. */
  118026. readonly input: NodeMaterialConnectionPoint;
  118027. /**
  118028. * Gets the output component
  118029. */
  118030. readonly output: NodeMaterialConnectionPoint;
  118031. protected _buildBlock(state: NodeMaterialBuildState): this;
  118032. }
  118033. }
  118034. declare module BABYLON {
  118035. /**
  118036. * Operations supported by the Trigonometry block
  118037. */
  118038. export enum TrigonometryBlockOperations {
  118039. /** Cos */
  118040. Cos = 0,
  118041. /** Sin */
  118042. Sin = 1,
  118043. /** Abs */
  118044. Abs = 2
  118045. }
  118046. /**
  118047. * Block used to apply trigonometry operation to floats
  118048. */
  118049. export class TrigonometryBlock extends NodeMaterialBlock {
  118050. /**
  118051. * Gets or sets the operation applied by the block
  118052. */
  118053. operation: TrigonometryBlockOperations;
  118054. /**
  118055. * Creates a new TrigonometryBlock
  118056. * @param name defines the block name
  118057. */
  118058. constructor(name: string);
  118059. /**
  118060. * Gets the current class name
  118061. * @returns the class name
  118062. */
  118063. getClassName(): string;
  118064. /**
  118065. * Gets the input component
  118066. */
  118067. readonly input: NodeMaterialConnectionPoint;
  118068. /**
  118069. * Gets the output component
  118070. */
  118071. readonly output: NodeMaterialConnectionPoint;
  118072. protected _buildBlock(state: NodeMaterialBuildState): this;
  118073. }
  118074. }
  118075. declare module BABYLON {
  118076. /**
  118077. * Effect Render Options
  118078. */
  118079. export interface IEffectRendererOptions {
  118080. /**
  118081. * Defines the vertices positions.
  118082. */
  118083. positions?: number[];
  118084. /**
  118085. * Defines the indices.
  118086. */
  118087. indices?: number[];
  118088. }
  118089. /**
  118090. * Helper class to render one or more effects
  118091. */
  118092. export class EffectRenderer {
  118093. private engine;
  118094. private static _DefaultOptions;
  118095. private _vertexBuffers;
  118096. private _indexBuffer;
  118097. private _ringBufferIndex;
  118098. private _ringScreenBuffer;
  118099. private _fullscreenViewport;
  118100. private _getNextFrameBuffer;
  118101. /**
  118102. * Creates an effect renderer
  118103. * @param engine the engine to use for rendering
  118104. * @param options defines the options of the effect renderer
  118105. */
  118106. constructor(engine: Engine, options?: IEffectRendererOptions);
  118107. /**
  118108. * Sets the current viewport in normalized coordinates 0-1
  118109. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118110. */
  118111. setViewport(viewport?: Viewport): void;
  118112. /**
  118113. * Sets the current effect wrapper to use during draw.
  118114. * The effect needs to be ready before calling this api.
  118115. * This also sets the default full screen position attribute.
  118116. * @param effectWrapper Defines the effect to draw with
  118117. */
  118118. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118119. /**
  118120. * Draws a full screen quad.
  118121. */
  118122. draw(): void;
  118123. /**
  118124. * renders one or more effects to a specified texture
  118125. * @param effectWrappers list of effects to renderer
  118126. * @param outputTexture texture to draw to, if null it will render to the screen
  118127. */
  118128. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  118129. /**
  118130. * Disposes of the effect renderer
  118131. */
  118132. dispose(): void;
  118133. }
  118134. /**
  118135. * Options to create an EffectWrapper
  118136. */
  118137. interface EffectWrapperCreationOptions {
  118138. /**
  118139. * Engine to use to create the effect
  118140. */
  118141. engine: Engine;
  118142. /**
  118143. * Fragment shader for the effect
  118144. */
  118145. fragmentShader: string;
  118146. /**
  118147. * Vertex shader for the effect
  118148. */
  118149. vertexShader?: string;
  118150. /**
  118151. * Attributes to use in the shader
  118152. */
  118153. attributeNames?: Array<string>;
  118154. /**
  118155. * Uniforms to use in the shader
  118156. */
  118157. uniformNames?: Array<string>;
  118158. /**
  118159. * Texture sampler names to use in the shader
  118160. */
  118161. samplerNames?: Array<string>;
  118162. /**
  118163. * The friendly name of the effect displayed in Spector.
  118164. */
  118165. name?: string;
  118166. }
  118167. /**
  118168. * Wraps an effect to be used for rendering
  118169. */
  118170. export class EffectWrapper {
  118171. /**
  118172. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  118173. */
  118174. onApplyObservable: Observable<{}>;
  118175. /**
  118176. * The underlying effect
  118177. */
  118178. effect: Effect;
  118179. /**
  118180. * Creates an effect to be renderer
  118181. * @param creationOptions options to create the effect
  118182. */
  118183. constructor(creationOptions: EffectWrapperCreationOptions);
  118184. /**
  118185. * Disposes of the effect wrapper
  118186. */
  118187. dispose(): void;
  118188. }
  118189. }
  118190. declare module BABYLON {
  118191. /**
  118192. * Helper class to push actions to a pool of workers.
  118193. */
  118194. export class WorkerPool implements IDisposable {
  118195. private _workerInfos;
  118196. private _pendingActions;
  118197. /**
  118198. * Constructor
  118199. * @param workers Array of workers to use for actions
  118200. */
  118201. constructor(workers: Array<Worker>);
  118202. /**
  118203. * Terminates all workers and clears any pending actions.
  118204. */
  118205. dispose(): void;
  118206. /**
  118207. * Pushes an action to the worker pool. If all the workers are active, the action will be
  118208. * pended until a worker has completed its action.
  118209. * @param action The action to perform. Call onComplete when the action is complete.
  118210. */
  118211. push(action: (worker: Worker, onComplete: () => void) => void): void;
  118212. private _execute;
  118213. }
  118214. }
  118215. declare module BABYLON {
  118216. /**
  118217. * Configuration for Draco compression
  118218. */
  118219. export interface IDracoCompressionConfiguration {
  118220. /**
  118221. * Configuration for the decoder.
  118222. */
  118223. decoder: {
  118224. /**
  118225. * The url to the WebAssembly module.
  118226. */
  118227. wasmUrl?: string;
  118228. /**
  118229. * The url to the WebAssembly binary.
  118230. */
  118231. wasmBinaryUrl?: string;
  118232. /**
  118233. * The url to the fallback JavaScript module.
  118234. */
  118235. fallbackUrl?: string;
  118236. };
  118237. }
  118238. /**
  118239. * Draco compression (https://google.github.io/draco/)
  118240. *
  118241. * This class wraps the Draco module.
  118242. *
  118243. * **Encoder**
  118244. *
  118245. * The encoder is not currently implemented.
  118246. *
  118247. * **Decoder**
  118248. *
  118249. * 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.
  118250. *
  118251. * To update the configuration, use the following code:
  118252. * ```javascript
  118253. * DracoCompression.Configuration = {
  118254. * decoder: {
  118255. * wasmUrl: "<url to the WebAssembly library>",
  118256. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  118257. * fallbackUrl: "<url to the fallback JavaScript library>",
  118258. * }
  118259. * };
  118260. * ```
  118261. *
  118262. * 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.
  118263. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118264. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118265. *
  118266. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118267. * ```javascript
  118268. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118269. * ```
  118270. *
  118271. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118272. */
  118273. export class DracoCompression implements IDisposable {
  118274. private _workerPoolPromise?;
  118275. private _decoderModulePromise?;
  118276. /**
  118277. * The configuration. Defaults to the following urls:
  118278. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  118279. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  118280. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  118281. */
  118282. static Configuration: IDracoCompressionConfiguration;
  118283. /**
  118284. * Returns true if the decoder configuration is available.
  118285. */
  118286. static readonly DecoderAvailable: boolean;
  118287. /**
  118288. * Default number of workers to create when creating the draco compression object.
  118289. */
  118290. static DefaultNumWorkers: number;
  118291. private static GetDefaultNumWorkers;
  118292. private static _Default;
  118293. /**
  118294. * Default instance for the draco compression object.
  118295. */
  118296. static readonly Default: DracoCompression;
  118297. /**
  118298. * Constructor
  118299. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  118300. */
  118301. constructor(numWorkers?: number);
  118302. /**
  118303. * Stop all async operations and release resources.
  118304. */
  118305. dispose(): void;
  118306. /**
  118307. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  118308. * @returns a promise that resolves when ready
  118309. */
  118310. whenReadyAsync(): Promise<void>;
  118311. /**
  118312. * Decode Draco compressed mesh data to vertex data.
  118313. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  118314. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  118315. * @returns A promise that resolves with the decoded vertex data
  118316. */
  118317. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  118318. [kind: string]: number;
  118319. }): Promise<VertexData>;
  118320. }
  118321. }
  118322. declare module BABYLON {
  118323. /**
  118324. * Class for building Constructive Solid Geometry
  118325. */
  118326. export class CSG {
  118327. private polygons;
  118328. /**
  118329. * The world matrix
  118330. */
  118331. matrix: Matrix;
  118332. /**
  118333. * Stores the position
  118334. */
  118335. position: Vector3;
  118336. /**
  118337. * Stores the rotation
  118338. */
  118339. rotation: Vector3;
  118340. /**
  118341. * Stores the rotation quaternion
  118342. */
  118343. rotationQuaternion: Nullable<Quaternion>;
  118344. /**
  118345. * Stores the scaling vector
  118346. */
  118347. scaling: Vector3;
  118348. /**
  118349. * Convert the Mesh to CSG
  118350. * @param mesh The Mesh to convert to CSG
  118351. * @returns A new CSG from the Mesh
  118352. */
  118353. static FromMesh(mesh: Mesh): CSG;
  118354. /**
  118355. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  118356. * @param polygons Polygons used to construct a CSG solid
  118357. */
  118358. private static FromPolygons;
  118359. /**
  118360. * Clones, or makes a deep copy, of the CSG
  118361. * @returns A new CSG
  118362. */
  118363. clone(): CSG;
  118364. /**
  118365. * Unions this CSG with another CSG
  118366. * @param csg The CSG to union against this CSG
  118367. * @returns The unioned CSG
  118368. */
  118369. union(csg: CSG): CSG;
  118370. /**
  118371. * Unions this CSG with another CSG in place
  118372. * @param csg The CSG to union against this CSG
  118373. */
  118374. unionInPlace(csg: CSG): void;
  118375. /**
  118376. * Subtracts this CSG with another CSG
  118377. * @param csg The CSG to subtract against this CSG
  118378. * @returns A new CSG
  118379. */
  118380. subtract(csg: CSG): CSG;
  118381. /**
  118382. * Subtracts this CSG with another CSG in place
  118383. * @param csg The CSG to subtact against this CSG
  118384. */
  118385. subtractInPlace(csg: CSG): void;
  118386. /**
  118387. * Intersect this CSG with another CSG
  118388. * @param csg The CSG to intersect against this CSG
  118389. * @returns A new CSG
  118390. */
  118391. intersect(csg: CSG): CSG;
  118392. /**
  118393. * Intersects this CSG with another CSG in place
  118394. * @param csg The CSG to intersect against this CSG
  118395. */
  118396. intersectInPlace(csg: CSG): void;
  118397. /**
  118398. * Return a new CSG solid with solid and empty space switched. This solid is
  118399. * not modified.
  118400. * @returns A new CSG solid with solid and empty space switched
  118401. */
  118402. inverse(): CSG;
  118403. /**
  118404. * Inverses the CSG in place
  118405. */
  118406. inverseInPlace(): void;
  118407. /**
  118408. * This is used to keep meshes transformations so they can be restored
  118409. * when we build back a Babylon Mesh
  118410. * NB : All CSG operations are performed in world coordinates
  118411. * @param csg The CSG to copy the transform attributes from
  118412. * @returns This CSG
  118413. */
  118414. copyTransformAttributes(csg: CSG): CSG;
  118415. /**
  118416. * Build Raw mesh from CSG
  118417. * Coordinates here are in world space
  118418. * @param name The name of the mesh geometry
  118419. * @param scene The Scene
  118420. * @param keepSubMeshes Specifies if the submeshes should be kept
  118421. * @returns A new Mesh
  118422. */
  118423. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  118424. /**
  118425. * Build Mesh from CSG taking material and transforms into account
  118426. * @param name The name of the Mesh
  118427. * @param material The material of the Mesh
  118428. * @param scene The Scene
  118429. * @param keepSubMeshes Specifies if submeshes should be kept
  118430. * @returns The new Mesh
  118431. */
  118432. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  118433. }
  118434. }
  118435. declare module BABYLON {
  118436. /**
  118437. * Class used to create a trail following a mesh
  118438. */
  118439. export class TrailMesh extends Mesh {
  118440. private _generator;
  118441. private _autoStart;
  118442. private _running;
  118443. private _diameter;
  118444. private _length;
  118445. private _sectionPolygonPointsCount;
  118446. private _sectionVectors;
  118447. private _sectionNormalVectors;
  118448. private _beforeRenderObserver;
  118449. /**
  118450. * @constructor
  118451. * @param name The value used by scene.getMeshByName() to do a lookup.
  118452. * @param generator The mesh to generate a trail.
  118453. * @param scene The scene to add this mesh to.
  118454. * @param diameter Diameter of trailing mesh. Default is 1.
  118455. * @param length Length of trailing mesh. Default is 60.
  118456. * @param autoStart Automatically start trailing mesh. Default true.
  118457. */
  118458. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  118459. /**
  118460. * "TrailMesh"
  118461. * @returns "TrailMesh"
  118462. */
  118463. getClassName(): string;
  118464. private _createMesh;
  118465. /**
  118466. * Start trailing mesh.
  118467. */
  118468. start(): void;
  118469. /**
  118470. * Stop trailing mesh.
  118471. */
  118472. stop(): void;
  118473. /**
  118474. * Update trailing mesh geometry.
  118475. */
  118476. update(): void;
  118477. /**
  118478. * Returns a new TrailMesh object.
  118479. * @param name is a string, the name given to the new mesh
  118480. * @param newGenerator use new generator object for cloned trail mesh
  118481. * @returns a new mesh
  118482. */
  118483. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  118484. /**
  118485. * Serializes this trail mesh
  118486. * @param serializationObject object to write serialization to
  118487. */
  118488. serialize(serializationObject: any): void;
  118489. /**
  118490. * Parses a serialized trail mesh
  118491. * @param parsedMesh the serialized mesh
  118492. * @param scene the scene to create the trail mesh in
  118493. * @returns the created trail mesh
  118494. */
  118495. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  118496. }
  118497. }
  118498. declare module BABYLON {
  118499. /**
  118500. * Class containing static functions to help procedurally build meshes
  118501. */
  118502. export class TiledBoxBuilder {
  118503. /**
  118504. * Creates a box mesh
  118505. * 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)
  118506. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118510. * @param name defines the name of the mesh
  118511. * @param options defines the options used to create the mesh
  118512. * @param scene defines the hosting scene
  118513. * @returns the box mesh
  118514. */
  118515. static CreateTiledBox(name: string, options: {
  118516. pattern?: number;
  118517. width?: number;
  118518. height?: number;
  118519. depth?: number;
  118520. tileSize?: number;
  118521. tileWidth?: number;
  118522. tileHeight?: number;
  118523. alignHorizontal?: number;
  118524. alignVertical?: number;
  118525. faceUV?: Vector4[];
  118526. faceColors?: Color4[];
  118527. sideOrientation?: number;
  118528. updatable?: boolean;
  118529. }, scene?: Nullable<Scene>): Mesh;
  118530. }
  118531. }
  118532. declare module BABYLON {
  118533. /**
  118534. * Class containing static functions to help procedurally build meshes
  118535. */
  118536. export class TorusKnotBuilder {
  118537. /**
  118538. * Creates a torus knot mesh
  118539. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118540. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118541. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118542. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118546. * @param name defines the name of the mesh
  118547. * @param options defines the options used to create the mesh
  118548. * @param scene defines the hosting scene
  118549. * @returns the torus knot mesh
  118550. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118551. */
  118552. static CreateTorusKnot(name: string, options: {
  118553. radius?: number;
  118554. tube?: number;
  118555. radialSegments?: number;
  118556. tubularSegments?: number;
  118557. p?: number;
  118558. q?: number;
  118559. updatable?: boolean;
  118560. sideOrientation?: number;
  118561. frontUVs?: Vector4;
  118562. backUVs?: Vector4;
  118563. }, scene: any): Mesh;
  118564. }
  118565. }
  118566. declare module BABYLON {
  118567. /**
  118568. * Polygon
  118569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118570. */
  118571. export class Polygon {
  118572. /**
  118573. * Creates a rectangle
  118574. * @param xmin bottom X coord
  118575. * @param ymin bottom Y coord
  118576. * @param xmax top X coord
  118577. * @param ymax top Y coord
  118578. * @returns points that make the resulting rectation
  118579. */
  118580. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  118581. /**
  118582. * Creates a circle
  118583. * @param radius radius of circle
  118584. * @param cx scale in x
  118585. * @param cy scale in y
  118586. * @param numberOfSides number of sides that make up the circle
  118587. * @returns points that make the resulting circle
  118588. */
  118589. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  118590. /**
  118591. * Creates a polygon from input string
  118592. * @param input Input polygon data
  118593. * @returns the parsed points
  118594. */
  118595. static Parse(input: string): Vector2[];
  118596. /**
  118597. * Starts building a polygon from x and y coordinates
  118598. * @param x x coordinate
  118599. * @param y y coordinate
  118600. * @returns the started path2
  118601. */
  118602. static StartingAt(x: number, y: number): Path2;
  118603. }
  118604. /**
  118605. * Builds a polygon
  118606. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118607. */
  118608. export class PolygonMeshBuilder {
  118609. private _points;
  118610. private _outlinepoints;
  118611. private _holes;
  118612. private _name;
  118613. private _scene;
  118614. private _epoints;
  118615. private _eholes;
  118616. private _addToepoint;
  118617. /**
  118618. * Babylon reference to the earcut plugin.
  118619. */
  118620. bjsEarcut: any;
  118621. /**
  118622. * Creates a PolygonMeshBuilder
  118623. * @param name name of the builder
  118624. * @param contours Path of the polygon
  118625. * @param scene scene to add to when creating the mesh
  118626. * @param earcutInjection can be used to inject your own earcut reference
  118627. */
  118628. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118629. /**
  118630. * Adds a whole within the polygon
  118631. * @param hole Array of points defining the hole
  118632. * @returns this
  118633. */
  118634. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118635. /**
  118636. * Creates the polygon
  118637. * @param updatable If the mesh should be updatable
  118638. * @param depth The depth of the mesh created
  118639. * @returns the created mesh
  118640. */
  118641. build(updatable?: boolean, depth?: number): Mesh;
  118642. /**
  118643. * Creates the polygon
  118644. * @param depth The depth of the mesh created
  118645. * @returns the created VertexData
  118646. */
  118647. buildVertexData(depth?: number): VertexData;
  118648. /**
  118649. * Adds a side to the polygon
  118650. * @param positions points that make the polygon
  118651. * @param normals normals of the polygon
  118652. * @param uvs uvs of the polygon
  118653. * @param indices indices of the polygon
  118654. * @param bounds bounds of the polygon
  118655. * @param points points of the polygon
  118656. * @param depth depth of the polygon
  118657. * @param flip flip of the polygon
  118658. */
  118659. private addSide;
  118660. }
  118661. }
  118662. declare module BABYLON {
  118663. /**
  118664. * Class containing static functions to help procedurally build meshes
  118665. */
  118666. export class PolygonBuilder {
  118667. /**
  118668. * Creates a polygon mesh
  118669. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118670. * * 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
  118671. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118674. * * Remember you can only change the shape positions, not their number when updating a polygon
  118675. * @param name defines the name of the mesh
  118676. * @param options defines the options used to create the mesh
  118677. * @param scene defines the hosting scene
  118678. * @param earcutInjection can be used to inject your own earcut reference
  118679. * @returns the polygon mesh
  118680. */
  118681. static CreatePolygon(name: string, options: {
  118682. shape: Vector3[];
  118683. holes?: Vector3[][];
  118684. depth?: number;
  118685. faceUV?: Vector4[];
  118686. faceColors?: Color4[];
  118687. updatable?: boolean;
  118688. sideOrientation?: number;
  118689. frontUVs?: Vector4;
  118690. backUVs?: Vector4;
  118691. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118692. /**
  118693. * Creates an extruded polygon mesh, with depth in the Y direction.
  118694. * * 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)
  118695. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118696. * @param name defines the name of the mesh
  118697. * @param options defines the options used to create the mesh
  118698. * @param scene defines the hosting scene
  118699. * @param earcutInjection can be used to inject your own earcut reference
  118700. * @returns the polygon mesh
  118701. */
  118702. static ExtrudePolygon(name: string, options: {
  118703. shape: Vector3[];
  118704. holes?: Vector3[][];
  118705. depth?: number;
  118706. faceUV?: Vector4[];
  118707. faceColors?: Color4[];
  118708. updatable?: boolean;
  118709. sideOrientation?: number;
  118710. frontUVs?: Vector4;
  118711. backUVs?: Vector4;
  118712. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118713. }
  118714. }
  118715. declare module BABYLON {
  118716. /**
  118717. * Class containing static functions to help procedurally build meshes
  118718. */
  118719. export class LatheBuilder {
  118720. /**
  118721. * Creates lathe mesh.
  118722. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118723. * * 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
  118724. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118725. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118726. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118727. * * 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
  118728. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118729. * * 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
  118730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118734. * @param name defines the name of the mesh
  118735. * @param options defines the options used to create the mesh
  118736. * @param scene defines the hosting scene
  118737. * @returns the lathe mesh
  118738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118739. */
  118740. static CreateLathe(name: string, options: {
  118741. shape: Vector3[];
  118742. radius?: number;
  118743. tessellation?: number;
  118744. clip?: number;
  118745. arc?: number;
  118746. closed?: boolean;
  118747. updatable?: boolean;
  118748. sideOrientation?: number;
  118749. frontUVs?: Vector4;
  118750. backUVs?: Vector4;
  118751. cap?: number;
  118752. invertUV?: boolean;
  118753. }, scene?: Nullable<Scene>): Mesh;
  118754. }
  118755. }
  118756. declare module BABYLON {
  118757. /**
  118758. * Class containing static functions to help procedurally build meshes
  118759. */
  118760. export class TiledPlaneBuilder {
  118761. /**
  118762. * Creates a tiled plane mesh
  118763. * * The parameter `pattern` will, depending on value, do nothing or
  118764. * * * flip (reflect about central vertical) alternate tiles across and up
  118765. * * * flip every tile on alternate rows
  118766. * * * rotate (180 degs) alternate tiles across and up
  118767. * * * rotate every tile on alternate rows
  118768. * * * flip and rotate alternate tiles across and up
  118769. * * * flip and rotate every tile on alternate rows
  118770. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  118771. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  118772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118774. * * 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)
  118775. * * 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)
  118776. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118777. * @param name defines the name of the mesh
  118778. * @param options defines the options used to create the mesh
  118779. * @param scene defines the hosting scene
  118780. * @returns the box mesh
  118781. */
  118782. static CreateTiledPlane(name: string, options: {
  118783. pattern?: number;
  118784. tileSize?: number;
  118785. tileWidth?: number;
  118786. tileHeight?: number;
  118787. size?: number;
  118788. width?: number;
  118789. height?: number;
  118790. alignHorizontal?: number;
  118791. alignVertical?: number;
  118792. sideOrientation?: number;
  118793. frontUVs?: Vector4;
  118794. backUVs?: Vector4;
  118795. updatable?: boolean;
  118796. }, scene?: Nullable<Scene>): Mesh;
  118797. }
  118798. }
  118799. declare module BABYLON {
  118800. /**
  118801. * Class containing static functions to help procedurally build meshes
  118802. */
  118803. export class TubeBuilder {
  118804. /**
  118805. * Creates a tube mesh.
  118806. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118807. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118808. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118809. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118810. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118811. * * 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)
  118812. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118813. * * 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
  118814. * * 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
  118815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118819. * @param name defines the name of the mesh
  118820. * @param options defines the options used to create the mesh
  118821. * @param scene defines the hosting scene
  118822. * @returns the tube mesh
  118823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118824. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118825. */
  118826. static CreateTube(name: string, options: {
  118827. path: Vector3[];
  118828. radius?: number;
  118829. tessellation?: number;
  118830. radiusFunction?: {
  118831. (i: number, distance: number): number;
  118832. };
  118833. cap?: number;
  118834. arc?: number;
  118835. updatable?: boolean;
  118836. sideOrientation?: number;
  118837. frontUVs?: Vector4;
  118838. backUVs?: Vector4;
  118839. instance?: Mesh;
  118840. invertUV?: boolean;
  118841. }, scene?: Nullable<Scene>): Mesh;
  118842. }
  118843. }
  118844. declare module BABYLON {
  118845. /**
  118846. * Class containing static functions to help procedurally build meshes
  118847. */
  118848. export class IcoSphereBuilder {
  118849. /**
  118850. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118851. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118852. * * 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`)
  118853. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118854. * * 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
  118855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118858. * @param name defines the name of the mesh
  118859. * @param options defines the options used to create the mesh
  118860. * @param scene defines the hosting scene
  118861. * @returns the icosahedron mesh
  118862. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118863. */
  118864. static CreateIcoSphere(name: string, options: {
  118865. radius?: number;
  118866. radiusX?: number;
  118867. radiusY?: number;
  118868. radiusZ?: number;
  118869. flat?: boolean;
  118870. subdivisions?: number;
  118871. sideOrientation?: number;
  118872. frontUVs?: Vector4;
  118873. backUVs?: Vector4;
  118874. updatable?: boolean;
  118875. }, scene?: Nullable<Scene>): Mesh;
  118876. }
  118877. }
  118878. declare module BABYLON {
  118879. /**
  118880. * Class containing static functions to help procedurally build meshes
  118881. */
  118882. export class DecalBuilder {
  118883. /**
  118884. * Creates a decal mesh.
  118885. * 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
  118886. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118887. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118888. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118889. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118890. * @param name defines the name of the mesh
  118891. * @param sourceMesh defines the mesh where the decal must be applied
  118892. * @param options defines the options used to create the mesh
  118893. * @param scene defines the hosting scene
  118894. * @returns the decal mesh
  118895. * @see https://doc.babylonjs.com/how_to/decals
  118896. */
  118897. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118898. position?: Vector3;
  118899. normal?: Vector3;
  118900. size?: Vector3;
  118901. angle?: number;
  118902. }): Mesh;
  118903. }
  118904. }
  118905. declare module BABYLON {
  118906. /**
  118907. * Class containing static functions to help procedurally build meshes
  118908. */
  118909. export class MeshBuilder {
  118910. /**
  118911. * Creates a box mesh
  118912. * * The parameter `size` sets the size (float) of each box side (default 1)
  118913. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118914. * * 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)
  118915. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118919. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118920. * @param name defines the name of the mesh
  118921. * @param options defines the options used to create the mesh
  118922. * @param scene defines the hosting scene
  118923. * @returns the box mesh
  118924. */
  118925. static CreateBox(name: string, options: {
  118926. size?: number;
  118927. width?: number;
  118928. height?: number;
  118929. depth?: number;
  118930. faceUV?: Vector4[];
  118931. faceColors?: Color4[];
  118932. sideOrientation?: number;
  118933. frontUVs?: Vector4;
  118934. backUVs?: Vector4;
  118935. updatable?: boolean;
  118936. }, scene?: Nullable<Scene>): Mesh;
  118937. /**
  118938. * Creates a tiled box mesh
  118939. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118941. * @param name defines the name of the mesh
  118942. * @param options defines the options used to create the mesh
  118943. * @param scene defines the hosting scene
  118944. * @returns the tiled box mesh
  118945. */
  118946. static CreateTiledBox(name: string, options: {
  118947. pattern?: number;
  118948. size?: number;
  118949. width?: number;
  118950. height?: number;
  118951. depth: number;
  118952. tileSize?: number;
  118953. tileWidth?: number;
  118954. tileHeight?: number;
  118955. faceUV?: Vector4[];
  118956. faceColors?: Color4[];
  118957. alignHorizontal?: number;
  118958. alignVertical?: number;
  118959. sideOrientation?: number;
  118960. updatable?: boolean;
  118961. }, scene?: Nullable<Scene>): Mesh;
  118962. /**
  118963. * Creates a sphere mesh
  118964. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118965. * * 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`)
  118966. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118967. * * 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
  118968. * * 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)
  118969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118972. * @param name defines the name of the mesh
  118973. * @param options defines the options used to create the mesh
  118974. * @param scene defines the hosting scene
  118975. * @returns the sphere mesh
  118976. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118977. */
  118978. static CreateSphere(name: string, options: {
  118979. segments?: number;
  118980. diameter?: number;
  118981. diameterX?: number;
  118982. diameterY?: number;
  118983. diameterZ?: number;
  118984. arc?: number;
  118985. slice?: number;
  118986. sideOrientation?: number;
  118987. frontUVs?: Vector4;
  118988. backUVs?: Vector4;
  118989. updatable?: boolean;
  118990. }, scene?: Nullable<Scene>): Mesh;
  118991. /**
  118992. * Creates a plane polygonal mesh. By default, this is a disc
  118993. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  118994. * * 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
  118995. * * 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
  118996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118999. * @param name defines the name of the mesh
  119000. * @param options defines the options used to create the mesh
  119001. * @param scene defines the hosting scene
  119002. * @returns the plane polygonal mesh
  119003. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119004. */
  119005. static CreateDisc(name: string, options: {
  119006. radius?: number;
  119007. tessellation?: number;
  119008. arc?: number;
  119009. updatable?: boolean;
  119010. sideOrientation?: number;
  119011. frontUVs?: Vector4;
  119012. backUVs?: Vector4;
  119013. }, scene?: Nullable<Scene>): Mesh;
  119014. /**
  119015. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119016. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119017. * * 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`)
  119018. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119019. * * 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
  119020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119023. * @param name defines the name of the mesh
  119024. * @param options defines the options used to create the mesh
  119025. * @param scene defines the hosting scene
  119026. * @returns the icosahedron mesh
  119027. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119028. */
  119029. static CreateIcoSphere(name: string, options: {
  119030. radius?: number;
  119031. radiusX?: number;
  119032. radiusY?: number;
  119033. radiusZ?: number;
  119034. flat?: boolean;
  119035. subdivisions?: number;
  119036. sideOrientation?: number;
  119037. frontUVs?: Vector4;
  119038. backUVs?: Vector4;
  119039. updatable?: boolean;
  119040. }, scene?: Nullable<Scene>): Mesh;
  119041. /**
  119042. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119043. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119044. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119045. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119046. * * 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
  119047. * * 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
  119048. * * 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
  119049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119052. * * 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
  119053. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119054. * * 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
  119055. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119057. * @param name defines the name of the mesh
  119058. * @param options defines the options used to create the mesh
  119059. * @param scene defines the hosting scene
  119060. * @returns the ribbon mesh
  119061. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119063. */
  119064. static CreateRibbon(name: string, options: {
  119065. pathArray: Vector3[][];
  119066. closeArray?: boolean;
  119067. closePath?: boolean;
  119068. offset?: number;
  119069. updatable?: boolean;
  119070. sideOrientation?: number;
  119071. frontUVs?: Vector4;
  119072. backUVs?: Vector4;
  119073. instance?: Mesh;
  119074. invertUV?: boolean;
  119075. uvs?: Vector2[];
  119076. colors?: Color4[];
  119077. }, scene?: Nullable<Scene>): Mesh;
  119078. /**
  119079. * Creates a cylinder or a cone mesh
  119080. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119081. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119082. * * 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.
  119083. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119084. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119085. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119086. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119087. * * 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).
  119088. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119089. * * 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).
  119090. * * 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
  119091. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119092. * * 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
  119093. * * 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.
  119094. * * If `enclose` is false, a ring surface is one element.
  119095. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119096. * * 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
  119097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119100. * @param name defines the name of the mesh
  119101. * @param options defines the options used to create the mesh
  119102. * @param scene defines the hosting scene
  119103. * @returns the cylinder mesh
  119104. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119105. */
  119106. static CreateCylinder(name: string, options: {
  119107. height?: number;
  119108. diameterTop?: number;
  119109. diameterBottom?: number;
  119110. diameter?: number;
  119111. tessellation?: number;
  119112. subdivisions?: number;
  119113. arc?: number;
  119114. faceColors?: Color4[];
  119115. faceUV?: Vector4[];
  119116. updatable?: boolean;
  119117. hasRings?: boolean;
  119118. enclose?: boolean;
  119119. cap?: number;
  119120. sideOrientation?: number;
  119121. frontUVs?: Vector4;
  119122. backUVs?: Vector4;
  119123. }, scene?: Nullable<Scene>): Mesh;
  119124. /**
  119125. * Creates a torus mesh
  119126. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119127. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119128. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119132. * @param name defines the name of the mesh
  119133. * @param options defines the options used to create the mesh
  119134. * @param scene defines the hosting scene
  119135. * @returns the torus mesh
  119136. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119137. */
  119138. static CreateTorus(name: string, options: {
  119139. diameter?: number;
  119140. thickness?: number;
  119141. tessellation?: number;
  119142. updatable?: boolean;
  119143. sideOrientation?: number;
  119144. frontUVs?: Vector4;
  119145. backUVs?: Vector4;
  119146. }, scene?: Nullable<Scene>): Mesh;
  119147. /**
  119148. * Creates a torus knot mesh
  119149. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119150. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119151. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119152. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119156. * @param name defines the name of the mesh
  119157. * @param options defines the options used to create the mesh
  119158. * @param scene defines the hosting scene
  119159. * @returns the torus knot mesh
  119160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119161. */
  119162. static CreateTorusKnot(name: string, options: {
  119163. radius?: number;
  119164. tube?: number;
  119165. radialSegments?: number;
  119166. tubularSegments?: number;
  119167. p?: number;
  119168. q?: number;
  119169. updatable?: boolean;
  119170. sideOrientation?: number;
  119171. frontUVs?: Vector4;
  119172. backUVs?: Vector4;
  119173. }, scene?: Nullable<Scene>): Mesh;
  119174. /**
  119175. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119176. * * 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
  119177. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119178. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119179. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119180. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119181. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119182. * * 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
  119183. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119186. * @param name defines the name of the new line system
  119187. * @param options defines the options used to create the line system
  119188. * @param scene defines the hosting scene
  119189. * @returns a new line system mesh
  119190. */
  119191. static CreateLineSystem(name: string, options: {
  119192. lines: Vector3[][];
  119193. updatable?: boolean;
  119194. instance?: Nullable<LinesMesh>;
  119195. colors?: Nullable<Color4[][]>;
  119196. useVertexAlpha?: boolean;
  119197. }, scene: Nullable<Scene>): LinesMesh;
  119198. /**
  119199. * Creates a line mesh
  119200. * 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
  119201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119202. * * The parameter `points` is an array successive Vector3
  119203. * * 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
  119204. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119205. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119206. * * When updating an instance, remember that only point positions can change, not the number of points
  119207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119209. * @param name defines the name of the new line system
  119210. * @param options defines the options used to create the line system
  119211. * @param scene defines the hosting scene
  119212. * @returns a new line mesh
  119213. */
  119214. static CreateLines(name: string, options: {
  119215. points: Vector3[];
  119216. updatable?: boolean;
  119217. instance?: Nullable<LinesMesh>;
  119218. colors?: Color4[];
  119219. useVertexAlpha?: boolean;
  119220. }, scene?: Nullable<Scene>): LinesMesh;
  119221. /**
  119222. * Creates a dashed line mesh
  119223. * * 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
  119224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119225. * * The parameter `points` is an array successive Vector3
  119226. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119227. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119228. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119229. * * 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
  119230. * * When updating an instance, remember that only point positions can change, not the number of points
  119231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119232. * @param name defines the name of the mesh
  119233. * @param options defines the options used to create the mesh
  119234. * @param scene defines the hosting scene
  119235. * @returns the dashed line mesh
  119236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119237. */
  119238. static CreateDashedLines(name: string, options: {
  119239. points: Vector3[];
  119240. dashSize?: number;
  119241. gapSize?: number;
  119242. dashNb?: number;
  119243. updatable?: boolean;
  119244. instance?: LinesMesh;
  119245. }, scene?: Nullable<Scene>): LinesMesh;
  119246. /**
  119247. * 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.
  119248. * * 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.
  119249. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119250. * * 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.
  119251. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119252. * * 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
  119253. * * 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
  119254. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119259. * @param name defines the name of the mesh
  119260. * @param options defines the options used to create the mesh
  119261. * @param scene defines the hosting scene
  119262. * @returns the extruded shape mesh
  119263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119265. */
  119266. static ExtrudeShape(name: string, options: {
  119267. shape: Vector3[];
  119268. path: Vector3[];
  119269. scale?: number;
  119270. rotation?: number;
  119271. cap?: number;
  119272. updatable?: boolean;
  119273. sideOrientation?: number;
  119274. frontUVs?: Vector4;
  119275. backUVs?: Vector4;
  119276. instance?: Mesh;
  119277. invertUV?: boolean;
  119278. }, scene?: Nullable<Scene>): Mesh;
  119279. /**
  119280. * Creates an custom extruded shape mesh.
  119281. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119282. * * 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.
  119283. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119284. * * 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
  119285. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119286. * * 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
  119287. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119288. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119289. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119290. * * 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
  119291. * * 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
  119292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119297. * @param name defines the name of the mesh
  119298. * @param options defines the options used to create the mesh
  119299. * @param scene defines the hosting scene
  119300. * @returns the custom extruded shape mesh
  119301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119304. */
  119305. static ExtrudeShapeCustom(name: string, options: {
  119306. shape: Vector3[];
  119307. path: Vector3[];
  119308. scaleFunction?: any;
  119309. rotationFunction?: any;
  119310. ribbonCloseArray?: boolean;
  119311. ribbonClosePath?: boolean;
  119312. cap?: number;
  119313. updatable?: boolean;
  119314. sideOrientation?: number;
  119315. frontUVs?: Vector4;
  119316. backUVs?: Vector4;
  119317. instance?: Mesh;
  119318. invertUV?: boolean;
  119319. }, scene?: Nullable<Scene>): Mesh;
  119320. /**
  119321. * Creates lathe mesh.
  119322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119323. * * 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
  119324. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119325. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119326. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119327. * * 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
  119328. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119329. * * 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
  119330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119334. * @param name defines the name of the mesh
  119335. * @param options defines the options used to create the mesh
  119336. * @param scene defines the hosting scene
  119337. * @returns the lathe mesh
  119338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119339. */
  119340. static CreateLathe(name: string, options: {
  119341. shape: Vector3[];
  119342. radius?: number;
  119343. tessellation?: number;
  119344. clip?: number;
  119345. arc?: number;
  119346. closed?: boolean;
  119347. updatable?: boolean;
  119348. sideOrientation?: number;
  119349. frontUVs?: Vector4;
  119350. backUVs?: Vector4;
  119351. cap?: number;
  119352. invertUV?: boolean;
  119353. }, scene?: Nullable<Scene>): Mesh;
  119354. /**
  119355. * Creates a tiled plane mesh
  119356. * * You can set a limited pattern arrangement with the tiles
  119357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119360. * @param name defines the name of the mesh
  119361. * @param options defines the options used to create the mesh
  119362. * @param scene defines the hosting scene
  119363. * @returns the plane mesh
  119364. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119365. */
  119366. static CreateTiledPlane(name: string, options: {
  119367. pattern?: number;
  119368. tileSize?: number;
  119369. tileWidth?: number;
  119370. tileHeight?: number;
  119371. size?: number;
  119372. width?: number;
  119373. height?: number;
  119374. alignHorizontal?: number;
  119375. alignVertical?: number;
  119376. sideOrientation?: number;
  119377. frontUVs?: Vector4;
  119378. backUVs?: Vector4;
  119379. updatable?: boolean;
  119380. }, scene?: Nullable<Scene>): Mesh;
  119381. /**
  119382. * Creates a plane mesh
  119383. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119384. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119385. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119389. * @param name defines the name of the mesh
  119390. * @param options defines the options used to create the mesh
  119391. * @param scene defines the hosting scene
  119392. * @returns the plane mesh
  119393. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119394. */
  119395. static CreatePlane(name: string, options: {
  119396. size?: number;
  119397. width?: number;
  119398. height?: number;
  119399. sideOrientation?: number;
  119400. frontUVs?: Vector4;
  119401. backUVs?: Vector4;
  119402. updatable?: boolean;
  119403. sourcePlane?: Plane;
  119404. }, scene?: Nullable<Scene>): Mesh;
  119405. /**
  119406. * Creates a ground mesh
  119407. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  119408. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  119409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119410. * @param name defines the name of the mesh
  119411. * @param options defines the options used to create the mesh
  119412. * @param scene defines the hosting scene
  119413. * @returns the ground mesh
  119414. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  119415. */
  119416. static CreateGround(name: string, options: {
  119417. width?: number;
  119418. height?: number;
  119419. subdivisions?: number;
  119420. subdivisionsX?: number;
  119421. subdivisionsY?: number;
  119422. updatable?: boolean;
  119423. }, scene?: Nullable<Scene>): Mesh;
  119424. /**
  119425. * Creates a tiled ground mesh
  119426. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  119427. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  119428. * * 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
  119429. * * 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
  119430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119431. * @param name defines the name of the mesh
  119432. * @param options defines the options used to create the mesh
  119433. * @param scene defines the hosting scene
  119434. * @returns the tiled ground mesh
  119435. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  119436. */
  119437. static CreateTiledGround(name: string, options: {
  119438. xmin: number;
  119439. zmin: number;
  119440. xmax: number;
  119441. zmax: number;
  119442. subdivisions?: {
  119443. w: number;
  119444. h: number;
  119445. };
  119446. precision?: {
  119447. w: number;
  119448. h: number;
  119449. };
  119450. updatable?: boolean;
  119451. }, scene?: Nullable<Scene>): Mesh;
  119452. /**
  119453. * Creates a ground mesh from a height map
  119454. * * The parameter `url` sets the URL of the height map image resource.
  119455. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  119456. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  119457. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  119458. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  119459. * * 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.
  119460. * * 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).
  119461. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119463. * @param name defines the name of the mesh
  119464. * @param url defines the url to the height map
  119465. * @param options defines the options used to create the mesh
  119466. * @param scene defines the hosting scene
  119467. * @returns the ground mesh
  119468. * @see https://doc.babylonjs.com/babylon101/height_map
  119469. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119470. */
  119471. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119472. width?: number;
  119473. height?: number;
  119474. subdivisions?: number;
  119475. minHeight?: number;
  119476. maxHeight?: number;
  119477. colorFilter?: Color3;
  119478. alphaFilter?: number;
  119479. updatable?: boolean;
  119480. onReady?: (mesh: GroundMesh) => void;
  119481. }, scene?: Nullable<Scene>): GroundMesh;
  119482. /**
  119483. * Creates a polygon mesh
  119484. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119485. * * 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
  119486. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119489. * * Remember you can only change the shape positions, not their number when updating a polygon
  119490. * @param name defines the name of the mesh
  119491. * @param options defines the options used to create the mesh
  119492. * @param scene defines the hosting scene
  119493. * @param earcutInjection can be used to inject your own earcut reference
  119494. * @returns the polygon mesh
  119495. */
  119496. static CreatePolygon(name: string, options: {
  119497. shape: Vector3[];
  119498. holes?: Vector3[][];
  119499. depth?: number;
  119500. faceUV?: Vector4[];
  119501. faceColors?: Color4[];
  119502. updatable?: boolean;
  119503. sideOrientation?: number;
  119504. frontUVs?: Vector4;
  119505. backUVs?: Vector4;
  119506. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119507. /**
  119508. * Creates an extruded polygon mesh, with depth in the Y direction.
  119509. * * 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)
  119510. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119511. * @param name defines the name of the mesh
  119512. * @param options defines the options used to create the mesh
  119513. * @param scene defines the hosting scene
  119514. * @param earcutInjection can be used to inject your own earcut reference
  119515. * @returns the polygon mesh
  119516. */
  119517. static ExtrudePolygon(name: string, options: {
  119518. shape: Vector3[];
  119519. holes?: Vector3[][];
  119520. depth?: number;
  119521. faceUV?: Vector4[];
  119522. faceColors?: Color4[];
  119523. updatable?: boolean;
  119524. sideOrientation?: number;
  119525. frontUVs?: Vector4;
  119526. backUVs?: Vector4;
  119527. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119528. /**
  119529. * Creates a tube mesh.
  119530. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119531. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119532. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119533. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119534. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119535. * * 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)
  119536. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119537. * * 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
  119538. * * 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
  119539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119543. * @param name defines the name of the mesh
  119544. * @param options defines the options used to create the mesh
  119545. * @param scene defines the hosting scene
  119546. * @returns the tube mesh
  119547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119548. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119549. */
  119550. static CreateTube(name: string, options: {
  119551. path: Vector3[];
  119552. radius?: number;
  119553. tessellation?: number;
  119554. radiusFunction?: {
  119555. (i: number, distance: number): number;
  119556. };
  119557. cap?: number;
  119558. arc?: number;
  119559. updatable?: boolean;
  119560. sideOrientation?: number;
  119561. frontUVs?: Vector4;
  119562. backUVs?: Vector4;
  119563. instance?: Mesh;
  119564. invertUV?: boolean;
  119565. }, scene?: Nullable<Scene>): Mesh;
  119566. /**
  119567. * Creates a polyhedron mesh
  119568. * * 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
  119569. * * The parameter `size` (positive float, default 1) sets the polygon size
  119570. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119571. * * 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`
  119572. * * 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
  119573. * * 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)`)
  119574. * * 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
  119575. * * 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
  119576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119579. * @param name defines the name of the mesh
  119580. * @param options defines the options used to create the mesh
  119581. * @param scene defines the hosting scene
  119582. * @returns the polyhedron mesh
  119583. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119584. */
  119585. static CreatePolyhedron(name: string, options: {
  119586. type?: number;
  119587. size?: number;
  119588. sizeX?: number;
  119589. sizeY?: number;
  119590. sizeZ?: number;
  119591. custom?: any;
  119592. faceUV?: Vector4[];
  119593. faceColors?: Color4[];
  119594. flat?: boolean;
  119595. updatable?: boolean;
  119596. sideOrientation?: number;
  119597. frontUVs?: Vector4;
  119598. backUVs?: Vector4;
  119599. }, scene?: Nullable<Scene>): Mesh;
  119600. /**
  119601. * Creates a decal mesh.
  119602. * 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
  119603. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119604. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119605. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119606. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119607. * @param name defines the name of the mesh
  119608. * @param sourceMesh defines the mesh where the decal must be applied
  119609. * @param options defines the options used to create the mesh
  119610. * @param scene defines the hosting scene
  119611. * @returns the decal mesh
  119612. * @see https://doc.babylonjs.com/how_to/decals
  119613. */
  119614. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119615. position?: Vector3;
  119616. normal?: Vector3;
  119617. size?: Vector3;
  119618. angle?: number;
  119619. }): Mesh;
  119620. }
  119621. }
  119622. declare module BABYLON {
  119623. /**
  119624. * A simplifier interface for future simplification implementations
  119625. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119626. */
  119627. export interface ISimplifier {
  119628. /**
  119629. * Simplification of a given mesh according to the given settings.
  119630. * Since this requires computation, it is assumed that the function runs async.
  119631. * @param settings The settings of the simplification, including quality and distance
  119632. * @param successCallback A callback that will be called after the mesh was simplified.
  119633. * @param errorCallback in case of an error, this callback will be called. optional.
  119634. */
  119635. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119636. }
  119637. /**
  119638. * Expected simplification settings.
  119639. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119641. */
  119642. export interface ISimplificationSettings {
  119643. /**
  119644. * Gets or sets the expected quality
  119645. */
  119646. quality: number;
  119647. /**
  119648. * Gets or sets the distance when this optimized version should be used
  119649. */
  119650. distance: number;
  119651. /**
  119652. * Gets an already optimized mesh
  119653. */
  119654. optimizeMesh?: boolean;
  119655. }
  119656. /**
  119657. * Class used to specify simplification options
  119658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119659. */
  119660. export class SimplificationSettings implements ISimplificationSettings {
  119661. /** expected quality */
  119662. quality: number;
  119663. /** distance when this optimized version should be used */
  119664. distance: number;
  119665. /** already optimized mesh */
  119666. optimizeMesh?: boolean | undefined;
  119667. /**
  119668. * Creates a SimplificationSettings
  119669. * @param quality expected quality
  119670. * @param distance distance when this optimized version should be used
  119671. * @param optimizeMesh already optimized mesh
  119672. */
  119673. constructor(
  119674. /** expected quality */
  119675. quality: number,
  119676. /** distance when this optimized version should be used */
  119677. distance: number,
  119678. /** already optimized mesh */
  119679. optimizeMesh?: boolean | undefined);
  119680. }
  119681. /**
  119682. * Interface used to define a simplification task
  119683. */
  119684. export interface ISimplificationTask {
  119685. /**
  119686. * Array of settings
  119687. */
  119688. settings: Array<ISimplificationSettings>;
  119689. /**
  119690. * Simplification type
  119691. */
  119692. simplificationType: SimplificationType;
  119693. /**
  119694. * Mesh to simplify
  119695. */
  119696. mesh: Mesh;
  119697. /**
  119698. * Callback called on success
  119699. */
  119700. successCallback?: () => void;
  119701. /**
  119702. * Defines if parallel processing can be used
  119703. */
  119704. parallelProcessing: boolean;
  119705. }
  119706. /**
  119707. * Queue used to order the simplification tasks
  119708. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119709. */
  119710. export class SimplificationQueue {
  119711. private _simplificationArray;
  119712. /**
  119713. * Gets a boolean indicating that the process is still running
  119714. */
  119715. running: boolean;
  119716. /**
  119717. * Creates a new queue
  119718. */
  119719. constructor();
  119720. /**
  119721. * Adds a new simplification task
  119722. * @param task defines a task to add
  119723. */
  119724. addTask(task: ISimplificationTask): void;
  119725. /**
  119726. * Execute next task
  119727. */
  119728. executeNext(): void;
  119729. /**
  119730. * Execute a simplification task
  119731. * @param task defines the task to run
  119732. */
  119733. runSimplification(task: ISimplificationTask): void;
  119734. private getSimplifier;
  119735. }
  119736. /**
  119737. * The implemented types of simplification
  119738. * At the moment only Quadratic Error Decimation is implemented
  119739. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119740. */
  119741. export enum SimplificationType {
  119742. /** Quadratic error decimation */
  119743. QUADRATIC = 0
  119744. }
  119745. }
  119746. declare module BABYLON {
  119747. interface Scene {
  119748. /** @hidden (Backing field) */
  119749. _simplificationQueue: SimplificationQueue;
  119750. /**
  119751. * Gets or sets the simplification queue attached to the scene
  119752. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119753. */
  119754. simplificationQueue: SimplificationQueue;
  119755. }
  119756. interface Mesh {
  119757. /**
  119758. * Simplify the mesh according to the given array of settings.
  119759. * Function will return immediately and will simplify async
  119760. * @param settings a collection of simplification settings
  119761. * @param parallelProcessing should all levels calculate parallel or one after the other
  119762. * @param simplificationType the type of simplification to run
  119763. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  119764. * @returns the current mesh
  119765. */
  119766. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  119767. }
  119768. /**
  119769. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  119770. * created in a scene
  119771. */
  119772. export class SimplicationQueueSceneComponent implements ISceneComponent {
  119773. /**
  119774. * The component name helpfull to identify the component in the list of scene components.
  119775. */
  119776. readonly name: string;
  119777. /**
  119778. * The scene the component belongs to.
  119779. */
  119780. scene: Scene;
  119781. /**
  119782. * Creates a new instance of the component for the given scene
  119783. * @param scene Defines the scene to register the component in
  119784. */
  119785. constructor(scene: Scene);
  119786. /**
  119787. * Registers the component in a given scene
  119788. */
  119789. register(): void;
  119790. /**
  119791. * Rebuilds the elements related to this component in case of
  119792. * context lost for instance.
  119793. */
  119794. rebuild(): void;
  119795. /**
  119796. * Disposes the component and the associated ressources
  119797. */
  119798. dispose(): void;
  119799. private _beforeCameraUpdate;
  119800. }
  119801. }
  119802. declare module BABYLON {
  119803. /**
  119804. * Navigation plugin interface to add navigation constrained by a navigation mesh
  119805. */
  119806. export interface INavigationEnginePlugin {
  119807. /**
  119808. * plugin name
  119809. */
  119810. name: string;
  119811. /**
  119812. * Creates a navigation mesh
  119813. * @param meshes array of all the geometry used to compute the navigatio mesh
  119814. * @param parameters bunch of parameters used to filter geometry
  119815. */
  119816. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119817. /**
  119818. * Create a navigation mesh debug mesh
  119819. * @param scene is where the mesh will be added
  119820. * @returns debug display mesh
  119821. */
  119822. createDebugNavMesh(scene: Scene): Mesh;
  119823. /**
  119824. * Get a navigation mesh constrained position, closest to the parameter position
  119825. * @param position world position
  119826. * @returns the closest point to position constrained by the navigation mesh
  119827. */
  119828. getClosestPoint(position: Vector3): Vector3;
  119829. /**
  119830. * Get a navigation mesh constrained position, within a particular radius
  119831. * @param position world position
  119832. * @param maxRadius the maximum distance to the constrained world position
  119833. * @returns the closest point to position constrained by the navigation mesh
  119834. */
  119835. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119836. /**
  119837. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119838. * @param start world position
  119839. * @param end world position
  119840. * @returns array containing world position composing the path
  119841. */
  119842. computePath(start: Vector3, end: Vector3): Vector3[];
  119843. /**
  119844. * If this plugin is supported
  119845. * @returns true if plugin is supported
  119846. */
  119847. isSupported(): boolean;
  119848. /**
  119849. * Create a new Crowd so you can add agents
  119850. * @param maxAgents the maximum agent count in the crowd
  119851. * @param maxAgentRadius the maximum radius an agent can have
  119852. * @param scene to attach the crowd to
  119853. * @returns the crowd you can add agents to
  119854. */
  119855. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119856. /**
  119857. * Release all resources
  119858. */
  119859. dispose(): void;
  119860. }
  119861. /**
  119862. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  119863. */
  119864. export interface ICrowd {
  119865. /**
  119866. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119867. * You can attach anything to that node. The node position is updated in the scene update tick.
  119868. * @param pos world position that will be constrained by the navigation mesh
  119869. * @param parameters agent parameters
  119870. * @param transform hooked to the agent that will be update by the scene
  119871. * @returns agent index
  119872. */
  119873. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119874. /**
  119875. * Returns the agent position in world space
  119876. * @param index agent index returned by addAgent
  119877. * @returns world space position
  119878. */
  119879. getAgentPosition(index: number): Vector3;
  119880. /**
  119881. * Gets the agent velocity in world space
  119882. * @param index agent index returned by addAgent
  119883. * @returns world space velocity
  119884. */
  119885. getAgentVelocity(index: number): Vector3;
  119886. /**
  119887. * remove a particular agent previously created
  119888. * @param index agent index returned by addAgent
  119889. */
  119890. removeAgent(index: number): void;
  119891. /**
  119892. * get the list of all agents attached to this crowd
  119893. * @returns list of agent indices
  119894. */
  119895. getAgents(): number[];
  119896. /**
  119897. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119898. * @param deltaTime in seconds
  119899. */
  119900. update(deltaTime: number): void;
  119901. /**
  119902. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119903. * @param index agent index returned by addAgent
  119904. * @param destination targeted world position
  119905. */
  119906. agentGoto(index: number, destination: Vector3): void;
  119907. /**
  119908. * Release all resources
  119909. */
  119910. dispose(): void;
  119911. }
  119912. /**
  119913. * Configures an agent
  119914. */
  119915. export interface IAgentParameters {
  119916. /**
  119917. * Agent radius. [Limit: >= 0]
  119918. */
  119919. radius: number;
  119920. /**
  119921. * Agent height. [Limit: > 0]
  119922. */
  119923. height: number;
  119924. /**
  119925. * Maximum allowed acceleration. [Limit: >= 0]
  119926. */
  119927. maxAcceleration: number;
  119928. /**
  119929. * Maximum allowed speed. [Limit: >= 0]
  119930. */
  119931. maxSpeed: number;
  119932. /**
  119933. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  119934. */
  119935. collisionQueryRange: number;
  119936. /**
  119937. * The path visibility optimization range. [Limit: > 0]
  119938. */
  119939. pathOptimizationRange: number;
  119940. /**
  119941. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  119942. */
  119943. separationWeight: number;
  119944. }
  119945. /**
  119946. * Configures the navigation mesh creation
  119947. */
  119948. export interface INavMeshParameters {
  119949. /**
  119950. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  119951. */
  119952. cs: number;
  119953. /**
  119954. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  119955. */
  119956. ch: number;
  119957. /**
  119958. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  119959. */
  119960. walkableSlopeAngle: number;
  119961. /**
  119962. * Minimum floor to 'ceiling' height that will still allow the floor area to
  119963. * be considered walkable. [Limit: >= 3] [Units: vx]
  119964. */
  119965. walkableHeight: number;
  119966. /**
  119967. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  119968. */
  119969. walkableClimb: number;
  119970. /**
  119971. * The distance to erode/shrink the walkable area of the heightfield away from
  119972. * obstructions. [Limit: >=0] [Units: vx]
  119973. */
  119974. walkableRadius: number;
  119975. /**
  119976. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  119977. */
  119978. maxEdgeLen: number;
  119979. /**
  119980. * The maximum distance a simplfied contour's border edges should deviate
  119981. * the original raw contour. [Limit: >=0] [Units: vx]
  119982. */
  119983. maxSimplificationError: number;
  119984. /**
  119985. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  119986. */
  119987. minRegionArea: number;
  119988. /**
  119989. * Any regions with a span count smaller than this value will, if possible,
  119990. * be merged with larger regions. [Limit: >=0] [Units: vx]
  119991. */
  119992. mergeRegionArea: number;
  119993. /**
  119994. * The maximum number of vertices allowed for polygons generated during the
  119995. * contour to polygon conversion process. [Limit: >= 3]
  119996. */
  119997. maxVertsPerPoly: number;
  119998. /**
  119999. * Sets the sampling distance to use when generating the detail mesh.
  120000. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120001. */
  120002. detailSampleDist: number;
  120003. /**
  120004. * The maximum distance the detail mesh surface should deviate from heightfield
  120005. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120006. */
  120007. detailSampleMaxError: number;
  120008. }
  120009. }
  120010. declare module BABYLON {
  120011. /**
  120012. * RecastJS navigation plugin
  120013. */
  120014. export class RecastJSPlugin implements INavigationEnginePlugin {
  120015. /**
  120016. * Reference to the Recast library
  120017. */
  120018. bjsRECAST: any;
  120019. /**
  120020. * plugin name
  120021. */
  120022. name: string;
  120023. /**
  120024. * the first navmesh created. We might extend this to support multiple navmeshes
  120025. */
  120026. navMesh: any;
  120027. /**
  120028. * Initializes the recastJS plugin
  120029. * @param recastInjection can be used to inject your own recast reference
  120030. */
  120031. constructor(recastInjection?: any);
  120032. /**
  120033. * Creates a navigation mesh
  120034. * @param meshes array of all the geometry used to compute the navigatio mesh
  120035. * @param parameters bunch of parameters used to filter geometry
  120036. */
  120037. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120038. /**
  120039. * Create a navigation mesh debug mesh
  120040. * @param scene is where the mesh will be added
  120041. * @returns debug display mesh
  120042. */
  120043. createDebugNavMesh(scene: Scene): Mesh;
  120044. /**
  120045. * Get a navigation mesh constrained position, closest to the parameter position
  120046. * @param position world position
  120047. * @returns the closest point to position constrained by the navigation mesh
  120048. */
  120049. getClosestPoint(position: Vector3): Vector3;
  120050. /**
  120051. * Get a navigation mesh constrained position, within a particular radius
  120052. * @param position world position
  120053. * @param maxRadius the maximum distance to the constrained world position
  120054. * @returns the closest point to position constrained by the navigation mesh
  120055. */
  120056. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120057. /**
  120058. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120059. * @param start world position
  120060. * @param end world position
  120061. * @returns array containing world position composing the path
  120062. */
  120063. computePath(start: Vector3, end: Vector3): Vector3[];
  120064. /**
  120065. * Create a new Crowd so you can add agents
  120066. * @param maxAgents the maximum agent count in the crowd
  120067. * @param maxAgentRadius the maximum radius an agent can have
  120068. * @param scene to attach the crowd to
  120069. * @returns the crowd you can add agents to
  120070. */
  120071. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120072. /**
  120073. * Disposes
  120074. */
  120075. dispose(): void;
  120076. /**
  120077. * If this plugin is supported
  120078. * @returns true if plugin is supported
  120079. */
  120080. isSupported(): boolean;
  120081. }
  120082. /**
  120083. * Recast detour crowd implementation
  120084. */
  120085. export class RecastJSCrowd implements ICrowd {
  120086. /**
  120087. * Recast/detour plugin
  120088. */
  120089. bjsRECASTPlugin: RecastJSPlugin;
  120090. /**
  120091. * Link to the detour crowd
  120092. */
  120093. recastCrowd: any;
  120094. /**
  120095. * One transform per agent
  120096. */
  120097. transforms: TransformNode[];
  120098. /**
  120099. * All agents created
  120100. */
  120101. agents: number[];
  120102. /**
  120103. * Link to the scene is kept to unregister the crowd from the scene
  120104. */
  120105. private _scene;
  120106. /**
  120107. * Observer for crowd updates
  120108. */
  120109. private _onBeforeAnimationsObserver;
  120110. /**
  120111. * Constructor
  120112. * @param plugin recastJS plugin
  120113. * @param maxAgents the maximum agent count in the crowd
  120114. * @param maxAgentRadius the maximum radius an agent can have
  120115. * @param scene to attach the crowd to
  120116. * @returns the crowd you can add agents to
  120117. */
  120118. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  120119. /**
  120120. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120121. * You can attach anything to that node. The node position is updated in the scene update tick.
  120122. * @param pos world position that will be constrained by the navigation mesh
  120123. * @param parameters agent parameters
  120124. * @param transform hooked to the agent that will be update by the scene
  120125. * @returns agent index
  120126. */
  120127. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120128. /**
  120129. * Returns the agent position in world space
  120130. * @param index agent index returned by addAgent
  120131. * @returns world space position
  120132. */
  120133. getAgentPosition(index: number): Vector3;
  120134. /**
  120135. * Returns the agent velocity in world space
  120136. * @param index agent index returned by addAgent
  120137. * @returns world space velocity
  120138. */
  120139. getAgentVelocity(index: number): Vector3;
  120140. /**
  120141. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120142. * @param index agent index returned by addAgent
  120143. * @param destination targeted world position
  120144. */
  120145. agentGoto(index: number, destination: Vector3): void;
  120146. /**
  120147. * remove a particular agent previously created
  120148. * @param index agent index returned by addAgent
  120149. */
  120150. removeAgent(index: number): void;
  120151. /**
  120152. * get the list of all agents attached to this crowd
  120153. * @returns list of agent indices
  120154. */
  120155. getAgents(): number[];
  120156. /**
  120157. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120158. * @param deltaTime in seconds
  120159. */
  120160. update(deltaTime: number): void;
  120161. /**
  120162. * Release all resources
  120163. */
  120164. dispose(): void;
  120165. }
  120166. }
  120167. declare module BABYLON {
  120168. /**
  120169. * Class used to enable access to IndexedDB
  120170. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120171. */
  120172. export class Database implements IOfflineProvider {
  120173. private _callbackManifestChecked;
  120174. private _currentSceneUrl;
  120175. private _db;
  120176. private _enableSceneOffline;
  120177. private _enableTexturesOffline;
  120178. private _manifestVersionFound;
  120179. private _mustUpdateRessources;
  120180. private _hasReachedQuota;
  120181. private _isSupported;
  120182. private _idbFactory;
  120183. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  120184. private static IsUASupportingBlobStorage;
  120185. /**
  120186. * Gets a boolean indicating if Database storate is enabled (off by default)
  120187. */
  120188. static IDBStorageEnabled: boolean;
  120189. /**
  120190. * Gets a boolean indicating if scene must be saved in the database
  120191. */
  120192. readonly enableSceneOffline: boolean;
  120193. /**
  120194. * Gets a boolean indicating if textures must be saved in the database
  120195. */
  120196. readonly enableTexturesOffline: boolean;
  120197. /**
  120198. * Creates a new Database
  120199. * @param urlToScene defines the url to load the scene
  120200. * @param callbackManifestChecked defines the callback to use when manifest is checked
  120201. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  120202. */
  120203. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  120204. private static _ParseURL;
  120205. private static _ReturnFullUrlLocation;
  120206. private _checkManifestFile;
  120207. /**
  120208. * Open the database and make it available
  120209. * @param successCallback defines the callback to call on success
  120210. * @param errorCallback defines the callback to call on error
  120211. */
  120212. open(successCallback: () => void, errorCallback: () => void): void;
  120213. /**
  120214. * Loads an image from the database
  120215. * @param url defines the url to load from
  120216. * @param image defines the target DOM image
  120217. */
  120218. loadImage(url: string, image: HTMLImageElement): void;
  120219. private _loadImageFromDBAsync;
  120220. private _saveImageIntoDBAsync;
  120221. private _checkVersionFromDB;
  120222. private _loadVersionFromDBAsync;
  120223. private _saveVersionIntoDBAsync;
  120224. /**
  120225. * Loads a file from database
  120226. * @param url defines the URL to load from
  120227. * @param sceneLoaded defines a callback to call on success
  120228. * @param progressCallBack defines a callback to call when progress changed
  120229. * @param errorCallback defines a callback to call on error
  120230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  120231. */
  120232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  120233. private _loadFileAsync;
  120234. private _saveFileAsync;
  120235. /**
  120236. * Validates if xhr data is correct
  120237. * @param xhr defines the request to validate
  120238. * @param dataType defines the expected data type
  120239. * @returns true if data is correct
  120240. */
  120241. private static _ValidateXHRData;
  120242. }
  120243. }
  120244. declare module BABYLON {
  120245. /** @hidden */
  120246. export var gpuUpdateParticlesPixelShader: {
  120247. name: string;
  120248. shader: string;
  120249. };
  120250. }
  120251. declare module BABYLON {
  120252. /** @hidden */
  120253. export var gpuUpdateParticlesVertexShader: {
  120254. name: string;
  120255. shader: string;
  120256. };
  120257. }
  120258. declare module BABYLON {
  120259. /** @hidden */
  120260. export var clipPlaneFragmentDeclaration2: {
  120261. name: string;
  120262. shader: string;
  120263. };
  120264. }
  120265. declare module BABYLON {
  120266. /** @hidden */
  120267. export var gpuRenderParticlesPixelShader: {
  120268. name: string;
  120269. shader: string;
  120270. };
  120271. }
  120272. declare module BABYLON {
  120273. /** @hidden */
  120274. export var clipPlaneVertexDeclaration2: {
  120275. name: string;
  120276. shader: string;
  120277. };
  120278. }
  120279. declare module BABYLON {
  120280. /** @hidden */
  120281. export var gpuRenderParticlesVertexShader: {
  120282. name: string;
  120283. shader: string;
  120284. };
  120285. }
  120286. declare module BABYLON {
  120287. /**
  120288. * This represents a GPU particle system in Babylon
  120289. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  120290. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  120291. */
  120292. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  120293. /**
  120294. * The layer mask we are rendering the particles through.
  120295. */
  120296. layerMask: number;
  120297. private _capacity;
  120298. private _activeCount;
  120299. private _currentActiveCount;
  120300. private _accumulatedCount;
  120301. private _renderEffect;
  120302. private _updateEffect;
  120303. private _buffer0;
  120304. private _buffer1;
  120305. private _spriteBuffer;
  120306. private _updateVAO;
  120307. private _renderVAO;
  120308. private _targetIndex;
  120309. private _sourceBuffer;
  120310. private _targetBuffer;
  120311. private _engine;
  120312. private _currentRenderId;
  120313. private _started;
  120314. private _stopped;
  120315. private _timeDelta;
  120316. private _randomTexture;
  120317. private _randomTexture2;
  120318. private _attributesStrideSize;
  120319. private _updateEffectOptions;
  120320. private _randomTextureSize;
  120321. private _actualFrame;
  120322. private readonly _rawTextureWidth;
  120323. /**
  120324. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  120325. */
  120326. static readonly IsSupported: boolean;
  120327. /**
  120328. * An event triggered when the system is disposed.
  120329. */
  120330. onDisposeObservable: Observable<GPUParticleSystem>;
  120331. /**
  120332. * Gets the maximum number of particles active at the same time.
  120333. * @returns The max number of active particles.
  120334. */
  120335. getCapacity(): number;
  120336. /**
  120337. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120338. * to override the particles.
  120339. */
  120340. forceDepthWrite: boolean;
  120341. /**
  120342. * Gets or set the number of active particles
  120343. */
  120344. activeParticleCount: number;
  120345. private _preWarmDone;
  120346. /**
  120347. * Is this system ready to be used/rendered
  120348. * @return true if the system is ready
  120349. */
  120350. isReady(): boolean;
  120351. /**
  120352. * Gets if the system has been started. (Note: this will still be true after stop is called)
  120353. * @returns True if it has been started, otherwise false.
  120354. */
  120355. isStarted(): boolean;
  120356. /**
  120357. * Starts the particle system and begins to emit
  120358. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  120359. */
  120360. start(delay?: number): void;
  120361. /**
  120362. * Stops the particle system.
  120363. */
  120364. stop(): void;
  120365. /**
  120366. * Remove all active particles
  120367. */
  120368. reset(): void;
  120369. /**
  120370. * Returns the string "GPUParticleSystem"
  120371. * @returns a string containing the class name
  120372. */
  120373. getClassName(): string;
  120374. private _colorGradientsTexture;
  120375. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  120376. /**
  120377. * Adds a new color gradient
  120378. * @param gradient defines the gradient to use (between 0 and 1)
  120379. * @param color1 defines the color to affect to the specified gradient
  120380. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  120381. * @returns the current particle system
  120382. */
  120383. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  120384. /**
  120385. * Remove a specific color gradient
  120386. * @param gradient defines the gradient to remove
  120387. * @returns the current particle system
  120388. */
  120389. removeColorGradient(gradient: number): GPUParticleSystem;
  120390. private _angularSpeedGradientsTexture;
  120391. private _sizeGradientsTexture;
  120392. private _velocityGradientsTexture;
  120393. private _limitVelocityGradientsTexture;
  120394. private _dragGradientsTexture;
  120395. private _addFactorGradient;
  120396. /**
  120397. * Adds a new size gradient
  120398. * @param gradient defines the gradient to use (between 0 and 1)
  120399. * @param factor defines the size factor to affect to the specified gradient
  120400. * @returns the current particle system
  120401. */
  120402. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  120403. /**
  120404. * Remove a specific size gradient
  120405. * @param gradient defines the gradient to remove
  120406. * @returns the current particle system
  120407. */
  120408. removeSizeGradient(gradient: number): GPUParticleSystem;
  120409. /**
  120410. * Adds a new angular speed gradient
  120411. * @param gradient defines the gradient to use (between 0 and 1)
  120412. * @param factor defines the angular speed to affect to the specified gradient
  120413. * @returns the current particle system
  120414. */
  120415. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  120416. /**
  120417. * Remove a specific angular speed gradient
  120418. * @param gradient defines the gradient to remove
  120419. * @returns the current particle system
  120420. */
  120421. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  120422. /**
  120423. * Adds a new velocity gradient
  120424. * @param gradient defines the gradient to use (between 0 and 1)
  120425. * @param factor defines the velocity to affect to the specified gradient
  120426. * @returns the current particle system
  120427. */
  120428. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120429. /**
  120430. * Remove a specific velocity gradient
  120431. * @param gradient defines the gradient to remove
  120432. * @returns the current particle system
  120433. */
  120434. removeVelocityGradient(gradient: number): GPUParticleSystem;
  120435. /**
  120436. * Adds a new limit velocity gradient
  120437. * @param gradient defines the gradient to use (between 0 and 1)
  120438. * @param factor defines the limit velocity value to affect to the specified gradient
  120439. * @returns the current particle system
  120440. */
  120441. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120442. /**
  120443. * Remove a specific limit velocity gradient
  120444. * @param gradient defines the gradient to remove
  120445. * @returns the current particle system
  120446. */
  120447. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  120448. /**
  120449. * Adds a new drag gradient
  120450. * @param gradient defines the gradient to use (between 0 and 1)
  120451. * @param factor defines the drag value to affect to the specified gradient
  120452. * @returns the current particle system
  120453. */
  120454. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  120455. /**
  120456. * Remove a specific drag gradient
  120457. * @param gradient defines the gradient to remove
  120458. * @returns the current particle system
  120459. */
  120460. removeDragGradient(gradient: number): GPUParticleSystem;
  120461. /**
  120462. * Not supported by GPUParticleSystem
  120463. * @param gradient defines the gradient to use (between 0 and 1)
  120464. * @param factor defines the emit rate value to affect to the specified gradient
  120465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120466. * @returns the current particle system
  120467. */
  120468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120469. /**
  120470. * Not supported by GPUParticleSystem
  120471. * @param gradient defines the gradient to remove
  120472. * @returns the current particle system
  120473. */
  120474. removeEmitRateGradient(gradient: number): IParticleSystem;
  120475. /**
  120476. * Not supported by GPUParticleSystem
  120477. * @param gradient defines the gradient to use (between 0 and 1)
  120478. * @param factor defines the start size value to affect to the specified gradient
  120479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120480. * @returns the current particle system
  120481. */
  120482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120483. /**
  120484. * Not supported by GPUParticleSystem
  120485. * @param gradient defines the gradient to remove
  120486. * @returns the current particle system
  120487. */
  120488. removeStartSizeGradient(gradient: number): IParticleSystem;
  120489. /**
  120490. * Not supported by GPUParticleSystem
  120491. * @param gradient defines the gradient to use (between 0 and 1)
  120492. * @param min defines the color remap minimal range
  120493. * @param max defines the color remap maximal range
  120494. * @returns the current particle system
  120495. */
  120496. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120497. /**
  120498. * Not supported by GPUParticleSystem
  120499. * @param gradient defines the gradient to remove
  120500. * @returns the current particle system
  120501. */
  120502. removeColorRemapGradient(): IParticleSystem;
  120503. /**
  120504. * Not supported by GPUParticleSystem
  120505. * @param gradient defines the gradient to use (between 0 and 1)
  120506. * @param min defines the alpha remap minimal range
  120507. * @param max defines the alpha remap maximal range
  120508. * @returns the current particle system
  120509. */
  120510. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120511. /**
  120512. * Not supported by GPUParticleSystem
  120513. * @param gradient defines the gradient to remove
  120514. * @returns the current particle system
  120515. */
  120516. removeAlphaRemapGradient(): IParticleSystem;
  120517. /**
  120518. * Not supported by GPUParticleSystem
  120519. * @param gradient defines the gradient to use (between 0 and 1)
  120520. * @param color defines the color to affect to the specified gradient
  120521. * @returns the current particle system
  120522. */
  120523. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  120524. /**
  120525. * Not supported by GPUParticleSystem
  120526. * @param gradient defines the gradient to remove
  120527. * @returns the current particle system
  120528. */
  120529. removeRampGradient(): IParticleSystem;
  120530. /**
  120531. * Not supported by GPUParticleSystem
  120532. * @returns the list of ramp gradients
  120533. */
  120534. getRampGradients(): Nullable<Array<Color3Gradient>>;
  120535. /**
  120536. * Not supported by GPUParticleSystem
  120537. * Gets or sets a boolean indicating that ramp gradients must be used
  120538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  120539. */
  120540. useRampGradients: boolean;
  120541. /**
  120542. * Not supported by GPUParticleSystem
  120543. * @param gradient defines the gradient to use (between 0 and 1)
  120544. * @param factor defines the life time factor to affect to the specified gradient
  120545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120546. * @returns the current particle system
  120547. */
  120548. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120549. /**
  120550. * Not supported by GPUParticleSystem
  120551. * @param gradient defines the gradient to remove
  120552. * @returns the current particle system
  120553. */
  120554. removeLifeTimeGradient(gradient: number): IParticleSystem;
  120555. /**
  120556. * Instantiates a GPU particle system.
  120557. * 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.
  120558. * @param name The name of the particle system
  120559. * @param options The options used to create the system
  120560. * @param scene The scene the particle system belongs to
  120561. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  120562. */
  120563. constructor(name: string, options: Partial<{
  120564. capacity: number;
  120565. randomTextureSize: number;
  120566. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  120567. protected _reset(): void;
  120568. private _createUpdateVAO;
  120569. private _createRenderVAO;
  120570. private _initialize;
  120571. /** @hidden */
  120572. _recreateUpdateEffect(): void;
  120573. /** @hidden */
  120574. _recreateRenderEffect(): void;
  120575. /**
  120576. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  120577. * @param preWarm defines if we are in the pre-warmimg phase
  120578. */
  120579. animate(preWarm?: boolean): void;
  120580. private _createFactorGradientTexture;
  120581. private _createSizeGradientTexture;
  120582. private _createAngularSpeedGradientTexture;
  120583. private _createVelocityGradientTexture;
  120584. private _createLimitVelocityGradientTexture;
  120585. private _createDragGradientTexture;
  120586. private _createColorGradientTexture;
  120587. /**
  120588. * Renders the particle system in its current state
  120589. * @param preWarm defines if the system should only update the particles but not render them
  120590. * @returns the current number of particles
  120591. */
  120592. render(preWarm?: boolean): number;
  120593. /**
  120594. * Rebuilds the particle system
  120595. */
  120596. rebuild(): void;
  120597. private _releaseBuffers;
  120598. private _releaseVAOs;
  120599. /**
  120600. * Disposes the particle system and free the associated resources
  120601. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120602. */
  120603. dispose(disposeTexture?: boolean): void;
  120604. /**
  120605. * Clones the particle system.
  120606. * @param name The name of the cloned object
  120607. * @param newEmitter The new emitter to use
  120608. * @returns the cloned particle system
  120609. */
  120610. clone(name: string, newEmitter: any): GPUParticleSystem;
  120611. /**
  120612. * Serializes the particle system to a JSON object.
  120613. * @returns the JSON object
  120614. */
  120615. serialize(): any;
  120616. /**
  120617. * Parses a JSON object to create a GPU particle system.
  120618. * @param parsedParticleSystem The JSON object to parse
  120619. * @param scene The scene to create the particle system in
  120620. * @param rootUrl The root url to use to load external dependencies like texture
  120621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120622. * @returns the parsed GPU particle system
  120623. */
  120624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120625. }
  120626. }
  120627. declare module BABYLON {
  120628. /**
  120629. * Represents a set of particle systems working together to create a specific effect
  120630. */
  120631. export class ParticleSystemSet implements IDisposable {
  120632. private _emitterCreationOptions;
  120633. private _emitterNode;
  120634. /**
  120635. * Gets the particle system list
  120636. */
  120637. systems: IParticleSystem[];
  120638. /**
  120639. * Gets the emitter node used with this set
  120640. */
  120641. readonly emitterNode: Nullable<TransformNode>;
  120642. /**
  120643. * Creates a new emitter mesh as a sphere
  120644. * @param options defines the options used to create the sphere
  120645. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120646. * @param scene defines the hosting scene
  120647. */
  120648. setEmitterAsSphere(options: {
  120649. diameter: number;
  120650. segments: number;
  120651. color: Color3;
  120652. }, renderingGroupId: number, scene: Scene): void;
  120653. /**
  120654. * Starts all particle systems of the set
  120655. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120656. */
  120657. start(emitter?: AbstractMesh): void;
  120658. /**
  120659. * Release all associated resources
  120660. */
  120661. dispose(): void;
  120662. /**
  120663. * Serialize the set into a JSON compatible object
  120664. * @returns a JSON compatible representation of the set
  120665. */
  120666. serialize(): any;
  120667. /**
  120668. * Parse a new ParticleSystemSet from a serialized source
  120669. * @param data defines a JSON compatible representation of the set
  120670. * @param scene defines the hosting scene
  120671. * @param gpu defines if we want GPU particles or CPU particles
  120672. * @returns a new ParticleSystemSet
  120673. */
  120674. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * This class is made for on one-liner static method to help creating particle system set.
  120680. */
  120681. export class ParticleHelper {
  120682. /**
  120683. * Gets or sets base Assets URL
  120684. */
  120685. static BaseAssetsUrl: string;
  120686. /**
  120687. * Create a default particle system that you can tweak
  120688. * @param emitter defines the emitter to use
  120689. * @param capacity defines the system capacity (default is 500 particles)
  120690. * @param scene defines the hosting scene
  120691. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120692. * @returns the new Particle system
  120693. */
  120694. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120695. /**
  120696. * This is the main static method (one-liner) of this helper to create different particle systems
  120697. * @param type This string represents the type to the particle system to create
  120698. * @param scene The scene where the particle system should live
  120699. * @param gpu If the system will use gpu
  120700. * @returns the ParticleSystemSet created
  120701. */
  120702. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120703. /**
  120704. * Static function used to export a particle system to a ParticleSystemSet variable.
  120705. * Please note that the emitter shape is not exported
  120706. * @param systems defines the particle systems to export
  120707. * @returns the created particle system set
  120708. */
  120709. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120710. }
  120711. }
  120712. declare module BABYLON {
  120713. interface Engine {
  120714. /**
  120715. * Create an effect to use with particle systems.
  120716. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120717. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120718. * @param uniformsNames defines a list of attribute names
  120719. * @param samplers defines an array of string used to represent textures
  120720. * @param defines defines the string containing the defines to use to compile the shaders
  120721. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120722. * @param onCompiled defines a function to call when the effect creation is successful
  120723. * @param onError defines a function to call when the effect creation has failed
  120724. * @returns the new Effect
  120725. */
  120726. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120727. }
  120728. interface Mesh {
  120729. /**
  120730. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120731. * @returns an array of IParticleSystem
  120732. */
  120733. getEmittedParticleSystems(): IParticleSystem[];
  120734. /**
  120735. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120736. * @returns an array of IParticleSystem
  120737. */
  120738. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120739. }
  120740. /**
  120741. * @hidden
  120742. */
  120743. export var _IDoNeedToBeInTheBuild: number;
  120744. }
  120745. declare module BABYLON {
  120746. interface Scene {
  120747. /** @hidden (Backing field) */
  120748. _physicsEngine: Nullable<IPhysicsEngine>;
  120749. /**
  120750. * Gets the current physics engine
  120751. * @returns a IPhysicsEngine or null if none attached
  120752. */
  120753. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  120754. /**
  120755. * Enables physics to the current scene
  120756. * @param gravity defines the scene's gravity for the physics engine
  120757. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  120758. * @return a boolean indicating if the physics engine was initialized
  120759. */
  120760. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  120761. /**
  120762. * Disables and disposes the physics engine associated with the scene
  120763. */
  120764. disablePhysicsEngine(): void;
  120765. /**
  120766. * Gets a boolean indicating if there is an active physics engine
  120767. * @returns a boolean indicating if there is an active physics engine
  120768. */
  120769. isPhysicsEnabled(): boolean;
  120770. /**
  120771. * Deletes a physics compound impostor
  120772. * @param compound defines the compound to delete
  120773. */
  120774. deleteCompoundImpostor(compound: any): void;
  120775. /**
  120776. * An event triggered when physic simulation is about to be run
  120777. */
  120778. onBeforePhysicsObservable: Observable<Scene>;
  120779. /**
  120780. * An event triggered when physic simulation has been done
  120781. */
  120782. onAfterPhysicsObservable: Observable<Scene>;
  120783. }
  120784. interface AbstractMesh {
  120785. /** @hidden */
  120786. _physicsImpostor: Nullable<PhysicsImpostor>;
  120787. /**
  120788. * Gets or sets impostor used for physic simulation
  120789. * @see http://doc.babylonjs.com/features/physics_engine
  120790. */
  120791. physicsImpostor: Nullable<PhysicsImpostor>;
  120792. /**
  120793. * Gets the current physics impostor
  120794. * @see http://doc.babylonjs.com/features/physics_engine
  120795. * @returns a physics impostor or null
  120796. */
  120797. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  120798. /** Apply a physic impulse to the mesh
  120799. * @param force defines the force to apply
  120800. * @param contactPoint defines where to apply the force
  120801. * @returns the current mesh
  120802. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120803. */
  120804. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  120805. /**
  120806. * Creates a physic joint between two meshes
  120807. * @param otherMesh defines the other mesh to use
  120808. * @param pivot1 defines the pivot to use on this mesh
  120809. * @param pivot2 defines the pivot to use on the other mesh
  120810. * @param options defines additional options (can be plugin dependent)
  120811. * @returns the current mesh
  120812. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  120813. */
  120814. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  120815. /** @hidden */
  120816. _disposePhysicsObserver: Nullable<Observer<Node>>;
  120817. }
  120818. /**
  120819. * Defines the physics engine scene component responsible to manage a physics engine
  120820. */
  120821. export class PhysicsEngineSceneComponent implements ISceneComponent {
  120822. /**
  120823. * The component name helpful to identify the component in the list of scene components.
  120824. */
  120825. readonly name: string;
  120826. /**
  120827. * The scene the component belongs to.
  120828. */
  120829. scene: Scene;
  120830. /**
  120831. * Creates a new instance of the component for the given scene
  120832. * @param scene Defines the scene to register the component in
  120833. */
  120834. constructor(scene: Scene);
  120835. /**
  120836. * Registers the component in a given scene
  120837. */
  120838. register(): void;
  120839. /**
  120840. * Rebuilds the elements related to this component in case of
  120841. * context lost for instance.
  120842. */
  120843. rebuild(): void;
  120844. /**
  120845. * Disposes the component and the associated ressources
  120846. */
  120847. dispose(): void;
  120848. }
  120849. }
  120850. declare module BABYLON {
  120851. /**
  120852. * A helper for physics simulations
  120853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120854. */
  120855. export class PhysicsHelper {
  120856. private _scene;
  120857. private _physicsEngine;
  120858. /**
  120859. * Initializes the Physics helper
  120860. * @param scene Babylon.js scene
  120861. */
  120862. constructor(scene: Scene);
  120863. /**
  120864. * Applies a radial explosion impulse
  120865. * @param origin the origin of the explosion
  120866. * @param radiusOrEventOptions the radius or the options of radial explosion
  120867. * @param strength the explosion strength
  120868. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120869. * @returns A physics radial explosion event, or null
  120870. */
  120871. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120872. /**
  120873. * Applies a radial explosion force
  120874. * @param origin the origin of the explosion
  120875. * @param radiusOrEventOptions the radius or the options of radial explosion
  120876. * @param strength the explosion strength
  120877. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120878. * @returns A physics radial explosion event, or null
  120879. */
  120880. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120881. /**
  120882. * Creates a gravitational field
  120883. * @param origin the origin of the explosion
  120884. * @param radiusOrEventOptions the radius or the options of radial explosion
  120885. * @param strength the explosion strength
  120886. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120887. * @returns A physics gravitational field event, or null
  120888. */
  120889. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  120890. /**
  120891. * Creates a physics updraft event
  120892. * @param origin the origin of the updraft
  120893. * @param radiusOrEventOptions the radius or the options of the updraft
  120894. * @param strength the strength of the updraft
  120895. * @param height the height of the updraft
  120896. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  120897. * @returns A physics updraft event, or null
  120898. */
  120899. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  120900. /**
  120901. * Creates a physics vortex event
  120902. * @param origin the of the vortex
  120903. * @param radiusOrEventOptions the radius or the options of the vortex
  120904. * @param strength the strength of the vortex
  120905. * @param height the height of the vortex
  120906. * @returns a Physics vortex event, or null
  120907. * A physics vortex event or null
  120908. */
  120909. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  120910. }
  120911. /**
  120912. * Represents a physics radial explosion event
  120913. */
  120914. class PhysicsRadialExplosionEvent {
  120915. private _scene;
  120916. private _options;
  120917. private _sphere;
  120918. private _dataFetched;
  120919. /**
  120920. * Initializes a radial explosioin event
  120921. * @param _scene BabylonJS scene
  120922. * @param _options The options for the vortex event
  120923. */
  120924. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  120925. /**
  120926. * Returns the data related to the radial explosion event (sphere).
  120927. * @returns The radial explosion event data
  120928. */
  120929. getData(): PhysicsRadialExplosionEventData;
  120930. /**
  120931. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  120932. * @param impostor A physics imposter
  120933. * @param origin the origin of the explosion
  120934. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  120935. */
  120936. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  120937. /**
  120938. * Triggers affecterd impostors callbacks
  120939. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  120940. */
  120941. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  120942. /**
  120943. * Disposes the sphere.
  120944. * @param force Specifies if the sphere should be disposed by force
  120945. */
  120946. dispose(force?: boolean): void;
  120947. /*** Helpers ***/
  120948. private _prepareSphere;
  120949. private _intersectsWithSphere;
  120950. }
  120951. /**
  120952. * Represents a gravitational field event
  120953. */
  120954. class PhysicsGravitationalFieldEvent {
  120955. private _physicsHelper;
  120956. private _scene;
  120957. private _origin;
  120958. private _options;
  120959. private _tickCallback;
  120960. private _sphere;
  120961. private _dataFetched;
  120962. /**
  120963. * Initializes the physics gravitational field event
  120964. * @param _physicsHelper A physics helper
  120965. * @param _scene BabylonJS scene
  120966. * @param _origin The origin position of the gravitational field event
  120967. * @param _options The options for the vortex event
  120968. */
  120969. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  120970. /**
  120971. * Returns the data related to the gravitational field event (sphere).
  120972. * @returns A gravitational field event
  120973. */
  120974. getData(): PhysicsGravitationalFieldEventData;
  120975. /**
  120976. * Enables the gravitational field.
  120977. */
  120978. enable(): void;
  120979. /**
  120980. * Disables the gravitational field.
  120981. */
  120982. disable(): void;
  120983. /**
  120984. * Disposes the sphere.
  120985. * @param force The force to dispose from the gravitational field event
  120986. */
  120987. dispose(force?: boolean): void;
  120988. private _tick;
  120989. }
  120990. /**
  120991. * Represents a physics updraft event
  120992. */
  120993. class PhysicsUpdraftEvent {
  120994. private _scene;
  120995. private _origin;
  120996. private _options;
  120997. private _physicsEngine;
  120998. private _originTop;
  120999. private _originDirection;
  121000. private _tickCallback;
  121001. private _cylinder;
  121002. private _cylinderPosition;
  121003. private _dataFetched;
  121004. /**
  121005. * Initializes the physics updraft event
  121006. * @param _scene BabylonJS scene
  121007. * @param _origin The origin position of the updraft
  121008. * @param _options The options for the updraft event
  121009. */
  121010. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121011. /**
  121012. * Returns the data related to the updraft event (cylinder).
  121013. * @returns A physics updraft event
  121014. */
  121015. getData(): PhysicsUpdraftEventData;
  121016. /**
  121017. * Enables the updraft.
  121018. */
  121019. enable(): void;
  121020. /**
  121021. * Disables the updraft.
  121022. */
  121023. disable(): void;
  121024. /**
  121025. * Disposes the cylinder.
  121026. * @param force Specifies if the updraft should be disposed by force
  121027. */
  121028. dispose(force?: boolean): void;
  121029. private getImpostorHitData;
  121030. private _tick;
  121031. /*** Helpers ***/
  121032. private _prepareCylinder;
  121033. private _intersectsWithCylinder;
  121034. }
  121035. /**
  121036. * Represents a physics vortex event
  121037. */
  121038. class PhysicsVortexEvent {
  121039. private _scene;
  121040. private _origin;
  121041. private _options;
  121042. private _physicsEngine;
  121043. private _originTop;
  121044. private _tickCallback;
  121045. private _cylinder;
  121046. private _cylinderPosition;
  121047. private _dataFetched;
  121048. /**
  121049. * Initializes the physics vortex event
  121050. * @param _scene The BabylonJS scene
  121051. * @param _origin The origin position of the vortex
  121052. * @param _options The options for the vortex event
  121053. */
  121054. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121055. /**
  121056. * Returns the data related to the vortex event (cylinder).
  121057. * @returns The physics vortex event data
  121058. */
  121059. getData(): PhysicsVortexEventData;
  121060. /**
  121061. * Enables the vortex.
  121062. */
  121063. enable(): void;
  121064. /**
  121065. * Disables the cortex.
  121066. */
  121067. disable(): void;
  121068. /**
  121069. * Disposes the sphere.
  121070. * @param force
  121071. */
  121072. dispose(force?: boolean): void;
  121073. private getImpostorHitData;
  121074. private _tick;
  121075. /*** Helpers ***/
  121076. private _prepareCylinder;
  121077. private _intersectsWithCylinder;
  121078. }
  121079. /**
  121080. * Options fot the radial explosion event
  121081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121082. */
  121083. export class PhysicsRadialExplosionEventOptions {
  121084. /**
  121085. * The radius of the sphere for the radial explosion.
  121086. */
  121087. radius: number;
  121088. /**
  121089. * The strenth of the explosion.
  121090. */
  121091. strength: number;
  121092. /**
  121093. * The strenght of the force in correspondence to the distance of the affected object
  121094. */
  121095. falloff: PhysicsRadialImpulseFalloff;
  121096. /**
  121097. * Sphere options for the radial explosion.
  121098. */
  121099. sphere: {
  121100. segments: number;
  121101. diameter: number;
  121102. };
  121103. /**
  121104. * Sphere options for the radial explosion.
  121105. */
  121106. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121107. }
  121108. /**
  121109. * Options fot the updraft event
  121110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121111. */
  121112. export class PhysicsUpdraftEventOptions {
  121113. /**
  121114. * The radius of the cylinder for the vortex
  121115. */
  121116. radius: number;
  121117. /**
  121118. * The strenth of the updraft.
  121119. */
  121120. strength: number;
  121121. /**
  121122. * The height of the cylinder for the updraft.
  121123. */
  121124. height: number;
  121125. /**
  121126. * The mode for the the updraft.
  121127. */
  121128. updraftMode: PhysicsUpdraftMode;
  121129. }
  121130. /**
  121131. * Options fot the vortex event
  121132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121133. */
  121134. export class PhysicsVortexEventOptions {
  121135. /**
  121136. * The radius of the cylinder for the vortex
  121137. */
  121138. radius: number;
  121139. /**
  121140. * The strenth of the vortex.
  121141. */
  121142. strength: number;
  121143. /**
  121144. * The height of the cylinder for the vortex.
  121145. */
  121146. height: number;
  121147. /**
  121148. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  121149. */
  121150. centripetalForceThreshold: number;
  121151. /**
  121152. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  121153. */
  121154. centripetalForceMultiplier: number;
  121155. /**
  121156. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  121157. */
  121158. centrifugalForceMultiplier: number;
  121159. /**
  121160. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  121161. */
  121162. updraftForceMultiplier: number;
  121163. }
  121164. /**
  121165. * The strenght of the force in correspondence to the distance of the affected object
  121166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121167. */
  121168. export enum PhysicsRadialImpulseFalloff {
  121169. /** Defines that impulse is constant in strength across it's whole radius */
  121170. Constant = 0,
  121171. /** Defines that impulse gets weaker if it's further from the origin */
  121172. Linear = 1
  121173. }
  121174. /**
  121175. * The strength of the force in correspondence to the distance of the affected object
  121176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121177. */
  121178. export enum PhysicsUpdraftMode {
  121179. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  121180. Center = 0,
  121181. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  121182. Perpendicular = 1
  121183. }
  121184. /**
  121185. * Interface for a physics hit data
  121186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121187. */
  121188. export interface PhysicsHitData {
  121189. /**
  121190. * The force applied at the contact point
  121191. */
  121192. force: Vector3;
  121193. /**
  121194. * The contact point
  121195. */
  121196. contactPoint: Vector3;
  121197. /**
  121198. * The distance from the origin to the contact point
  121199. */
  121200. distanceFromOrigin: number;
  121201. }
  121202. /**
  121203. * Interface for radial explosion event data
  121204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121205. */
  121206. export interface PhysicsRadialExplosionEventData {
  121207. /**
  121208. * A sphere used for the radial explosion event
  121209. */
  121210. sphere: Mesh;
  121211. }
  121212. /**
  121213. * Interface for gravitational field event data
  121214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121215. */
  121216. export interface PhysicsGravitationalFieldEventData {
  121217. /**
  121218. * A sphere mesh used for the gravitational field event
  121219. */
  121220. sphere: Mesh;
  121221. }
  121222. /**
  121223. * Interface for updraft event data
  121224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121225. */
  121226. export interface PhysicsUpdraftEventData {
  121227. /**
  121228. * A cylinder used for the updraft event
  121229. */
  121230. cylinder: Mesh;
  121231. }
  121232. /**
  121233. * Interface for vortex event data
  121234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121235. */
  121236. export interface PhysicsVortexEventData {
  121237. /**
  121238. * A cylinder used for the vortex event
  121239. */
  121240. cylinder: Mesh;
  121241. }
  121242. /**
  121243. * Interface for an affected physics impostor
  121244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121245. */
  121246. export interface PhysicsAffectedImpostorWithData {
  121247. /**
  121248. * The impostor affected by the effect
  121249. */
  121250. impostor: PhysicsImpostor;
  121251. /**
  121252. * The data about the hit/horce from the explosion
  121253. */
  121254. hitData: PhysicsHitData;
  121255. }
  121256. }
  121257. declare module BABYLON {
  121258. /** @hidden */
  121259. export var blackAndWhitePixelShader: {
  121260. name: string;
  121261. shader: string;
  121262. };
  121263. }
  121264. declare module BABYLON {
  121265. /**
  121266. * Post process used to render in black and white
  121267. */
  121268. export class BlackAndWhitePostProcess extends PostProcess {
  121269. /**
  121270. * Linear about to convert he result to black and white (default: 1)
  121271. */
  121272. degree: number;
  121273. /**
  121274. * Creates a black and white post process
  121275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  121276. * @param name The name of the effect.
  121277. * @param options The required width/height ratio to downsize to before computing the render pass.
  121278. * @param camera The camera to apply the render pass to.
  121279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121280. * @param engine The engine which the post process will be applied. (default: current engine)
  121281. * @param reusable If the post process can be reused on the same frame. (default: false)
  121282. */
  121283. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121284. }
  121285. }
  121286. declare module BABYLON {
  121287. /**
  121288. * This represents a set of one or more post processes in Babylon.
  121289. * A post process can be used to apply a shader to a texture after it is rendered.
  121290. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121291. */
  121292. export class PostProcessRenderEffect {
  121293. private _postProcesses;
  121294. private _getPostProcesses;
  121295. private _singleInstance;
  121296. private _cameras;
  121297. private _indicesForCamera;
  121298. /**
  121299. * Name of the effect
  121300. * @hidden
  121301. */
  121302. _name: string;
  121303. /**
  121304. * Instantiates a post process render effect.
  121305. * A post process can be used to apply a shader to a texture after it is rendered.
  121306. * @param engine The engine the effect is tied to
  121307. * @param name The name of the effect
  121308. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121309. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121310. */
  121311. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  121312. /**
  121313. * Checks if all the post processes in the effect are supported.
  121314. */
  121315. readonly isSupported: boolean;
  121316. /**
  121317. * Updates the current state of the effect
  121318. * @hidden
  121319. */
  121320. _update(): void;
  121321. /**
  121322. * Attaches the effect on cameras
  121323. * @param cameras The camera to attach to.
  121324. * @hidden
  121325. */
  121326. _attachCameras(cameras: Camera): void;
  121327. /**
  121328. * Attaches the effect on cameras
  121329. * @param cameras The camera to attach to.
  121330. * @hidden
  121331. */
  121332. _attachCameras(cameras: Camera[]): void;
  121333. /**
  121334. * Detaches the effect on cameras
  121335. * @param cameras The camera to detatch from.
  121336. * @hidden
  121337. */
  121338. _detachCameras(cameras: Camera): void;
  121339. /**
  121340. * Detatches the effect on cameras
  121341. * @param cameras The camera to detatch from.
  121342. * @hidden
  121343. */
  121344. _detachCameras(cameras: Camera[]): void;
  121345. /**
  121346. * Enables the effect on given cameras
  121347. * @param cameras The camera to enable.
  121348. * @hidden
  121349. */
  121350. _enable(cameras: Camera): void;
  121351. /**
  121352. * Enables the effect on given cameras
  121353. * @param cameras The camera to enable.
  121354. * @hidden
  121355. */
  121356. _enable(cameras: Nullable<Camera[]>): void;
  121357. /**
  121358. * Disables the effect on the given cameras
  121359. * @param cameras The camera to disable.
  121360. * @hidden
  121361. */
  121362. _disable(cameras: Camera): void;
  121363. /**
  121364. * Disables the effect on the given cameras
  121365. * @param cameras The camera to disable.
  121366. * @hidden
  121367. */
  121368. _disable(cameras: Nullable<Camera[]>): void;
  121369. /**
  121370. * Gets a list of the post processes contained in the effect.
  121371. * @param camera The camera to get the post processes on.
  121372. * @returns The list of the post processes in the effect.
  121373. */
  121374. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  121375. }
  121376. }
  121377. declare module BABYLON {
  121378. /** @hidden */
  121379. export var extractHighlightsPixelShader: {
  121380. name: string;
  121381. shader: string;
  121382. };
  121383. }
  121384. declare module BABYLON {
  121385. /**
  121386. * 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.
  121387. */
  121388. export class ExtractHighlightsPostProcess extends PostProcess {
  121389. /**
  121390. * The luminance threshold, pixels below this value will be set to black.
  121391. */
  121392. threshold: number;
  121393. /** @hidden */
  121394. _exposure: number;
  121395. /**
  121396. * Post process which has the input texture to be used when performing highlight extraction
  121397. * @hidden
  121398. */
  121399. _inputPostProcess: Nullable<PostProcess>;
  121400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121401. }
  121402. }
  121403. declare module BABYLON {
  121404. /** @hidden */
  121405. export var bloomMergePixelShader: {
  121406. name: string;
  121407. shader: string;
  121408. };
  121409. }
  121410. declare module BABYLON {
  121411. /**
  121412. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121413. */
  121414. export class BloomMergePostProcess extends PostProcess {
  121415. /** Weight of the bloom to be added to the original input. */
  121416. weight: number;
  121417. /**
  121418. * Creates a new instance of @see BloomMergePostProcess
  121419. * @param name The name of the effect.
  121420. * @param originalFromInput Post process which's input will be used for the merge.
  121421. * @param blurred Blurred highlights post process which's output will be used.
  121422. * @param weight Weight of the bloom to be added to the original input.
  121423. * @param options The required width/height ratio to downsize to before computing the render pass.
  121424. * @param camera The camera to apply the render pass to.
  121425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121426. * @param engine The engine which the post process will be applied. (default: current engine)
  121427. * @param reusable If the post process can be reused on the same frame. (default: false)
  121428. * @param textureType Type of textures used when performing the post process. (default: 0)
  121429. * @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)
  121430. */
  121431. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  121432. /** Weight of the bloom to be added to the original input. */
  121433. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121434. }
  121435. }
  121436. declare module BABYLON {
  121437. /**
  121438. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  121439. */
  121440. export class BloomEffect extends PostProcessRenderEffect {
  121441. private bloomScale;
  121442. /**
  121443. * @hidden Internal
  121444. */
  121445. _effects: Array<PostProcess>;
  121446. /**
  121447. * @hidden Internal
  121448. */
  121449. _downscale: ExtractHighlightsPostProcess;
  121450. private _blurX;
  121451. private _blurY;
  121452. private _merge;
  121453. /**
  121454. * The luminance threshold to find bright areas of the image to bloom.
  121455. */
  121456. threshold: number;
  121457. /**
  121458. * The strength of the bloom.
  121459. */
  121460. weight: number;
  121461. /**
  121462. * Specifies the size of the bloom blur kernel, relative to the final output size
  121463. */
  121464. kernel: number;
  121465. /**
  121466. * Creates a new instance of @see BloomEffect
  121467. * @param scene The scene the effect belongs to.
  121468. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  121469. * @param bloomKernel The size of the kernel to be used when applying the blur.
  121470. * @param bloomWeight The the strength of bloom.
  121471. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121472. * @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)
  121473. */
  121474. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  121475. /**
  121476. * Disposes each of the internal effects for a given camera.
  121477. * @param camera The camera to dispose the effect on.
  121478. */
  121479. disposeEffects(camera: Camera): void;
  121480. /**
  121481. * @hidden Internal
  121482. */
  121483. _updateEffects(): void;
  121484. /**
  121485. * Internal
  121486. * @returns if all the contained post processes are ready.
  121487. * @hidden
  121488. */
  121489. _isReady(): boolean;
  121490. }
  121491. }
  121492. declare module BABYLON {
  121493. /** @hidden */
  121494. export var chromaticAberrationPixelShader: {
  121495. name: string;
  121496. shader: string;
  121497. };
  121498. }
  121499. declare module BABYLON {
  121500. /**
  121501. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121502. */
  121503. export class ChromaticAberrationPostProcess extends PostProcess {
  121504. /**
  121505. * The amount of seperation of rgb channels (default: 30)
  121506. */
  121507. aberrationAmount: number;
  121508. /**
  121509. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121510. */
  121511. radialIntensity: number;
  121512. /**
  121513. * 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))
  121514. */
  121515. direction: Vector2;
  121516. /**
  121517. * 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))
  121518. */
  121519. centerPosition: Vector2;
  121520. /**
  121521. * Creates a new instance ChromaticAberrationPostProcess
  121522. * @param name The name of the effect.
  121523. * @param screenWidth The width of the screen to apply the effect on.
  121524. * @param screenHeight The height of the screen to apply the effect on.
  121525. * @param options The required width/height ratio to downsize to before computing the render pass.
  121526. * @param camera The camera to apply the render pass to.
  121527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121528. * @param engine The engine which the post process will be applied. (default: current engine)
  121529. * @param reusable If the post process can be reused on the same frame. (default: false)
  121530. * @param textureType Type of textures used when performing the post process. (default: 0)
  121531. * @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)
  121532. */
  121533. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121534. }
  121535. }
  121536. declare module BABYLON {
  121537. /** @hidden */
  121538. export var circleOfConfusionPixelShader: {
  121539. name: string;
  121540. shader: string;
  121541. };
  121542. }
  121543. declare module BABYLON {
  121544. /**
  121545. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121546. */
  121547. export class CircleOfConfusionPostProcess extends PostProcess {
  121548. /**
  121549. * 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.
  121550. */
  121551. lensSize: number;
  121552. /**
  121553. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121554. */
  121555. fStop: number;
  121556. /**
  121557. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121558. */
  121559. focusDistance: number;
  121560. /**
  121561. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121562. */
  121563. focalLength: number;
  121564. private _depthTexture;
  121565. /**
  121566. * Creates a new instance CircleOfConfusionPostProcess
  121567. * @param name The name of the effect.
  121568. * @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.
  121569. * @param options The required width/height ratio to downsize to before computing the render pass.
  121570. * @param camera The camera to apply the render pass to.
  121571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121572. * @param engine The engine which the post process will be applied. (default: current engine)
  121573. * @param reusable If the post process can be reused on the same frame. (default: false)
  121574. * @param textureType Type of textures used when performing the post process. (default: 0)
  121575. * @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)
  121576. */
  121577. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121578. /**
  121579. * 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.
  121580. */
  121581. depthTexture: RenderTargetTexture;
  121582. }
  121583. }
  121584. declare module BABYLON {
  121585. /** @hidden */
  121586. export var colorCorrectionPixelShader: {
  121587. name: string;
  121588. shader: string;
  121589. };
  121590. }
  121591. declare module BABYLON {
  121592. /**
  121593. *
  121594. * This post-process allows the modification of rendered colors by using
  121595. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121596. *
  121597. * The object needs to be provided an url to a texture containing the color
  121598. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121599. * Use an image editing software to tweak the LUT to match your needs.
  121600. *
  121601. * For an example of a color LUT, see here:
  121602. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121603. * For explanations on color grading, see here:
  121604. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121605. *
  121606. */
  121607. export class ColorCorrectionPostProcess extends PostProcess {
  121608. private _colorTableTexture;
  121609. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121610. }
  121611. }
  121612. declare module BABYLON {
  121613. /** @hidden */
  121614. export var convolutionPixelShader: {
  121615. name: string;
  121616. shader: string;
  121617. };
  121618. }
  121619. declare module BABYLON {
  121620. /**
  121621. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121622. * input texture to perform effects such as edge detection or sharpening
  121623. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121624. */
  121625. export class ConvolutionPostProcess extends PostProcess {
  121626. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121627. kernel: number[];
  121628. /**
  121629. * Creates a new instance ConvolutionPostProcess
  121630. * @param name The name of the effect.
  121631. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121632. * @param options The required width/height ratio to downsize to before computing the render pass.
  121633. * @param camera The camera to apply the render pass to.
  121634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121635. * @param engine The engine which the post process will be applied. (default: current engine)
  121636. * @param reusable If the post process can be reused on the same frame. (default: false)
  121637. * @param textureType Type of textures used when performing the post process. (default: 0)
  121638. */
  121639. constructor(name: string,
  121640. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121641. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121642. /**
  121643. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121644. */
  121645. static EdgeDetect0Kernel: number[];
  121646. /**
  121647. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121648. */
  121649. static EdgeDetect1Kernel: number[];
  121650. /**
  121651. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121652. */
  121653. static EdgeDetect2Kernel: number[];
  121654. /**
  121655. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121656. */
  121657. static SharpenKernel: number[];
  121658. /**
  121659. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121660. */
  121661. static EmbossKernel: number[];
  121662. /**
  121663. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121664. */
  121665. static GaussianKernel: number[];
  121666. }
  121667. }
  121668. declare module BABYLON {
  121669. /**
  121670. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121671. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121672. * based on samples that have a large difference in distance than the center pixel.
  121673. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121674. */
  121675. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121676. direction: Vector2;
  121677. /**
  121678. * Creates a new instance CircleOfConfusionPostProcess
  121679. * @param name The name of the effect.
  121680. * @param scene The scene the effect belongs to.
  121681. * @param direction The direction the blur should be applied.
  121682. * @param kernel The size of the kernel used to blur.
  121683. * @param options The required width/height ratio to downsize to before computing the render pass.
  121684. * @param camera The camera to apply the render pass to.
  121685. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121686. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121688. * @param engine The engine which the post process will be applied. (default: current engine)
  121689. * @param reusable If the post process can be reused on the same frame. (default: false)
  121690. * @param textureType Type of textures used when performing the post process. (default: 0)
  121691. * @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)
  121692. */
  121693. 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);
  121694. }
  121695. }
  121696. declare module BABYLON {
  121697. /** @hidden */
  121698. export var depthOfFieldMergePixelShader: {
  121699. name: string;
  121700. shader: string;
  121701. };
  121702. }
  121703. declare module BABYLON {
  121704. /**
  121705. * Options to be set when merging outputs from the default pipeline.
  121706. */
  121707. export class DepthOfFieldMergePostProcessOptions {
  121708. /**
  121709. * The original image to merge on top of
  121710. */
  121711. originalFromInput: PostProcess;
  121712. /**
  121713. * Parameters to perform the merge of the depth of field effect
  121714. */
  121715. depthOfField?: {
  121716. circleOfConfusion: PostProcess;
  121717. blurSteps: Array<PostProcess>;
  121718. };
  121719. /**
  121720. * Parameters to perform the merge of bloom effect
  121721. */
  121722. bloom?: {
  121723. blurred: PostProcess;
  121724. weight: number;
  121725. };
  121726. }
  121727. /**
  121728. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121729. */
  121730. export class DepthOfFieldMergePostProcess extends PostProcess {
  121731. private blurSteps;
  121732. /**
  121733. * Creates a new instance of DepthOfFieldMergePostProcess
  121734. * @param name The name of the effect.
  121735. * @param originalFromInput Post process which's input will be used for the merge.
  121736. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121737. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121738. * @param options The required width/height ratio to downsize to before computing the render pass.
  121739. * @param camera The camera to apply the render pass to.
  121740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121741. * @param engine The engine which the post process will be applied. (default: current engine)
  121742. * @param reusable If the post process can be reused on the same frame. (default: false)
  121743. * @param textureType Type of textures used when performing the post process. (default: 0)
  121744. * @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)
  121745. */
  121746. 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);
  121747. /**
  121748. * Updates the effect with the current post process compile time values and recompiles the shader.
  121749. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121750. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121751. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121752. * @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
  121753. * @param onCompiled Called when the shader has been compiled.
  121754. * @param onError Called if there is an error when compiling a shader.
  121755. */
  121756. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  121757. }
  121758. }
  121759. declare module BABYLON {
  121760. /**
  121761. * Specifies the level of max blur that should be applied when using the depth of field effect
  121762. */
  121763. export enum DepthOfFieldEffectBlurLevel {
  121764. /**
  121765. * Subtle blur
  121766. */
  121767. Low = 0,
  121768. /**
  121769. * Medium blur
  121770. */
  121771. Medium = 1,
  121772. /**
  121773. * Large blur
  121774. */
  121775. High = 2
  121776. }
  121777. /**
  121778. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121779. */
  121780. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  121781. private _circleOfConfusion;
  121782. /**
  121783. * @hidden Internal, blurs from high to low
  121784. */
  121785. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  121786. private _depthOfFieldBlurY;
  121787. private _dofMerge;
  121788. /**
  121789. * @hidden Internal post processes in depth of field effect
  121790. */
  121791. _effects: Array<PostProcess>;
  121792. /**
  121793. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121794. */
  121795. focalLength: number;
  121796. /**
  121797. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121798. */
  121799. fStop: number;
  121800. /**
  121801. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121802. */
  121803. focusDistance: number;
  121804. /**
  121805. * 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.
  121806. */
  121807. lensSize: number;
  121808. /**
  121809. * Creates a new instance DepthOfFieldEffect
  121810. * @param scene The scene the effect belongs to.
  121811. * @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.
  121812. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121813. * @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)
  121814. */
  121815. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  121816. /**
  121817. * Get the current class name of the current effet
  121818. * @returns "DepthOfFieldEffect"
  121819. */
  121820. getClassName(): string;
  121821. /**
  121822. * 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.
  121823. */
  121824. depthTexture: RenderTargetTexture;
  121825. /**
  121826. * Disposes each of the internal effects for a given camera.
  121827. * @param camera The camera to dispose the effect on.
  121828. */
  121829. disposeEffects(camera: Camera): void;
  121830. /**
  121831. * @hidden Internal
  121832. */
  121833. _updateEffects(): void;
  121834. /**
  121835. * Internal
  121836. * @returns if all the contained post processes are ready.
  121837. * @hidden
  121838. */
  121839. _isReady(): boolean;
  121840. }
  121841. }
  121842. declare module BABYLON {
  121843. /** @hidden */
  121844. export var displayPassPixelShader: {
  121845. name: string;
  121846. shader: string;
  121847. };
  121848. }
  121849. declare module BABYLON {
  121850. /**
  121851. * DisplayPassPostProcess which produces an output the same as it's input
  121852. */
  121853. export class DisplayPassPostProcess extends PostProcess {
  121854. /**
  121855. * Creates the DisplayPassPostProcess
  121856. * @param name The name of the effect.
  121857. * @param options The required width/height ratio to downsize to before computing the render pass.
  121858. * @param camera The camera to apply the render pass to.
  121859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121860. * @param engine The engine which the post process will be applied. (default: current engine)
  121861. * @param reusable If the post process can be reused on the same frame. (default: false)
  121862. */
  121863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121864. }
  121865. }
  121866. declare module BABYLON {
  121867. /** @hidden */
  121868. export var filterPixelShader: {
  121869. name: string;
  121870. shader: string;
  121871. };
  121872. }
  121873. declare module BABYLON {
  121874. /**
  121875. * Applies a kernel filter to the image
  121876. */
  121877. export class FilterPostProcess extends PostProcess {
  121878. /** The matrix to be applied to the image */
  121879. kernelMatrix: Matrix;
  121880. /**
  121881. *
  121882. * @param name The name of the effect.
  121883. * @param kernelMatrix The matrix to be applied to the image
  121884. * @param options The required width/height ratio to downsize to before computing the render pass.
  121885. * @param camera The camera to apply the render pass to.
  121886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121887. * @param engine The engine which the post process will be applied. (default: current engine)
  121888. * @param reusable If the post process can be reused on the same frame. (default: false)
  121889. */
  121890. constructor(name: string,
  121891. /** The matrix to be applied to the image */
  121892. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121893. }
  121894. }
  121895. declare module BABYLON {
  121896. /** @hidden */
  121897. export var fxaaPixelShader: {
  121898. name: string;
  121899. shader: string;
  121900. };
  121901. }
  121902. declare module BABYLON {
  121903. /** @hidden */
  121904. export var fxaaVertexShader: {
  121905. name: string;
  121906. shader: string;
  121907. };
  121908. }
  121909. declare module BABYLON {
  121910. /**
  121911. * Fxaa post process
  121912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121913. */
  121914. export class FxaaPostProcess extends PostProcess {
  121915. /** @hidden */
  121916. texelWidth: number;
  121917. /** @hidden */
  121918. texelHeight: number;
  121919. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121920. private _getDefines;
  121921. }
  121922. }
  121923. declare module BABYLON {
  121924. /** @hidden */
  121925. export var grainPixelShader: {
  121926. name: string;
  121927. shader: string;
  121928. };
  121929. }
  121930. declare module BABYLON {
  121931. /**
  121932. * The GrainPostProcess adds noise to the image at mid luminance levels
  121933. */
  121934. export class GrainPostProcess extends PostProcess {
  121935. /**
  121936. * The intensity of the grain added (default: 30)
  121937. */
  121938. intensity: number;
  121939. /**
  121940. * If the grain should be randomized on every frame
  121941. */
  121942. animated: boolean;
  121943. /**
  121944. * Creates a new instance of @see GrainPostProcess
  121945. * @param name The name of the effect.
  121946. * @param options The required width/height ratio to downsize to before computing the render pass.
  121947. * @param camera The camera to apply the render pass to.
  121948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121949. * @param engine The engine which the post process will be applied. (default: current engine)
  121950. * @param reusable If the post process can be reused on the same frame. (default: false)
  121951. * @param textureType Type of textures used when performing the post process. (default: 0)
  121952. * @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)
  121953. */
  121954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121955. }
  121956. }
  121957. declare module BABYLON {
  121958. /** @hidden */
  121959. export var highlightsPixelShader: {
  121960. name: string;
  121961. shader: string;
  121962. };
  121963. }
  121964. declare module BABYLON {
  121965. /**
  121966. * Extracts highlights from the image
  121967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121968. */
  121969. export class HighlightsPostProcess extends PostProcess {
  121970. /**
  121971. * Extracts highlights from the image
  121972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121973. * @param name The name of the effect.
  121974. * @param options The required width/height ratio to downsize to before computing the render pass.
  121975. * @param camera The camera to apply the render pass to.
  121976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121977. * @param engine The engine which the post process will be applied. (default: current engine)
  121978. * @param reusable If the post process can be reused on the same frame. (default: false)
  121979. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121980. */
  121981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121982. }
  121983. }
  121984. declare module BABYLON {
  121985. /** @hidden */
  121986. export var mrtFragmentDeclaration: {
  121987. name: string;
  121988. shader: string;
  121989. };
  121990. }
  121991. declare module BABYLON {
  121992. /** @hidden */
  121993. export var geometryPixelShader: {
  121994. name: string;
  121995. shader: string;
  121996. };
  121997. }
  121998. declare module BABYLON {
  121999. /** @hidden */
  122000. export var geometryVertexShader: {
  122001. name: string;
  122002. shader: string;
  122003. };
  122004. }
  122005. declare module BABYLON {
  122006. /** @hidden */
  122007. interface ISavedTransformationMatrix {
  122008. world: Matrix;
  122009. viewProjection: Matrix;
  122010. }
  122011. /**
  122012. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122013. */
  122014. export class GeometryBufferRenderer {
  122015. /**
  122016. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122017. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122018. */
  122019. static readonly POSITION_TEXTURE_TYPE: number;
  122020. /**
  122021. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122022. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122023. */
  122024. static readonly VELOCITY_TEXTURE_TYPE: number;
  122025. /**
  122026. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122027. * in order to compute objects velocities when enableVelocity is set to "true"
  122028. * @hidden
  122029. */
  122030. _previousTransformationMatrices: {
  122031. [index: number]: ISavedTransformationMatrix;
  122032. };
  122033. /**
  122034. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122035. * in order to compute objects velocities when enableVelocity is set to "true"
  122036. * @hidden
  122037. */
  122038. _previousBonesTransformationMatrices: {
  122039. [index: number]: Float32Array;
  122040. };
  122041. /**
  122042. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122043. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122044. */
  122045. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122046. private _scene;
  122047. private _multiRenderTarget;
  122048. private _ratio;
  122049. private _enablePosition;
  122050. private _enableVelocity;
  122051. private _positionIndex;
  122052. private _velocityIndex;
  122053. protected _effect: Effect;
  122054. protected _cachedDefines: string;
  122055. /**
  122056. * Set the render list (meshes to be rendered) used in the G buffer.
  122057. */
  122058. renderList: Mesh[];
  122059. /**
  122060. * Gets wether or not G buffer are supported by the running hardware.
  122061. * This requires draw buffer supports
  122062. */
  122063. readonly isSupported: boolean;
  122064. /**
  122065. * Returns the index of the given texture type in the G-Buffer textures array
  122066. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122067. * @returns the index of the given texture type in the G-Buffer textures array
  122068. */
  122069. getTextureIndex(textureType: number): number;
  122070. /**
  122071. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122072. */
  122073. /**
  122074. * Sets whether or not objects positions are enabled for the G buffer.
  122075. */
  122076. enablePosition: boolean;
  122077. /**
  122078. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122079. */
  122080. /**
  122081. * Sets wether or not objects velocities are enabled for the G buffer.
  122082. */
  122083. enableVelocity: boolean;
  122084. /**
  122085. * Gets the scene associated with the buffer.
  122086. */
  122087. readonly scene: Scene;
  122088. /**
  122089. * Gets the ratio used by the buffer during its creation.
  122090. * How big is the buffer related to the main canvas.
  122091. */
  122092. readonly ratio: number;
  122093. /** @hidden */
  122094. static _SceneComponentInitialization: (scene: Scene) => void;
  122095. /**
  122096. * Creates a new G Buffer for the scene
  122097. * @param scene The scene the buffer belongs to
  122098. * @param ratio How big is the buffer related to the main canvas.
  122099. */
  122100. constructor(scene: Scene, ratio?: number);
  122101. /**
  122102. * Checks wether everything is ready to render a submesh to the G buffer.
  122103. * @param subMesh the submesh to check readiness for
  122104. * @param useInstances is the mesh drawn using instance or not
  122105. * @returns true if ready otherwise false
  122106. */
  122107. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122108. /**
  122109. * Gets the current underlying G Buffer.
  122110. * @returns the buffer
  122111. */
  122112. getGBuffer(): MultiRenderTarget;
  122113. /**
  122114. * Gets the number of samples used to render the buffer (anti aliasing).
  122115. */
  122116. /**
  122117. * Sets the number of samples used to render the buffer (anti aliasing).
  122118. */
  122119. samples: number;
  122120. /**
  122121. * Disposes the renderer and frees up associated resources.
  122122. */
  122123. dispose(): void;
  122124. protected _createRenderTargets(): void;
  122125. private _copyBonesTransformationMatrices;
  122126. }
  122127. }
  122128. declare module BABYLON {
  122129. interface Scene {
  122130. /** @hidden (Backing field) */
  122131. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122132. /**
  122133. * Gets or Sets the current geometry buffer associated to the scene.
  122134. */
  122135. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122136. /**
  122137. * Enables a GeometryBufferRender and associates it with the scene
  122138. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  122139. * @returns the GeometryBufferRenderer
  122140. */
  122141. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  122142. /**
  122143. * Disables the GeometryBufferRender associated with the scene
  122144. */
  122145. disableGeometryBufferRenderer(): void;
  122146. }
  122147. /**
  122148. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122149. * in several rendering techniques.
  122150. */
  122151. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  122152. /**
  122153. * The component name helpful to identify the component in the list of scene components.
  122154. */
  122155. readonly name: string;
  122156. /**
  122157. * The scene the component belongs to.
  122158. */
  122159. scene: Scene;
  122160. /**
  122161. * Creates a new instance of the component for the given scene
  122162. * @param scene Defines the scene to register the component in
  122163. */
  122164. constructor(scene: Scene);
  122165. /**
  122166. * Registers the component in a given scene
  122167. */
  122168. register(): void;
  122169. /**
  122170. * Rebuilds the elements related to this component in case of
  122171. * context lost for instance.
  122172. */
  122173. rebuild(): void;
  122174. /**
  122175. * Disposes the component and the associated ressources
  122176. */
  122177. dispose(): void;
  122178. private _gatherRenderTargets;
  122179. }
  122180. }
  122181. declare module BABYLON {
  122182. /** @hidden */
  122183. export var motionBlurPixelShader: {
  122184. name: string;
  122185. shader: string;
  122186. };
  122187. }
  122188. declare module BABYLON {
  122189. /**
  122190. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122191. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122192. * As an example, all you have to do is to create the post-process:
  122193. * var mb = new BABYLON.MotionBlurPostProcess(
  122194. * 'mb', // The name of the effect.
  122195. * scene, // The scene containing the objects to blur according to their velocity.
  122196. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122197. * camera // The camera to apply the render pass to.
  122198. * );
  122199. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122200. */
  122201. export class MotionBlurPostProcess extends PostProcess {
  122202. /**
  122203. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122204. */
  122205. motionStrength: number;
  122206. /**
  122207. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122208. */
  122209. /**
  122210. * Sets the number of iterations to be used for motion blur quality
  122211. */
  122212. motionBlurSamples: number;
  122213. private _motionBlurSamples;
  122214. private _geometryBufferRenderer;
  122215. /**
  122216. * Creates a new instance MotionBlurPostProcess
  122217. * @param name The name of the effect.
  122218. * @param scene The scene containing the objects to blur according to their velocity.
  122219. * @param options The required width/height ratio to downsize to before computing the render pass.
  122220. * @param camera The camera to apply the render pass to.
  122221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122222. * @param engine The engine which the post process will be applied. (default: current engine)
  122223. * @param reusable If the post process can be reused on the same frame. (default: false)
  122224. * @param textureType Type of textures used when performing the post process. (default: 0)
  122225. * @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)
  122226. */
  122227. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122228. /**
  122229. * Excludes the given skinned mesh from computing bones velocities.
  122230. * 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.
  122231. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  122232. */
  122233. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122234. /**
  122235. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  122236. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  122237. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  122238. */
  122239. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122240. /**
  122241. * Disposes the post process.
  122242. * @param camera The camera to dispose the post process on.
  122243. */
  122244. dispose(camera?: Camera): void;
  122245. }
  122246. }
  122247. declare module BABYLON {
  122248. /** @hidden */
  122249. export var refractionPixelShader: {
  122250. name: string;
  122251. shader: string;
  122252. };
  122253. }
  122254. declare module BABYLON {
  122255. /**
  122256. * Post process which applies a refractin texture
  122257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122258. */
  122259. export class RefractionPostProcess extends PostProcess {
  122260. /** the base color of the refraction (used to taint the rendering) */
  122261. color: Color3;
  122262. /** simulated refraction depth */
  122263. depth: number;
  122264. /** the coefficient of the base color (0 to remove base color tainting) */
  122265. colorLevel: number;
  122266. private _refTexture;
  122267. private _ownRefractionTexture;
  122268. /**
  122269. * Gets or sets the refraction texture
  122270. * Please note that you are responsible for disposing the texture if you set it manually
  122271. */
  122272. refractionTexture: Texture;
  122273. /**
  122274. * Initializes the RefractionPostProcess
  122275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122276. * @param name The name of the effect.
  122277. * @param refractionTextureUrl Url of the refraction texture to use
  122278. * @param color the base color of the refraction (used to taint the rendering)
  122279. * @param depth simulated refraction depth
  122280. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  122281. * @param camera The camera to apply the render pass to.
  122282. * @param options The required width/height ratio to downsize to before computing the render pass.
  122283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122284. * @param engine The engine which the post process will be applied. (default: current engine)
  122285. * @param reusable If the post process can be reused on the same frame. (default: false)
  122286. */
  122287. constructor(name: string, refractionTextureUrl: string,
  122288. /** the base color of the refraction (used to taint the rendering) */
  122289. color: Color3,
  122290. /** simulated refraction depth */
  122291. depth: number,
  122292. /** the coefficient of the base color (0 to remove base color tainting) */
  122293. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122294. /**
  122295. * Disposes of the post process
  122296. * @param camera Camera to dispose post process on
  122297. */
  122298. dispose(camera: Camera): void;
  122299. }
  122300. }
  122301. declare module BABYLON {
  122302. /** @hidden */
  122303. export var sharpenPixelShader: {
  122304. name: string;
  122305. shader: string;
  122306. };
  122307. }
  122308. declare module BABYLON {
  122309. /**
  122310. * The SharpenPostProcess applies a sharpen kernel to every pixel
  122311. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122312. */
  122313. export class SharpenPostProcess extends PostProcess {
  122314. /**
  122315. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  122316. */
  122317. colorAmount: number;
  122318. /**
  122319. * How much sharpness should be applied (default: 0.3)
  122320. */
  122321. edgeAmount: number;
  122322. /**
  122323. * Creates a new instance ConvolutionPostProcess
  122324. * @param name The name of the effect.
  122325. * @param options The required width/height ratio to downsize to before computing the render pass.
  122326. * @param camera The camera to apply the render pass to.
  122327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122328. * @param engine The engine which the post process will be applied. (default: current engine)
  122329. * @param reusable If the post process can be reused on the same frame. (default: false)
  122330. * @param textureType Type of textures used when performing the post process. (default: 0)
  122331. * @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)
  122332. */
  122333. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122334. }
  122335. }
  122336. declare module BABYLON {
  122337. /**
  122338. * PostProcessRenderPipeline
  122339. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122340. */
  122341. export class PostProcessRenderPipeline {
  122342. private engine;
  122343. private _renderEffects;
  122344. private _renderEffectsForIsolatedPass;
  122345. /**
  122346. * List of inspectable custom properties (used by the Inspector)
  122347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122348. */
  122349. inspectableCustomProperties: IInspectable[];
  122350. /**
  122351. * @hidden
  122352. */
  122353. protected _cameras: Camera[];
  122354. /** @hidden */
  122355. _name: string;
  122356. /**
  122357. * Gets pipeline name
  122358. */
  122359. readonly name: string;
  122360. /**
  122361. * Initializes a PostProcessRenderPipeline
  122362. * @param engine engine to add the pipeline to
  122363. * @param name name of the pipeline
  122364. */
  122365. constructor(engine: Engine, name: string);
  122366. /**
  122367. * Gets the class name
  122368. * @returns "PostProcessRenderPipeline"
  122369. */
  122370. getClassName(): string;
  122371. /**
  122372. * If all the render effects in the pipeline are supported
  122373. */
  122374. readonly isSupported: boolean;
  122375. /**
  122376. * Adds an effect to the pipeline
  122377. * @param renderEffect the effect to add
  122378. */
  122379. addEffect(renderEffect: PostProcessRenderEffect): void;
  122380. /** @hidden */
  122381. _rebuild(): void;
  122382. /** @hidden */
  122383. _enableEffect(renderEffectName: string, cameras: Camera): void;
  122384. /** @hidden */
  122385. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  122386. /** @hidden */
  122387. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122388. /** @hidden */
  122389. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122390. /** @hidden */
  122391. _attachCameras(cameras: Camera, unique: boolean): void;
  122392. /** @hidden */
  122393. _attachCameras(cameras: Camera[], unique: boolean): void;
  122394. /** @hidden */
  122395. _detachCameras(cameras: Camera): void;
  122396. /** @hidden */
  122397. _detachCameras(cameras: Nullable<Camera[]>): void;
  122398. /** @hidden */
  122399. _update(): void;
  122400. /** @hidden */
  122401. _reset(): void;
  122402. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  122403. /**
  122404. * Disposes of the pipeline
  122405. */
  122406. dispose(): void;
  122407. }
  122408. }
  122409. declare module BABYLON {
  122410. /**
  122411. * PostProcessRenderPipelineManager class
  122412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122413. */
  122414. export class PostProcessRenderPipelineManager {
  122415. private _renderPipelines;
  122416. /**
  122417. * Initializes a PostProcessRenderPipelineManager
  122418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122419. */
  122420. constructor();
  122421. /**
  122422. * Gets the list of supported render pipelines
  122423. */
  122424. readonly supportedPipelines: PostProcessRenderPipeline[];
  122425. /**
  122426. * Adds a pipeline to the manager
  122427. * @param renderPipeline The pipeline to add
  122428. */
  122429. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  122430. /**
  122431. * Attaches a camera to the pipeline
  122432. * @param renderPipelineName The name of the pipeline to attach to
  122433. * @param cameras the camera to attach
  122434. * @param unique if the camera can be attached multiple times to the pipeline
  122435. */
  122436. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  122437. /**
  122438. * Detaches a camera from the pipeline
  122439. * @param renderPipelineName The name of the pipeline to detach from
  122440. * @param cameras the camera to detach
  122441. */
  122442. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  122443. /**
  122444. * Enables an effect by name on a pipeline
  122445. * @param renderPipelineName the name of the pipeline to enable the effect in
  122446. * @param renderEffectName the name of the effect to enable
  122447. * @param cameras the cameras that the effect should be enabled on
  122448. */
  122449. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122450. /**
  122451. * Disables an effect by name on a pipeline
  122452. * @param renderPipelineName the name of the pipeline to disable the effect in
  122453. * @param renderEffectName the name of the effect to disable
  122454. * @param cameras the cameras that the effect should be disabled on
  122455. */
  122456. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122457. /**
  122458. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122459. */
  122460. update(): void;
  122461. /** @hidden */
  122462. _rebuild(): void;
  122463. /**
  122464. * Disposes of the manager and pipelines
  122465. */
  122466. dispose(): void;
  122467. }
  122468. }
  122469. declare module BABYLON {
  122470. interface Scene {
  122471. /** @hidden (Backing field) */
  122472. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122473. /**
  122474. * Gets the postprocess render pipeline manager
  122475. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122476. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122477. */
  122478. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122479. }
  122480. /**
  122481. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122482. */
  122483. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  122484. /**
  122485. * The component name helpfull to identify the component in the list of scene components.
  122486. */
  122487. readonly name: string;
  122488. /**
  122489. * The scene the component belongs to.
  122490. */
  122491. scene: Scene;
  122492. /**
  122493. * Creates a new instance of the component for the given scene
  122494. * @param scene Defines the scene to register the component in
  122495. */
  122496. constructor(scene: Scene);
  122497. /**
  122498. * Registers the component in a given scene
  122499. */
  122500. register(): void;
  122501. /**
  122502. * Rebuilds the elements related to this component in case of
  122503. * context lost for instance.
  122504. */
  122505. rebuild(): void;
  122506. /**
  122507. * Disposes the component and the associated ressources
  122508. */
  122509. dispose(): void;
  122510. private _gatherRenderTargets;
  122511. }
  122512. }
  122513. declare module BABYLON {
  122514. /**
  122515. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  122516. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122517. */
  122518. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122519. private _scene;
  122520. private _camerasToBeAttached;
  122521. /**
  122522. * ID of the sharpen post process,
  122523. */
  122524. private readonly SharpenPostProcessId;
  122525. /**
  122526. * @ignore
  122527. * ID of the image processing post process;
  122528. */
  122529. readonly ImageProcessingPostProcessId: string;
  122530. /**
  122531. * @ignore
  122532. * ID of the Fast Approximate Anti-Aliasing post process;
  122533. */
  122534. readonly FxaaPostProcessId: string;
  122535. /**
  122536. * ID of the chromatic aberration post process,
  122537. */
  122538. private readonly ChromaticAberrationPostProcessId;
  122539. /**
  122540. * ID of the grain post process
  122541. */
  122542. private readonly GrainPostProcessId;
  122543. /**
  122544. * Sharpen post process which will apply a sharpen convolution to enhance edges
  122545. */
  122546. sharpen: SharpenPostProcess;
  122547. private _sharpenEffect;
  122548. private bloom;
  122549. /**
  122550. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  122551. */
  122552. depthOfField: DepthOfFieldEffect;
  122553. /**
  122554. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122555. */
  122556. fxaa: FxaaPostProcess;
  122557. /**
  122558. * Image post processing pass used to perform operations such as tone mapping or color grading.
  122559. */
  122560. imageProcessing: ImageProcessingPostProcess;
  122561. /**
  122562. * Chromatic aberration post process which will shift rgb colors in the image
  122563. */
  122564. chromaticAberration: ChromaticAberrationPostProcess;
  122565. private _chromaticAberrationEffect;
  122566. /**
  122567. * Grain post process which add noise to the image
  122568. */
  122569. grain: GrainPostProcess;
  122570. private _grainEffect;
  122571. /**
  122572. * Glow post process which adds a glow to emissive areas of the image
  122573. */
  122574. private _glowLayer;
  122575. /**
  122576. * Animations which can be used to tweak settings over a period of time
  122577. */
  122578. animations: Animation[];
  122579. private _imageProcessingConfigurationObserver;
  122580. private _sharpenEnabled;
  122581. private _bloomEnabled;
  122582. private _depthOfFieldEnabled;
  122583. private _depthOfFieldBlurLevel;
  122584. private _fxaaEnabled;
  122585. private _imageProcessingEnabled;
  122586. private _defaultPipelineTextureType;
  122587. private _bloomScale;
  122588. private _chromaticAberrationEnabled;
  122589. private _grainEnabled;
  122590. private _buildAllowed;
  122591. /**
  122592. * Gets active scene
  122593. */
  122594. readonly scene: Scene;
  122595. /**
  122596. * Enable or disable the sharpen process from the pipeline
  122597. */
  122598. sharpenEnabled: boolean;
  122599. private _resizeObserver;
  122600. private _hardwareScaleLevel;
  122601. private _bloomKernel;
  122602. /**
  122603. * Specifies the size of the bloom blur kernel, relative to the final output size
  122604. */
  122605. bloomKernel: number;
  122606. /**
  122607. * Specifies the weight of the bloom in the final rendering
  122608. */
  122609. private _bloomWeight;
  122610. /**
  122611. * Specifies the luma threshold for the area that will be blurred by the bloom
  122612. */
  122613. private _bloomThreshold;
  122614. private _hdr;
  122615. /**
  122616. * The strength of the bloom.
  122617. */
  122618. bloomWeight: number;
  122619. /**
  122620. * The strength of the bloom.
  122621. */
  122622. bloomThreshold: number;
  122623. /**
  122624. * The scale of the bloom, lower value will provide better performance.
  122625. */
  122626. bloomScale: number;
  122627. /**
  122628. * Enable or disable the bloom from the pipeline
  122629. */
  122630. bloomEnabled: boolean;
  122631. private _rebuildBloom;
  122632. /**
  122633. * If the depth of field is enabled.
  122634. */
  122635. depthOfFieldEnabled: boolean;
  122636. /**
  122637. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122638. */
  122639. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122640. /**
  122641. * If the anti aliasing is enabled.
  122642. */
  122643. fxaaEnabled: boolean;
  122644. private _samples;
  122645. /**
  122646. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122647. */
  122648. samples: number;
  122649. /**
  122650. * If image processing is enabled.
  122651. */
  122652. imageProcessingEnabled: boolean;
  122653. /**
  122654. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122655. */
  122656. glowLayerEnabled: boolean;
  122657. /**
  122658. * Gets the glow layer (or null if not defined)
  122659. */
  122660. readonly glowLayer: Nullable<GlowLayer>;
  122661. /**
  122662. * Enable or disable the chromaticAberration process from the pipeline
  122663. */
  122664. chromaticAberrationEnabled: boolean;
  122665. /**
  122666. * Enable or disable the grain process from the pipeline
  122667. */
  122668. grainEnabled: boolean;
  122669. /**
  122670. * @constructor
  122671. * @param name - The rendering pipeline name (default: "")
  122672. * @param hdr - If high dynamic range textures should be used (default: true)
  122673. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122674. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122675. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122676. */
  122677. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122678. /**
  122679. * Get the class name
  122680. * @returns "DefaultRenderingPipeline"
  122681. */
  122682. getClassName(): string;
  122683. /**
  122684. * Force the compilation of the entire pipeline.
  122685. */
  122686. prepare(): void;
  122687. private _hasCleared;
  122688. private _prevPostProcess;
  122689. private _prevPrevPostProcess;
  122690. private _setAutoClearAndTextureSharing;
  122691. private _depthOfFieldSceneObserver;
  122692. private _buildPipeline;
  122693. private _disposePostProcesses;
  122694. /**
  122695. * Adds a camera to the pipeline
  122696. * @param camera the camera to be added
  122697. */
  122698. addCamera(camera: Camera): void;
  122699. /**
  122700. * Removes a camera from the pipeline
  122701. * @param camera the camera to remove
  122702. */
  122703. removeCamera(camera: Camera): void;
  122704. /**
  122705. * Dispose of the pipeline and stop all post processes
  122706. */
  122707. dispose(): void;
  122708. /**
  122709. * Serialize the rendering pipeline (Used when exporting)
  122710. * @returns the serialized object
  122711. */
  122712. serialize(): any;
  122713. /**
  122714. * Parse the serialized pipeline
  122715. * @param source Source pipeline.
  122716. * @param scene The scene to load the pipeline to.
  122717. * @param rootUrl The URL of the serialized pipeline.
  122718. * @returns An instantiated pipeline from the serialized object.
  122719. */
  122720. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122721. }
  122722. }
  122723. declare module BABYLON {
  122724. /** @hidden */
  122725. export var lensHighlightsPixelShader: {
  122726. name: string;
  122727. shader: string;
  122728. };
  122729. }
  122730. declare module BABYLON {
  122731. /** @hidden */
  122732. export var depthOfFieldPixelShader: {
  122733. name: string;
  122734. shader: string;
  122735. };
  122736. }
  122737. declare module BABYLON {
  122738. /**
  122739. * BABYLON.JS Chromatic Aberration GLSL Shader
  122740. * Author: Olivier Guyot
  122741. * Separates very slightly R, G and B colors on the edges of the screen
  122742. * Inspired by Francois Tarlier & Martins Upitis
  122743. */
  122744. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  122745. /**
  122746. * @ignore
  122747. * The chromatic aberration PostProcess id in the pipeline
  122748. */
  122749. LensChromaticAberrationEffect: string;
  122750. /**
  122751. * @ignore
  122752. * The highlights enhancing PostProcess id in the pipeline
  122753. */
  122754. HighlightsEnhancingEffect: string;
  122755. /**
  122756. * @ignore
  122757. * The depth-of-field PostProcess id in the pipeline
  122758. */
  122759. LensDepthOfFieldEffect: string;
  122760. private _scene;
  122761. private _depthTexture;
  122762. private _grainTexture;
  122763. private _chromaticAberrationPostProcess;
  122764. private _highlightsPostProcess;
  122765. private _depthOfFieldPostProcess;
  122766. private _edgeBlur;
  122767. private _grainAmount;
  122768. private _chromaticAberration;
  122769. private _distortion;
  122770. private _highlightsGain;
  122771. private _highlightsThreshold;
  122772. private _dofDistance;
  122773. private _dofAperture;
  122774. private _dofDarken;
  122775. private _dofPentagon;
  122776. private _blurNoise;
  122777. /**
  122778. * @constructor
  122779. *
  122780. * Effect parameters are as follow:
  122781. * {
  122782. * chromatic_aberration: number; // from 0 to x (1 for realism)
  122783. * edge_blur: number; // from 0 to x (1 for realism)
  122784. * distortion: number; // from 0 to x (1 for realism)
  122785. * grain_amount: number; // from 0 to 1
  122786. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  122787. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  122788. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  122789. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  122790. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  122791. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  122792. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  122793. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  122794. * }
  122795. * Note: if an effect parameter is unset, effect is disabled
  122796. *
  122797. * @param name The rendering pipeline name
  122798. * @param parameters - An object containing all parameters (see above)
  122799. * @param scene The scene linked to this pipeline
  122800. * @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)
  122801. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122802. */
  122803. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  122804. /**
  122805. * Get the class name
  122806. * @returns "LensRenderingPipeline"
  122807. */
  122808. getClassName(): string;
  122809. /**
  122810. * Gets associated scene
  122811. */
  122812. readonly scene: Scene;
  122813. /**
  122814. * Gets or sets the edge blur
  122815. */
  122816. edgeBlur: number;
  122817. /**
  122818. * Gets or sets the grain amount
  122819. */
  122820. grainAmount: number;
  122821. /**
  122822. * Gets or sets the chromatic aberration amount
  122823. */
  122824. chromaticAberration: number;
  122825. /**
  122826. * Gets or sets the depth of field aperture
  122827. */
  122828. dofAperture: number;
  122829. /**
  122830. * Gets or sets the edge distortion
  122831. */
  122832. edgeDistortion: number;
  122833. /**
  122834. * Gets or sets the depth of field distortion
  122835. */
  122836. dofDistortion: number;
  122837. /**
  122838. * Gets or sets the darken out of focus amount
  122839. */
  122840. darkenOutOfFocus: number;
  122841. /**
  122842. * Gets or sets a boolean indicating if blur noise is enabled
  122843. */
  122844. blurNoise: boolean;
  122845. /**
  122846. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  122847. */
  122848. pentagonBokeh: boolean;
  122849. /**
  122850. * Gets or sets the highlight grain amount
  122851. */
  122852. highlightsGain: number;
  122853. /**
  122854. * Gets or sets the highlight threshold
  122855. */
  122856. highlightsThreshold: number;
  122857. /**
  122858. * Sets the amount of blur at the edges
  122859. * @param amount blur amount
  122860. */
  122861. setEdgeBlur(amount: number): void;
  122862. /**
  122863. * Sets edge blur to 0
  122864. */
  122865. disableEdgeBlur(): void;
  122866. /**
  122867. * Sets the amout of grain
  122868. * @param amount Amount of grain
  122869. */
  122870. setGrainAmount(amount: number): void;
  122871. /**
  122872. * Set grain amount to 0
  122873. */
  122874. disableGrain(): void;
  122875. /**
  122876. * Sets the chromatic aberration amount
  122877. * @param amount amount of chromatic aberration
  122878. */
  122879. setChromaticAberration(amount: number): void;
  122880. /**
  122881. * Sets chromatic aberration amount to 0
  122882. */
  122883. disableChromaticAberration(): void;
  122884. /**
  122885. * Sets the EdgeDistortion amount
  122886. * @param amount amount of EdgeDistortion
  122887. */
  122888. setEdgeDistortion(amount: number): void;
  122889. /**
  122890. * Sets edge distortion to 0
  122891. */
  122892. disableEdgeDistortion(): void;
  122893. /**
  122894. * Sets the FocusDistance amount
  122895. * @param amount amount of FocusDistance
  122896. */
  122897. setFocusDistance(amount: number): void;
  122898. /**
  122899. * Disables depth of field
  122900. */
  122901. disableDepthOfField(): void;
  122902. /**
  122903. * Sets the Aperture amount
  122904. * @param amount amount of Aperture
  122905. */
  122906. setAperture(amount: number): void;
  122907. /**
  122908. * Sets the DarkenOutOfFocus amount
  122909. * @param amount amount of DarkenOutOfFocus
  122910. */
  122911. setDarkenOutOfFocus(amount: number): void;
  122912. private _pentagonBokehIsEnabled;
  122913. /**
  122914. * Creates a pentagon bokeh effect
  122915. */
  122916. enablePentagonBokeh(): void;
  122917. /**
  122918. * Disables the pentagon bokeh effect
  122919. */
  122920. disablePentagonBokeh(): void;
  122921. /**
  122922. * Enables noise blur
  122923. */
  122924. enableNoiseBlur(): void;
  122925. /**
  122926. * Disables noise blur
  122927. */
  122928. disableNoiseBlur(): void;
  122929. /**
  122930. * Sets the HighlightsGain amount
  122931. * @param amount amount of HighlightsGain
  122932. */
  122933. setHighlightsGain(amount: number): void;
  122934. /**
  122935. * Sets the HighlightsThreshold amount
  122936. * @param amount amount of HighlightsThreshold
  122937. */
  122938. setHighlightsThreshold(amount: number): void;
  122939. /**
  122940. * Disables highlights
  122941. */
  122942. disableHighlights(): void;
  122943. /**
  122944. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122945. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122946. */
  122947. dispose(disableDepthRender?: boolean): void;
  122948. private _createChromaticAberrationPostProcess;
  122949. private _createHighlightsPostProcess;
  122950. private _createDepthOfFieldPostProcess;
  122951. private _createGrainTexture;
  122952. }
  122953. }
  122954. declare module BABYLON {
  122955. /** @hidden */
  122956. export var ssao2PixelShader: {
  122957. name: string;
  122958. shader: string;
  122959. };
  122960. }
  122961. declare module BABYLON {
  122962. /** @hidden */
  122963. export var ssaoCombinePixelShader: {
  122964. name: string;
  122965. shader: string;
  122966. };
  122967. }
  122968. declare module BABYLON {
  122969. /**
  122970. * Render pipeline to produce ssao effect
  122971. */
  122972. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  122973. /**
  122974. * @ignore
  122975. * The PassPostProcess id in the pipeline that contains the original scene color
  122976. */
  122977. SSAOOriginalSceneColorEffect: string;
  122978. /**
  122979. * @ignore
  122980. * The SSAO PostProcess id in the pipeline
  122981. */
  122982. SSAORenderEffect: string;
  122983. /**
  122984. * @ignore
  122985. * The horizontal blur PostProcess id in the pipeline
  122986. */
  122987. SSAOBlurHRenderEffect: string;
  122988. /**
  122989. * @ignore
  122990. * The vertical blur PostProcess id in the pipeline
  122991. */
  122992. SSAOBlurVRenderEffect: string;
  122993. /**
  122994. * @ignore
  122995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122996. */
  122997. SSAOCombineRenderEffect: string;
  122998. /**
  122999. * The output strength of the SSAO post-process. Default value is 1.0.
  123000. */
  123001. totalStrength: number;
  123002. /**
  123003. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123004. */
  123005. maxZ: number;
  123006. /**
  123007. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123008. */
  123009. minZAspect: number;
  123010. private _samples;
  123011. /**
  123012. * Number of samples used for the SSAO calculations. Default value is 8
  123013. */
  123014. samples: number;
  123015. private _textureSamples;
  123016. /**
  123017. * Number of samples to use for antialiasing
  123018. */
  123019. textureSamples: number;
  123020. /**
  123021. * Ratio object used for SSAO ratio and blur ratio
  123022. */
  123023. private _ratio;
  123024. /**
  123025. * Dynamically generated sphere sampler.
  123026. */
  123027. private _sampleSphere;
  123028. /**
  123029. * Blur filter offsets
  123030. */
  123031. private _samplerOffsets;
  123032. private _expensiveBlur;
  123033. /**
  123034. * If bilateral blur should be used
  123035. */
  123036. expensiveBlur: boolean;
  123037. /**
  123038. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123039. */
  123040. radius: number;
  123041. /**
  123042. * The base color of the SSAO post-process
  123043. * The final result is "base + ssao" between [0, 1]
  123044. */
  123045. base: number;
  123046. /**
  123047. * Support test.
  123048. */
  123049. static readonly IsSupported: boolean;
  123050. private _scene;
  123051. private _depthTexture;
  123052. private _normalTexture;
  123053. private _randomTexture;
  123054. private _originalColorPostProcess;
  123055. private _ssaoPostProcess;
  123056. private _blurHPostProcess;
  123057. private _blurVPostProcess;
  123058. private _ssaoCombinePostProcess;
  123059. private _firstUpdate;
  123060. /**
  123061. * Gets active scene
  123062. */
  123063. readonly scene: Scene;
  123064. /**
  123065. * @constructor
  123066. * @param name The rendering pipeline name
  123067. * @param scene The scene linked to this pipeline
  123068. * @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 }
  123069. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123070. */
  123071. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123072. /**
  123073. * Get the class name
  123074. * @returns "SSAO2RenderingPipeline"
  123075. */
  123076. getClassName(): string;
  123077. /**
  123078. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123079. */
  123080. dispose(disableGeometryBufferRenderer?: boolean): void;
  123081. private _createBlurPostProcess;
  123082. /** @hidden */
  123083. _rebuild(): void;
  123084. private _bits;
  123085. private _radicalInverse_VdC;
  123086. private _hammersley;
  123087. private _hemisphereSample_uniform;
  123088. private _generateHemisphere;
  123089. private _createSSAOPostProcess;
  123090. private _createSSAOCombinePostProcess;
  123091. private _createRandomTexture;
  123092. /**
  123093. * Serialize the rendering pipeline (Used when exporting)
  123094. * @returns the serialized object
  123095. */
  123096. serialize(): any;
  123097. /**
  123098. * Parse the serialized pipeline
  123099. * @param source Source pipeline.
  123100. * @param scene The scene to load the pipeline to.
  123101. * @param rootUrl The URL of the serialized pipeline.
  123102. * @returns An instantiated pipeline from the serialized object.
  123103. */
  123104. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123105. }
  123106. }
  123107. declare module BABYLON {
  123108. /** @hidden */
  123109. export var ssaoPixelShader: {
  123110. name: string;
  123111. shader: string;
  123112. };
  123113. }
  123114. declare module BABYLON {
  123115. /**
  123116. * Render pipeline to produce ssao effect
  123117. */
  123118. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  123119. /**
  123120. * @ignore
  123121. * The PassPostProcess id in the pipeline that contains the original scene color
  123122. */
  123123. SSAOOriginalSceneColorEffect: string;
  123124. /**
  123125. * @ignore
  123126. * The SSAO PostProcess id in the pipeline
  123127. */
  123128. SSAORenderEffect: string;
  123129. /**
  123130. * @ignore
  123131. * The horizontal blur PostProcess id in the pipeline
  123132. */
  123133. SSAOBlurHRenderEffect: string;
  123134. /**
  123135. * @ignore
  123136. * The vertical blur PostProcess id in the pipeline
  123137. */
  123138. SSAOBlurVRenderEffect: string;
  123139. /**
  123140. * @ignore
  123141. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123142. */
  123143. SSAOCombineRenderEffect: string;
  123144. /**
  123145. * The output strength of the SSAO post-process. Default value is 1.0.
  123146. */
  123147. totalStrength: number;
  123148. /**
  123149. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  123150. */
  123151. radius: number;
  123152. /**
  123153. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  123154. * Must not be equal to fallOff and superior to fallOff.
  123155. * Default value is 0.0075
  123156. */
  123157. area: number;
  123158. /**
  123159. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  123160. * Must not be equal to area and inferior to area.
  123161. * Default value is 0.000001
  123162. */
  123163. fallOff: number;
  123164. /**
  123165. * The base color of the SSAO post-process
  123166. * The final result is "base + ssao" between [0, 1]
  123167. */
  123168. base: number;
  123169. private _scene;
  123170. private _depthTexture;
  123171. private _randomTexture;
  123172. private _originalColorPostProcess;
  123173. private _ssaoPostProcess;
  123174. private _blurHPostProcess;
  123175. private _blurVPostProcess;
  123176. private _ssaoCombinePostProcess;
  123177. private _firstUpdate;
  123178. /**
  123179. * Gets active scene
  123180. */
  123181. readonly scene: Scene;
  123182. /**
  123183. * @constructor
  123184. * @param name - The rendering pipeline name
  123185. * @param scene - The scene linked to this pipeline
  123186. * @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 }
  123187. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  123188. */
  123189. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123190. /**
  123191. * Get the class name
  123192. * @returns "SSAORenderingPipeline"
  123193. */
  123194. getClassName(): string;
  123195. /**
  123196. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123197. */
  123198. dispose(disableDepthRender?: boolean): void;
  123199. private _createBlurPostProcess;
  123200. /** @hidden */
  123201. _rebuild(): void;
  123202. private _createSSAOPostProcess;
  123203. private _createSSAOCombinePostProcess;
  123204. private _createRandomTexture;
  123205. }
  123206. }
  123207. declare module BABYLON {
  123208. /** @hidden */
  123209. export var standardPixelShader: {
  123210. name: string;
  123211. shader: string;
  123212. };
  123213. }
  123214. declare module BABYLON {
  123215. /**
  123216. * Standard rendering pipeline
  123217. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123218. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  123219. */
  123220. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123221. /**
  123222. * Public members
  123223. */
  123224. /**
  123225. * Post-process which contains the original scene color before the pipeline applies all the effects
  123226. */
  123227. originalPostProcess: Nullable<PostProcess>;
  123228. /**
  123229. * Post-process used to down scale an image x4
  123230. */
  123231. downSampleX4PostProcess: Nullable<PostProcess>;
  123232. /**
  123233. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  123234. */
  123235. brightPassPostProcess: Nullable<PostProcess>;
  123236. /**
  123237. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  123238. */
  123239. blurHPostProcesses: PostProcess[];
  123240. /**
  123241. * Post-process array storing all the vertical blur post-processes used by the pipeline
  123242. */
  123243. blurVPostProcesses: PostProcess[];
  123244. /**
  123245. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  123246. */
  123247. textureAdderPostProcess: Nullable<PostProcess>;
  123248. /**
  123249. * Post-process used to create volumetric lighting effect
  123250. */
  123251. volumetricLightPostProcess: Nullable<PostProcess>;
  123252. /**
  123253. * Post-process used to smooth the previous volumetric light post-process on the X axis
  123254. */
  123255. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  123256. /**
  123257. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  123258. */
  123259. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123260. /**
  123261. * Post-process used to merge the volumetric light effect and the real scene color
  123262. */
  123263. volumetricLightMergePostProces: Nullable<PostProcess>;
  123264. /**
  123265. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  123266. */
  123267. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  123268. /**
  123269. * Base post-process used to calculate the average luminance of the final image for HDR
  123270. */
  123271. luminancePostProcess: Nullable<PostProcess>;
  123272. /**
  123273. * Post-processes used to create down sample post-processes in order to get
  123274. * the average luminance of the final image for HDR
  123275. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  123276. */
  123277. luminanceDownSamplePostProcesses: PostProcess[];
  123278. /**
  123279. * Post-process used to create a HDR effect (light adaptation)
  123280. */
  123281. hdrPostProcess: Nullable<PostProcess>;
  123282. /**
  123283. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  123284. */
  123285. textureAdderFinalPostProcess: Nullable<PostProcess>;
  123286. /**
  123287. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  123288. */
  123289. lensFlareFinalPostProcess: Nullable<PostProcess>;
  123290. /**
  123291. * Post-process used to merge the final HDR post-process and the real scene color
  123292. */
  123293. hdrFinalPostProcess: Nullable<PostProcess>;
  123294. /**
  123295. * Post-process used to create a lens flare effect
  123296. */
  123297. lensFlarePostProcess: Nullable<PostProcess>;
  123298. /**
  123299. * Post-process that merges the result of the lens flare post-process and the real scene color
  123300. */
  123301. lensFlareComposePostProcess: Nullable<PostProcess>;
  123302. /**
  123303. * Post-process used to create a motion blur effect
  123304. */
  123305. motionBlurPostProcess: Nullable<PostProcess>;
  123306. /**
  123307. * Post-process used to create a depth of field effect
  123308. */
  123309. depthOfFieldPostProcess: Nullable<PostProcess>;
  123310. /**
  123311. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123312. */
  123313. fxaaPostProcess: Nullable<FxaaPostProcess>;
  123314. /**
  123315. * Represents the brightness threshold in order to configure the illuminated surfaces
  123316. */
  123317. brightThreshold: number;
  123318. /**
  123319. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  123320. */
  123321. blurWidth: number;
  123322. /**
  123323. * Sets if the blur for highlighted surfaces must be only horizontal
  123324. */
  123325. horizontalBlur: boolean;
  123326. /**
  123327. * Gets the overall exposure used by the pipeline
  123328. */
  123329. /**
  123330. * Sets the overall exposure used by the pipeline
  123331. */
  123332. exposure: number;
  123333. /**
  123334. * Texture used typically to simulate "dirty" on camera lens
  123335. */
  123336. lensTexture: Nullable<Texture>;
  123337. /**
  123338. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  123339. */
  123340. volumetricLightCoefficient: number;
  123341. /**
  123342. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  123343. */
  123344. volumetricLightPower: number;
  123345. /**
  123346. * Used the set the blur intensity to smooth the volumetric lights
  123347. */
  123348. volumetricLightBlurScale: number;
  123349. /**
  123350. * Light (spot or directional) used to generate the volumetric lights rays
  123351. * The source light must have a shadow generate so the pipeline can get its
  123352. * depth map
  123353. */
  123354. sourceLight: Nullable<SpotLight | DirectionalLight>;
  123355. /**
  123356. * For eye adaptation, represents the minimum luminance the eye can see
  123357. */
  123358. hdrMinimumLuminance: number;
  123359. /**
  123360. * For eye adaptation, represents the decrease luminance speed
  123361. */
  123362. hdrDecreaseRate: number;
  123363. /**
  123364. * For eye adaptation, represents the increase luminance speed
  123365. */
  123366. hdrIncreaseRate: number;
  123367. /**
  123368. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123369. */
  123370. /**
  123371. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123372. */
  123373. hdrAutoExposure: boolean;
  123374. /**
  123375. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  123376. */
  123377. lensColorTexture: Nullable<Texture>;
  123378. /**
  123379. * The overall strengh for the lens flare effect
  123380. */
  123381. lensFlareStrength: number;
  123382. /**
  123383. * Dispersion coefficient for lens flare ghosts
  123384. */
  123385. lensFlareGhostDispersal: number;
  123386. /**
  123387. * Main lens flare halo width
  123388. */
  123389. lensFlareHaloWidth: number;
  123390. /**
  123391. * Based on the lens distortion effect, defines how much the lens flare result
  123392. * is distorted
  123393. */
  123394. lensFlareDistortionStrength: number;
  123395. /**
  123396. * Lens star texture must be used to simulate rays on the flares and is available
  123397. * in the documentation
  123398. */
  123399. lensStarTexture: Nullable<Texture>;
  123400. /**
  123401. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  123402. * flare effect by taking account of the dirt texture
  123403. */
  123404. lensFlareDirtTexture: Nullable<Texture>;
  123405. /**
  123406. * Represents the focal length for the depth of field effect
  123407. */
  123408. depthOfFieldDistance: number;
  123409. /**
  123410. * Represents the blur intensity for the blurred part of the depth of field effect
  123411. */
  123412. depthOfFieldBlurWidth: number;
  123413. /**
  123414. * Gets how much the image is blurred by the movement while using the motion blur post-process
  123415. */
  123416. /**
  123417. * Sets how much the image is blurred by the movement while using the motion blur post-process
  123418. */
  123419. motionStrength: number;
  123420. /**
  123421. * Gets wether or not the motion blur post-process is object based or screen based.
  123422. */
  123423. /**
  123424. * Sets wether or not the motion blur post-process should be object based or screen based
  123425. */
  123426. objectBasedMotionBlur: boolean;
  123427. /**
  123428. * List of animations for the pipeline (IAnimatable implementation)
  123429. */
  123430. animations: Animation[];
  123431. /**
  123432. * Private members
  123433. */
  123434. private _scene;
  123435. private _currentDepthOfFieldSource;
  123436. private _basePostProcess;
  123437. private _fixedExposure;
  123438. private _currentExposure;
  123439. private _hdrAutoExposure;
  123440. private _hdrCurrentLuminance;
  123441. private _motionStrength;
  123442. private _isObjectBasedMotionBlur;
  123443. private _floatTextureType;
  123444. private _ratio;
  123445. private _bloomEnabled;
  123446. private _depthOfFieldEnabled;
  123447. private _vlsEnabled;
  123448. private _lensFlareEnabled;
  123449. private _hdrEnabled;
  123450. private _motionBlurEnabled;
  123451. private _fxaaEnabled;
  123452. private _motionBlurSamples;
  123453. private _volumetricLightStepsCount;
  123454. private _samples;
  123455. /**
  123456. * @ignore
  123457. * Specifies if the bloom pipeline is enabled
  123458. */
  123459. BloomEnabled: boolean;
  123460. /**
  123461. * @ignore
  123462. * Specifies if the depth of field pipeline is enabed
  123463. */
  123464. DepthOfFieldEnabled: boolean;
  123465. /**
  123466. * @ignore
  123467. * Specifies if the lens flare pipeline is enabed
  123468. */
  123469. LensFlareEnabled: boolean;
  123470. /**
  123471. * @ignore
  123472. * Specifies if the HDR pipeline is enabled
  123473. */
  123474. HDREnabled: boolean;
  123475. /**
  123476. * @ignore
  123477. * Specifies if the volumetric lights scattering effect is enabled
  123478. */
  123479. VLSEnabled: boolean;
  123480. /**
  123481. * @ignore
  123482. * Specifies if the motion blur effect is enabled
  123483. */
  123484. MotionBlurEnabled: boolean;
  123485. /**
  123486. * Specifies if anti-aliasing is enabled
  123487. */
  123488. fxaaEnabled: boolean;
  123489. /**
  123490. * Specifies the number of steps used to calculate the volumetric lights
  123491. * Typically in interval [50, 200]
  123492. */
  123493. volumetricLightStepsCount: number;
  123494. /**
  123495. * Specifies the number of samples used for the motion blur effect
  123496. * Typically in interval [16, 64]
  123497. */
  123498. motionBlurSamples: number;
  123499. /**
  123500. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123501. */
  123502. samples: number;
  123503. /**
  123504. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123505. * @constructor
  123506. * @param name The rendering pipeline name
  123507. * @param scene The scene linked to this pipeline
  123508. * @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)
  123509. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  123510. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123511. */
  123512. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  123513. private _buildPipeline;
  123514. private _createDownSampleX4PostProcess;
  123515. private _createBrightPassPostProcess;
  123516. private _createBlurPostProcesses;
  123517. private _createTextureAdderPostProcess;
  123518. private _createVolumetricLightPostProcess;
  123519. private _createLuminancePostProcesses;
  123520. private _createHdrPostProcess;
  123521. private _createLensFlarePostProcess;
  123522. private _createDepthOfFieldPostProcess;
  123523. private _createMotionBlurPostProcess;
  123524. private _getDepthTexture;
  123525. private _disposePostProcesses;
  123526. /**
  123527. * Dispose of the pipeline and stop all post processes
  123528. */
  123529. dispose(): void;
  123530. /**
  123531. * Serialize the rendering pipeline (Used when exporting)
  123532. * @returns the serialized object
  123533. */
  123534. serialize(): any;
  123535. /**
  123536. * Parse the serialized pipeline
  123537. * @param source Source pipeline.
  123538. * @param scene The scene to load the pipeline to.
  123539. * @param rootUrl The URL of the serialized pipeline.
  123540. * @returns An instantiated pipeline from the serialized object.
  123541. */
  123542. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  123543. /**
  123544. * Luminance steps
  123545. */
  123546. static LuminanceSteps: number;
  123547. }
  123548. }
  123549. declare module BABYLON {
  123550. /** @hidden */
  123551. export var tonemapPixelShader: {
  123552. name: string;
  123553. shader: string;
  123554. };
  123555. }
  123556. declare module BABYLON {
  123557. /** Defines operator used for tonemapping */
  123558. export enum TonemappingOperator {
  123559. /** Hable */
  123560. Hable = 0,
  123561. /** Reinhard */
  123562. Reinhard = 1,
  123563. /** HejiDawson */
  123564. HejiDawson = 2,
  123565. /** Photographic */
  123566. Photographic = 3
  123567. }
  123568. /**
  123569. * Defines a post process to apply tone mapping
  123570. */
  123571. export class TonemapPostProcess extends PostProcess {
  123572. private _operator;
  123573. /** Defines the required exposure adjustement */
  123574. exposureAdjustment: number;
  123575. /**
  123576. * Creates a new TonemapPostProcess
  123577. * @param name defines the name of the postprocess
  123578. * @param _operator defines the operator to use
  123579. * @param exposureAdjustment defines the required exposure adjustement
  123580. * @param camera defines the camera to use (can be null)
  123581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123582. * @param engine defines the hosting engine (can be ignore if camera is set)
  123583. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123584. */
  123585. constructor(name: string, _operator: TonemappingOperator,
  123586. /** Defines the required exposure adjustement */
  123587. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  123588. }
  123589. }
  123590. declare module BABYLON {
  123591. /** @hidden */
  123592. export var depthVertexShader: {
  123593. name: string;
  123594. shader: string;
  123595. };
  123596. }
  123597. declare module BABYLON {
  123598. /** @hidden */
  123599. export var volumetricLightScatteringPixelShader: {
  123600. name: string;
  123601. shader: string;
  123602. };
  123603. }
  123604. declare module BABYLON {
  123605. /** @hidden */
  123606. export var volumetricLightScatteringPassVertexShader: {
  123607. name: string;
  123608. shader: string;
  123609. };
  123610. }
  123611. declare module BABYLON {
  123612. /** @hidden */
  123613. export var volumetricLightScatteringPassPixelShader: {
  123614. name: string;
  123615. shader: string;
  123616. };
  123617. }
  123618. declare module BABYLON {
  123619. /**
  123620. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123621. */
  123622. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123623. private _volumetricLightScatteringPass;
  123624. private _volumetricLightScatteringRTT;
  123625. private _viewPort;
  123626. private _screenCoordinates;
  123627. private _cachedDefines;
  123628. /**
  123629. * If not undefined, the mesh position is computed from the attached node position
  123630. */
  123631. attachedNode: {
  123632. position: Vector3;
  123633. };
  123634. /**
  123635. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123636. */
  123637. customMeshPosition: Vector3;
  123638. /**
  123639. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123640. */
  123641. useCustomMeshPosition: boolean;
  123642. /**
  123643. * If the post-process should inverse the light scattering direction
  123644. */
  123645. invert: boolean;
  123646. /**
  123647. * The internal mesh used by the post-process
  123648. */
  123649. mesh: Mesh;
  123650. /**
  123651. * @hidden
  123652. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123653. */
  123654. useDiffuseColor: boolean;
  123655. /**
  123656. * Array containing the excluded meshes not rendered in the internal pass
  123657. */
  123658. excludedMeshes: AbstractMesh[];
  123659. /**
  123660. * Controls the overall intensity of the post-process
  123661. */
  123662. exposure: number;
  123663. /**
  123664. * Dissipates each sample's contribution in range [0, 1]
  123665. */
  123666. decay: number;
  123667. /**
  123668. * Controls the overall intensity of each sample
  123669. */
  123670. weight: number;
  123671. /**
  123672. * Controls the density of each sample
  123673. */
  123674. density: number;
  123675. /**
  123676. * @constructor
  123677. * @param name The post-process name
  123678. * @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)
  123679. * @param camera The camera that the post-process will be attached to
  123680. * @param mesh The mesh used to create the light scattering
  123681. * @param samples The post-process quality, default 100
  123682. * @param samplingModeThe post-process filtering mode
  123683. * @param engine The babylon engine
  123684. * @param reusable If the post-process is reusable
  123685. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123686. */
  123687. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123688. /**
  123689. * Returns the string "VolumetricLightScatteringPostProcess"
  123690. * @returns "VolumetricLightScatteringPostProcess"
  123691. */
  123692. getClassName(): string;
  123693. private _isReady;
  123694. /**
  123695. * Sets the new light position for light scattering effect
  123696. * @param position The new custom light position
  123697. */
  123698. setCustomMeshPosition(position: Vector3): void;
  123699. /**
  123700. * Returns the light position for light scattering effect
  123701. * @return Vector3 The custom light position
  123702. */
  123703. getCustomMeshPosition(): Vector3;
  123704. /**
  123705. * Disposes the internal assets and detaches the post-process from the camera
  123706. */
  123707. dispose(camera: Camera): void;
  123708. /**
  123709. * Returns the render target texture used by the post-process
  123710. * @return the render target texture used by the post-process
  123711. */
  123712. getPass(): RenderTargetTexture;
  123713. private _meshExcluded;
  123714. private _createPass;
  123715. private _updateMeshScreenCoordinates;
  123716. /**
  123717. * Creates a default mesh for the Volumeric Light Scattering post-process
  123718. * @param name The mesh name
  123719. * @param scene The scene where to create the mesh
  123720. * @return the default mesh
  123721. */
  123722. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123723. }
  123724. }
  123725. declare module BABYLON {
  123726. interface Scene {
  123727. /** @hidden (Backing field) */
  123728. _boundingBoxRenderer: BoundingBoxRenderer;
  123729. /** @hidden (Backing field) */
  123730. _forceShowBoundingBoxes: boolean;
  123731. /**
  123732. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123733. */
  123734. forceShowBoundingBoxes: boolean;
  123735. /**
  123736. * Gets the bounding box renderer associated with the scene
  123737. * @returns a BoundingBoxRenderer
  123738. */
  123739. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123740. }
  123741. interface AbstractMesh {
  123742. /** @hidden (Backing field) */
  123743. _showBoundingBox: boolean;
  123744. /**
  123745. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  123746. */
  123747. showBoundingBox: boolean;
  123748. }
  123749. /**
  123750. * Component responsible of rendering the bounding box of the meshes in a scene.
  123751. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  123752. */
  123753. export class BoundingBoxRenderer implements ISceneComponent {
  123754. /**
  123755. * The component name helpfull to identify the component in the list of scene components.
  123756. */
  123757. readonly name: string;
  123758. /**
  123759. * The scene the component belongs to.
  123760. */
  123761. scene: Scene;
  123762. /**
  123763. * Color of the bounding box lines placed in front of an object
  123764. */
  123765. frontColor: Color3;
  123766. /**
  123767. * Color of the bounding box lines placed behind an object
  123768. */
  123769. backColor: Color3;
  123770. /**
  123771. * Defines if the renderer should show the back lines or not
  123772. */
  123773. showBackLines: boolean;
  123774. /**
  123775. * @hidden
  123776. */
  123777. renderList: SmartArray<BoundingBox>;
  123778. private _colorShader;
  123779. private _vertexBuffers;
  123780. private _indexBuffer;
  123781. private _fillIndexBuffer;
  123782. private _fillIndexData;
  123783. /**
  123784. * Instantiates a new bounding box renderer in a scene.
  123785. * @param scene the scene the renderer renders in
  123786. */
  123787. constructor(scene: Scene);
  123788. /**
  123789. * Registers the component in a given scene
  123790. */
  123791. register(): void;
  123792. private _evaluateSubMesh;
  123793. private _activeMesh;
  123794. private _prepareRessources;
  123795. private _createIndexBuffer;
  123796. /**
  123797. * Rebuilds the elements related to this component in case of
  123798. * context lost for instance.
  123799. */
  123800. rebuild(): void;
  123801. /**
  123802. * @hidden
  123803. */
  123804. reset(): void;
  123805. /**
  123806. * Render the bounding boxes of a specific rendering group
  123807. * @param renderingGroupId defines the rendering group to render
  123808. */
  123809. render(renderingGroupId: number): void;
  123810. /**
  123811. * In case of occlusion queries, we can render the occlusion bounding box through this method
  123812. * @param mesh Define the mesh to render the occlusion bounding box for
  123813. */
  123814. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  123815. /**
  123816. * Dispose and release the resources attached to this renderer.
  123817. */
  123818. dispose(): void;
  123819. }
  123820. }
  123821. declare module BABYLON {
  123822. /** @hidden */
  123823. export var depthPixelShader: {
  123824. name: string;
  123825. shader: string;
  123826. };
  123827. }
  123828. declare module BABYLON {
  123829. /**
  123830. * This represents a depth renderer in Babylon.
  123831. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  123832. */
  123833. export class DepthRenderer {
  123834. private _scene;
  123835. private _depthMap;
  123836. private _effect;
  123837. private readonly _storeNonLinearDepth;
  123838. private readonly _clearColor;
  123839. /** Get if the depth renderer is using packed depth or not */
  123840. readonly isPacked: boolean;
  123841. private _cachedDefines;
  123842. private _camera;
  123843. /**
  123844. * Specifiess that the depth renderer will only be used within
  123845. * the camera it is created for.
  123846. * This can help forcing its rendering during the camera processing.
  123847. */
  123848. useOnlyInActiveCamera: boolean;
  123849. /** @hidden */
  123850. static _SceneComponentInitialization: (scene: Scene) => void;
  123851. /**
  123852. * Instantiates a depth renderer
  123853. * @param scene The scene the renderer belongs to
  123854. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  123855. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  123856. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123857. */
  123858. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  123859. /**
  123860. * Creates the depth rendering effect and checks if the effect is ready.
  123861. * @param subMesh The submesh to be used to render the depth map of
  123862. * @param useInstances If multiple world instances should be used
  123863. * @returns if the depth renderer is ready to render the depth map
  123864. */
  123865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123866. /**
  123867. * Gets the texture which the depth map will be written to.
  123868. * @returns The depth map texture
  123869. */
  123870. getDepthMap(): RenderTargetTexture;
  123871. /**
  123872. * Disposes of the depth renderer.
  123873. */
  123874. dispose(): void;
  123875. }
  123876. }
  123877. declare module BABYLON {
  123878. interface Scene {
  123879. /** @hidden (Backing field) */
  123880. _depthRenderer: {
  123881. [id: string]: DepthRenderer;
  123882. };
  123883. /**
  123884. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  123885. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  123886. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123887. * @returns the created depth renderer
  123888. */
  123889. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  123890. /**
  123891. * Disables a depth renderer for a given camera
  123892. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  123893. */
  123894. disableDepthRenderer(camera?: Nullable<Camera>): void;
  123895. }
  123896. /**
  123897. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  123898. * in several rendering techniques.
  123899. */
  123900. export class DepthRendererSceneComponent implements ISceneComponent {
  123901. /**
  123902. * The component name helpfull to identify the component in the list of scene components.
  123903. */
  123904. readonly name: string;
  123905. /**
  123906. * The scene the component belongs to.
  123907. */
  123908. scene: Scene;
  123909. /**
  123910. * Creates a new instance of the component for the given scene
  123911. * @param scene Defines the scene to register the component in
  123912. */
  123913. constructor(scene: Scene);
  123914. /**
  123915. * Registers the component in a given scene
  123916. */
  123917. register(): void;
  123918. /**
  123919. * Rebuilds the elements related to this component in case of
  123920. * context lost for instance.
  123921. */
  123922. rebuild(): void;
  123923. /**
  123924. * Disposes the component and the associated ressources
  123925. */
  123926. dispose(): void;
  123927. private _gatherRenderTargets;
  123928. private _gatherActiveCameraRenderTargets;
  123929. }
  123930. }
  123931. declare module BABYLON {
  123932. /** @hidden */
  123933. export var outlinePixelShader: {
  123934. name: string;
  123935. shader: string;
  123936. };
  123937. }
  123938. declare module BABYLON {
  123939. /** @hidden */
  123940. export var outlineVertexShader: {
  123941. name: string;
  123942. shader: string;
  123943. };
  123944. }
  123945. declare module BABYLON {
  123946. interface Scene {
  123947. /** @hidden */
  123948. _outlineRenderer: OutlineRenderer;
  123949. /**
  123950. * Gets the outline renderer associated with the scene
  123951. * @returns a OutlineRenderer
  123952. */
  123953. getOutlineRenderer(): OutlineRenderer;
  123954. }
  123955. interface AbstractMesh {
  123956. /** @hidden (Backing field) */
  123957. _renderOutline: boolean;
  123958. /**
  123959. * Gets or sets a boolean indicating if the outline must be rendered as well
  123960. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  123961. */
  123962. renderOutline: boolean;
  123963. /** @hidden (Backing field) */
  123964. _renderOverlay: boolean;
  123965. /**
  123966. * Gets or sets a boolean indicating if the overlay must be rendered as well
  123967. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  123968. */
  123969. renderOverlay: boolean;
  123970. }
  123971. /**
  123972. * This class is responsible to draw bothe outline/overlay of meshes.
  123973. * It should not be used directly but through the available method on mesh.
  123974. */
  123975. export class OutlineRenderer implements ISceneComponent {
  123976. /**
  123977. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  123978. */
  123979. private static _StencilReference;
  123980. /**
  123981. * The name of the component. Each component must have a unique name.
  123982. */
  123983. name: string;
  123984. /**
  123985. * The scene the component belongs to.
  123986. */
  123987. scene: Scene;
  123988. /**
  123989. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123990. */
  123991. zOffset: number;
  123992. private _engine;
  123993. private _effect;
  123994. private _cachedDefines;
  123995. private _savedDepthWrite;
  123996. /**
  123997. * Instantiates a new outline renderer. (There could be only one per scene).
  123998. * @param scene Defines the scene it belongs to
  123999. */
  124000. constructor(scene: Scene);
  124001. /**
  124002. * Register the component to one instance of a scene.
  124003. */
  124004. register(): void;
  124005. /**
  124006. * Rebuilds the elements related to this component in case of
  124007. * context lost for instance.
  124008. */
  124009. rebuild(): void;
  124010. /**
  124011. * Disposes the component and the associated ressources.
  124012. */
  124013. dispose(): void;
  124014. /**
  124015. * Renders the outline in the canvas.
  124016. * @param subMesh Defines the sumesh to render
  124017. * @param batch Defines the batch of meshes in case of instances
  124018. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124019. */
  124020. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124021. /**
  124022. * Returns whether or not the outline renderer is ready for a given submesh.
  124023. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124024. * @param subMesh Defines the submesh to check readyness for
  124025. * @param useInstances Defines wheter wee are trying to render instances or not
  124026. * @returns true if ready otherwise false
  124027. */
  124028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124029. private _beforeRenderingMesh;
  124030. private _afterRenderingMesh;
  124031. }
  124032. }
  124033. declare module BABYLON {
  124034. /**
  124035. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124036. * @see http://doc.babylonjs.com/babylon101/sprites
  124037. */
  124038. export class SpritePackedManager extends SpriteManager {
  124039. /** defines the packed manager's name */
  124040. name: string;
  124041. /**
  124042. * Creates a new sprite manager from a packed sprite sheet
  124043. * @param name defines the manager's name
  124044. * @param imgUrl defines the sprite sheet url
  124045. * @param capacity defines the maximum allowed number of sprites
  124046. * @param scene defines the hosting scene
  124047. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124048. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124049. * @param samplingMode defines the smapling mode to use with spritesheet
  124050. * @param fromPacked set to true; do not alter
  124051. */
  124052. constructor(
  124053. /** defines the packed manager's name */
  124054. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124055. }
  124056. }
  124057. declare module BABYLON {
  124058. /**
  124059. * Defines the list of states available for a task inside a AssetsManager
  124060. */
  124061. export enum AssetTaskState {
  124062. /**
  124063. * Initialization
  124064. */
  124065. INIT = 0,
  124066. /**
  124067. * Running
  124068. */
  124069. RUNNING = 1,
  124070. /**
  124071. * Done
  124072. */
  124073. DONE = 2,
  124074. /**
  124075. * Error
  124076. */
  124077. ERROR = 3
  124078. }
  124079. /**
  124080. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124081. */
  124082. export abstract class AbstractAssetTask {
  124083. /**
  124084. * Task name
  124085. */ name: string;
  124086. /**
  124087. * Callback called when the task is successful
  124088. */
  124089. onSuccess: (task: any) => void;
  124090. /**
  124091. * Callback called when the task is not successful
  124092. */
  124093. onError: (task: any, message?: string, exception?: any) => void;
  124094. /**
  124095. * Creates a new AssetsManager
  124096. * @param name defines the name of the task
  124097. */
  124098. constructor(
  124099. /**
  124100. * Task name
  124101. */ name: string);
  124102. private _isCompleted;
  124103. private _taskState;
  124104. private _errorObject;
  124105. /**
  124106. * Get if the task is completed
  124107. */
  124108. readonly isCompleted: boolean;
  124109. /**
  124110. * Gets the current state of the task
  124111. */
  124112. readonly taskState: AssetTaskState;
  124113. /**
  124114. * Gets the current error object (if task is in error)
  124115. */
  124116. readonly errorObject: {
  124117. message?: string;
  124118. exception?: any;
  124119. };
  124120. /**
  124121. * Internal only
  124122. * @hidden
  124123. */
  124124. _setErrorObject(message?: string, exception?: any): void;
  124125. /**
  124126. * Execute the current task
  124127. * @param scene defines the scene where you want your assets to be loaded
  124128. * @param onSuccess is a callback called when the task is successfully executed
  124129. * @param onError is a callback called if an error occurs
  124130. */
  124131. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124132. /**
  124133. * Execute the current task
  124134. * @param scene defines the scene where you want your assets to be loaded
  124135. * @param onSuccess is a callback called when the task is successfully executed
  124136. * @param onError is a callback called if an error occurs
  124137. */
  124138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124139. /**
  124140. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  124141. * This can be used with failed tasks that have the reason for failure fixed.
  124142. */
  124143. reset(): void;
  124144. private onErrorCallback;
  124145. private onDoneCallback;
  124146. }
  124147. /**
  124148. * Define the interface used by progress events raised during assets loading
  124149. */
  124150. export interface IAssetsProgressEvent {
  124151. /**
  124152. * Defines the number of remaining tasks to process
  124153. */
  124154. remainingCount: number;
  124155. /**
  124156. * Defines the total number of tasks
  124157. */
  124158. totalCount: number;
  124159. /**
  124160. * Defines the task that was just processed
  124161. */
  124162. task: AbstractAssetTask;
  124163. }
  124164. /**
  124165. * Class used to share progress information about assets loading
  124166. */
  124167. export class AssetsProgressEvent implements IAssetsProgressEvent {
  124168. /**
  124169. * Defines the number of remaining tasks to process
  124170. */
  124171. remainingCount: number;
  124172. /**
  124173. * Defines the total number of tasks
  124174. */
  124175. totalCount: number;
  124176. /**
  124177. * Defines the task that was just processed
  124178. */
  124179. task: AbstractAssetTask;
  124180. /**
  124181. * Creates a AssetsProgressEvent
  124182. * @param remainingCount defines the number of remaining tasks to process
  124183. * @param totalCount defines the total number of tasks
  124184. * @param task defines the task that was just processed
  124185. */
  124186. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  124187. }
  124188. /**
  124189. * Define a task used by AssetsManager to load meshes
  124190. */
  124191. export class MeshAssetTask extends AbstractAssetTask {
  124192. /**
  124193. * Defines the name of the task
  124194. */
  124195. name: string;
  124196. /**
  124197. * Defines the list of mesh's names you want to load
  124198. */
  124199. meshesNames: any;
  124200. /**
  124201. * Defines the root url to use as a base to load your meshes and associated resources
  124202. */
  124203. rootUrl: string;
  124204. /**
  124205. * Defines the filename of the scene to load from
  124206. */
  124207. sceneFilename: string;
  124208. /**
  124209. * Gets the list of loaded meshes
  124210. */
  124211. loadedMeshes: Array<AbstractMesh>;
  124212. /**
  124213. * Gets the list of loaded particle systems
  124214. */
  124215. loadedParticleSystems: Array<IParticleSystem>;
  124216. /**
  124217. * Gets the list of loaded skeletons
  124218. */
  124219. loadedSkeletons: Array<Skeleton>;
  124220. /**
  124221. * Gets the list of loaded animation groups
  124222. */
  124223. loadedAnimationGroups: Array<AnimationGroup>;
  124224. /**
  124225. * Callback called when the task is successful
  124226. */
  124227. onSuccess: (task: MeshAssetTask) => void;
  124228. /**
  124229. * Callback called when the task is successful
  124230. */
  124231. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  124232. /**
  124233. * Creates a new MeshAssetTask
  124234. * @param name defines the name of the task
  124235. * @param meshesNames defines the list of mesh's names you want to load
  124236. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  124237. * @param sceneFilename defines the filename of the scene to load from
  124238. */
  124239. constructor(
  124240. /**
  124241. * Defines the name of the task
  124242. */
  124243. name: string,
  124244. /**
  124245. * Defines the list of mesh's names you want to load
  124246. */
  124247. meshesNames: any,
  124248. /**
  124249. * Defines the root url to use as a base to load your meshes and associated resources
  124250. */
  124251. rootUrl: string,
  124252. /**
  124253. * Defines the filename of the scene to load from
  124254. */
  124255. sceneFilename: string);
  124256. /**
  124257. * Execute the current task
  124258. * @param scene defines the scene where you want your assets to be loaded
  124259. * @param onSuccess is a callback called when the task is successfully executed
  124260. * @param onError is a callback called if an error occurs
  124261. */
  124262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124263. }
  124264. /**
  124265. * Define a task used by AssetsManager to load text content
  124266. */
  124267. export class TextFileAssetTask extends AbstractAssetTask {
  124268. /**
  124269. * Defines the name of the task
  124270. */
  124271. name: string;
  124272. /**
  124273. * Defines the location of the file to load
  124274. */
  124275. url: string;
  124276. /**
  124277. * Gets the loaded text string
  124278. */
  124279. text: string;
  124280. /**
  124281. * Callback called when the task is successful
  124282. */
  124283. onSuccess: (task: TextFileAssetTask) => void;
  124284. /**
  124285. * Callback called when the task is successful
  124286. */
  124287. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  124288. /**
  124289. * Creates a new TextFileAssetTask object
  124290. * @param name defines the name of the task
  124291. * @param url defines the location of the file to load
  124292. */
  124293. constructor(
  124294. /**
  124295. * Defines the name of the task
  124296. */
  124297. name: string,
  124298. /**
  124299. * Defines the location of the file to load
  124300. */
  124301. url: string);
  124302. /**
  124303. * Execute the current task
  124304. * @param scene defines the scene where you want your assets to be loaded
  124305. * @param onSuccess is a callback called when the task is successfully executed
  124306. * @param onError is a callback called if an error occurs
  124307. */
  124308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124309. }
  124310. /**
  124311. * Define a task used by AssetsManager to load binary data
  124312. */
  124313. export class BinaryFileAssetTask extends AbstractAssetTask {
  124314. /**
  124315. * Defines the name of the task
  124316. */
  124317. name: string;
  124318. /**
  124319. * Defines the location of the file to load
  124320. */
  124321. url: string;
  124322. /**
  124323. * Gets the lodaded data (as an array buffer)
  124324. */
  124325. data: ArrayBuffer;
  124326. /**
  124327. * Callback called when the task is successful
  124328. */
  124329. onSuccess: (task: BinaryFileAssetTask) => void;
  124330. /**
  124331. * Callback called when the task is successful
  124332. */
  124333. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  124334. /**
  124335. * Creates a new BinaryFileAssetTask object
  124336. * @param name defines the name of the new task
  124337. * @param url defines the location of the file to load
  124338. */
  124339. constructor(
  124340. /**
  124341. * Defines the name of the task
  124342. */
  124343. name: string,
  124344. /**
  124345. * Defines the location of the file to load
  124346. */
  124347. url: string);
  124348. /**
  124349. * Execute the current task
  124350. * @param scene defines the scene where you want your assets to be loaded
  124351. * @param onSuccess is a callback called when the task is successfully executed
  124352. * @param onError is a callback called if an error occurs
  124353. */
  124354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124355. }
  124356. /**
  124357. * Define a task used by AssetsManager to load images
  124358. */
  124359. export class ImageAssetTask extends AbstractAssetTask {
  124360. /**
  124361. * Defines the name of the task
  124362. */
  124363. name: string;
  124364. /**
  124365. * Defines the location of the image to load
  124366. */
  124367. url: string;
  124368. /**
  124369. * Gets the loaded images
  124370. */
  124371. image: HTMLImageElement;
  124372. /**
  124373. * Callback called when the task is successful
  124374. */
  124375. onSuccess: (task: ImageAssetTask) => void;
  124376. /**
  124377. * Callback called when the task is successful
  124378. */
  124379. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  124380. /**
  124381. * Creates a new ImageAssetTask
  124382. * @param name defines the name of the task
  124383. * @param url defines the location of the image to load
  124384. */
  124385. constructor(
  124386. /**
  124387. * Defines the name of the task
  124388. */
  124389. name: string,
  124390. /**
  124391. * Defines the location of the image to load
  124392. */
  124393. url: string);
  124394. /**
  124395. * Execute the current task
  124396. * @param scene defines the scene where you want your assets to be loaded
  124397. * @param onSuccess is a callback called when the task is successfully executed
  124398. * @param onError is a callback called if an error occurs
  124399. */
  124400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124401. }
  124402. /**
  124403. * Defines the interface used by texture loading tasks
  124404. */
  124405. export interface ITextureAssetTask<TEX extends BaseTexture> {
  124406. /**
  124407. * Gets the loaded texture
  124408. */
  124409. texture: TEX;
  124410. }
  124411. /**
  124412. * Define a task used by AssetsManager to load 2D textures
  124413. */
  124414. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  124415. /**
  124416. * Defines the name of the task
  124417. */
  124418. name: string;
  124419. /**
  124420. * Defines the location of the file to load
  124421. */
  124422. url: string;
  124423. /**
  124424. * Defines if mipmap should not be generated (default is false)
  124425. */
  124426. noMipmap?: boolean | undefined;
  124427. /**
  124428. * Defines if texture must be inverted on Y axis (default is false)
  124429. */
  124430. invertY?: boolean | undefined;
  124431. /**
  124432. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124433. */
  124434. samplingMode: number;
  124435. /**
  124436. * Gets the loaded texture
  124437. */
  124438. texture: Texture;
  124439. /**
  124440. * Callback called when the task is successful
  124441. */
  124442. onSuccess: (task: TextureAssetTask) => void;
  124443. /**
  124444. * Callback called when the task is successful
  124445. */
  124446. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  124447. /**
  124448. * Creates a new TextureAssetTask object
  124449. * @param name defines the name of the task
  124450. * @param url defines the location of the file to load
  124451. * @param noMipmap defines if mipmap should not be generated (default is false)
  124452. * @param invertY defines if texture must be inverted on Y axis (default is false)
  124453. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124454. */
  124455. constructor(
  124456. /**
  124457. * Defines the name of the task
  124458. */
  124459. name: string,
  124460. /**
  124461. * Defines the location of the file to load
  124462. */
  124463. url: string,
  124464. /**
  124465. * Defines if mipmap should not be generated (default is false)
  124466. */
  124467. noMipmap?: boolean | undefined,
  124468. /**
  124469. * Defines if texture must be inverted on Y axis (default is false)
  124470. */
  124471. invertY?: boolean | undefined,
  124472. /**
  124473. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124474. */
  124475. samplingMode?: number);
  124476. /**
  124477. * Execute the current task
  124478. * @param scene defines the scene where you want your assets to be loaded
  124479. * @param onSuccess is a callback called when the task is successfully executed
  124480. * @param onError is a callback called if an error occurs
  124481. */
  124482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124483. }
  124484. /**
  124485. * Define a task used by AssetsManager to load cube textures
  124486. */
  124487. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  124488. /**
  124489. * Defines the name of the task
  124490. */
  124491. name: string;
  124492. /**
  124493. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124494. */
  124495. url: string;
  124496. /**
  124497. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124498. */
  124499. extensions?: string[] | undefined;
  124500. /**
  124501. * Defines if mipmaps should not be generated (default is false)
  124502. */
  124503. noMipmap?: boolean | undefined;
  124504. /**
  124505. * Defines the explicit list of files (undefined by default)
  124506. */
  124507. files?: string[] | undefined;
  124508. /**
  124509. * Gets the loaded texture
  124510. */
  124511. texture: CubeTexture;
  124512. /**
  124513. * Callback called when the task is successful
  124514. */
  124515. onSuccess: (task: CubeTextureAssetTask) => void;
  124516. /**
  124517. * Callback called when the task is successful
  124518. */
  124519. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  124520. /**
  124521. * Creates a new CubeTextureAssetTask
  124522. * @param name defines the name of the task
  124523. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124524. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124525. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124526. * @param files defines the explicit list of files (undefined by default)
  124527. */
  124528. constructor(
  124529. /**
  124530. * Defines the name of the task
  124531. */
  124532. name: string,
  124533. /**
  124534. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124535. */
  124536. url: string,
  124537. /**
  124538. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124539. */
  124540. extensions?: string[] | undefined,
  124541. /**
  124542. * Defines if mipmaps should not be generated (default is false)
  124543. */
  124544. noMipmap?: boolean | undefined,
  124545. /**
  124546. * Defines the explicit list of files (undefined by default)
  124547. */
  124548. files?: string[] | undefined);
  124549. /**
  124550. * Execute the current task
  124551. * @param scene defines the scene where you want your assets to be loaded
  124552. * @param onSuccess is a callback called when the task is successfully executed
  124553. * @param onError is a callback called if an error occurs
  124554. */
  124555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124556. }
  124557. /**
  124558. * Define a task used by AssetsManager to load HDR cube textures
  124559. */
  124560. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  124561. /**
  124562. * Defines the name of the task
  124563. */
  124564. name: string;
  124565. /**
  124566. * Defines the location of the file to load
  124567. */
  124568. url: string;
  124569. /**
  124570. * Defines the desired size (the more it increases the longer the generation will be)
  124571. */
  124572. size: number;
  124573. /**
  124574. * Defines if mipmaps should not be generated (default is false)
  124575. */
  124576. noMipmap: boolean;
  124577. /**
  124578. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124579. */
  124580. generateHarmonics: boolean;
  124581. /**
  124582. * 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)
  124583. */
  124584. gammaSpace: boolean;
  124585. /**
  124586. * Internal Use Only
  124587. */
  124588. reserved: boolean;
  124589. /**
  124590. * Gets the loaded texture
  124591. */
  124592. texture: HDRCubeTexture;
  124593. /**
  124594. * Callback called when the task is successful
  124595. */
  124596. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  124597. /**
  124598. * Callback called when the task is successful
  124599. */
  124600. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  124601. /**
  124602. * Creates a new HDRCubeTextureAssetTask object
  124603. * @param name defines the name of the task
  124604. * @param url defines the location of the file to load
  124605. * @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.
  124606. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124607. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124608. * @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)
  124609. * @param reserved Internal use only
  124610. */
  124611. constructor(
  124612. /**
  124613. * Defines the name of the task
  124614. */
  124615. name: string,
  124616. /**
  124617. * Defines the location of the file to load
  124618. */
  124619. url: string,
  124620. /**
  124621. * Defines the desired size (the more it increases the longer the generation will be)
  124622. */
  124623. size: number,
  124624. /**
  124625. * Defines if mipmaps should not be generated (default is false)
  124626. */
  124627. noMipmap?: boolean,
  124628. /**
  124629. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124630. */
  124631. generateHarmonics?: boolean,
  124632. /**
  124633. * 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)
  124634. */
  124635. gammaSpace?: boolean,
  124636. /**
  124637. * Internal Use Only
  124638. */
  124639. reserved?: boolean);
  124640. /**
  124641. * Execute the current task
  124642. * @param scene defines the scene where you want your assets to be loaded
  124643. * @param onSuccess is a callback called when the task is successfully executed
  124644. * @param onError is a callback called if an error occurs
  124645. */
  124646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124647. }
  124648. /**
  124649. * Define a task used by AssetsManager to load Equirectangular cube textures
  124650. */
  124651. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124652. /**
  124653. * Defines the name of the task
  124654. */
  124655. name: string;
  124656. /**
  124657. * Defines the location of the file to load
  124658. */
  124659. url: string;
  124660. /**
  124661. * Defines the desired size (the more it increases the longer the generation will be)
  124662. */
  124663. size: number;
  124664. /**
  124665. * Defines if mipmaps should not be generated (default is false)
  124666. */
  124667. noMipmap: boolean;
  124668. /**
  124669. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124670. * but the standard material would require them in Gamma space) (default is true)
  124671. */
  124672. gammaSpace: boolean;
  124673. /**
  124674. * Gets the loaded texture
  124675. */
  124676. texture: EquiRectangularCubeTexture;
  124677. /**
  124678. * Callback called when the task is successful
  124679. */
  124680. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124681. /**
  124682. * Callback called when the task is successful
  124683. */
  124684. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124685. /**
  124686. * Creates a new EquiRectangularCubeTextureAssetTask object
  124687. * @param name defines the name of the task
  124688. * @param url defines the location of the file to load
  124689. * @param size defines the desired size (the more it increases the longer the generation will be)
  124690. * If the size is omitted this implies you are using a preprocessed cubemap.
  124691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124692. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124693. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124694. * (default is true)
  124695. */
  124696. constructor(
  124697. /**
  124698. * Defines the name of the task
  124699. */
  124700. name: string,
  124701. /**
  124702. * Defines the location of the file to load
  124703. */
  124704. url: string,
  124705. /**
  124706. * Defines the desired size (the more it increases the longer the generation will be)
  124707. */
  124708. size: number,
  124709. /**
  124710. * Defines if mipmaps should not be generated (default is false)
  124711. */
  124712. noMipmap?: boolean,
  124713. /**
  124714. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124715. * but the standard material would require them in Gamma space) (default is true)
  124716. */
  124717. gammaSpace?: boolean);
  124718. /**
  124719. * Execute the current task
  124720. * @param scene defines the scene where you want your assets to be loaded
  124721. * @param onSuccess is a callback called when the task is successfully executed
  124722. * @param onError is a callback called if an error occurs
  124723. */
  124724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124725. }
  124726. /**
  124727. * This class can be used to easily import assets into a scene
  124728. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124729. */
  124730. export class AssetsManager {
  124731. private _scene;
  124732. private _isLoading;
  124733. protected _tasks: AbstractAssetTask[];
  124734. protected _waitingTasksCount: number;
  124735. protected _totalTasksCount: number;
  124736. /**
  124737. * Callback called when all tasks are processed
  124738. */
  124739. onFinish: (tasks: AbstractAssetTask[]) => void;
  124740. /**
  124741. * Callback called when a task is successful
  124742. */
  124743. onTaskSuccess: (task: AbstractAssetTask) => void;
  124744. /**
  124745. * Callback called when a task had an error
  124746. */
  124747. onTaskError: (task: AbstractAssetTask) => void;
  124748. /**
  124749. * Callback called when a task is done (whatever the result is)
  124750. */
  124751. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  124752. /**
  124753. * Observable called when all tasks are processed
  124754. */
  124755. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  124756. /**
  124757. * Observable called when a task had an error
  124758. */
  124759. onTaskErrorObservable: Observable<AbstractAssetTask>;
  124760. /**
  124761. * Observable called when all tasks were executed
  124762. */
  124763. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  124764. /**
  124765. * Observable called when a task is done (whatever the result is)
  124766. */
  124767. onProgressObservable: Observable<IAssetsProgressEvent>;
  124768. /**
  124769. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  124770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  124771. */
  124772. useDefaultLoadingScreen: boolean;
  124773. /**
  124774. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  124775. * when all assets have been downloaded.
  124776. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  124777. */
  124778. autoHideLoadingUI: boolean;
  124779. /**
  124780. * Creates a new AssetsManager
  124781. * @param scene defines the scene to work on
  124782. */
  124783. constructor(scene: Scene);
  124784. /**
  124785. * Add a MeshAssetTask to the list of active tasks
  124786. * @param taskName defines the name of the new task
  124787. * @param meshesNames defines the name of meshes to load
  124788. * @param rootUrl defines the root url to use to locate files
  124789. * @param sceneFilename defines the filename of the scene file
  124790. * @returns a new MeshAssetTask object
  124791. */
  124792. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  124793. /**
  124794. * Add a TextFileAssetTask to the list of active tasks
  124795. * @param taskName defines the name of the new task
  124796. * @param url defines the url of the file to load
  124797. * @returns a new TextFileAssetTask object
  124798. */
  124799. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  124800. /**
  124801. * Add a BinaryFileAssetTask to the list of active tasks
  124802. * @param taskName defines the name of the new task
  124803. * @param url defines the url of the file to load
  124804. * @returns a new BinaryFileAssetTask object
  124805. */
  124806. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  124807. /**
  124808. * Add a ImageAssetTask to the list of active tasks
  124809. * @param taskName defines the name of the new task
  124810. * @param url defines the url of the file to load
  124811. * @returns a new ImageAssetTask object
  124812. */
  124813. addImageTask(taskName: string, url: string): ImageAssetTask;
  124814. /**
  124815. * Add a TextureAssetTask to the list of active tasks
  124816. * @param taskName defines the name of the new task
  124817. * @param url defines the url of the file to load
  124818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124819. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  124820. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124821. * @returns a new TextureAssetTask object
  124822. */
  124823. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  124824. /**
  124825. * Add a CubeTextureAssetTask to the list of active tasks
  124826. * @param taskName defines the name of the new task
  124827. * @param url defines the url of the file to load
  124828. * @param extensions defines the extension to use to load the cube map (can be null)
  124829. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124830. * @param files defines the list of files to load (can be null)
  124831. * @returns a new CubeTextureAssetTask object
  124832. */
  124833. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  124834. /**
  124835. *
  124836. * Add a HDRCubeTextureAssetTask to the list of active tasks
  124837. * @param taskName defines the name of the new task
  124838. * @param url defines the url of the file to load
  124839. * @param size defines the size you want for the cubemap (can be null)
  124840. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124841. * @param generateHarmonics defines if you want to automatically generate (true by default)
  124842. * @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)
  124843. * @param reserved Internal use only
  124844. * @returns a new HDRCubeTextureAssetTask object
  124845. */
  124846. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  124847. /**
  124848. *
  124849. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  124850. * @param taskName defines the name of the new task
  124851. * @param url defines the url of the file to load
  124852. * @param size defines the size you want for the cubemap (can be null)
  124853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124854. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124855. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124856. * @returns a new EquiRectangularCubeTextureAssetTask object
  124857. */
  124858. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  124859. /**
  124860. * Remove a task from the assets manager.
  124861. * @param task the task to remove
  124862. */
  124863. removeTask(task: AbstractAssetTask): void;
  124864. private _decreaseWaitingTasksCount;
  124865. private _runTask;
  124866. /**
  124867. * Reset the AssetsManager and remove all tasks
  124868. * @return the current instance of the AssetsManager
  124869. */
  124870. reset(): AssetsManager;
  124871. /**
  124872. * Start the loading process
  124873. * @return the current instance of the AssetsManager
  124874. */
  124875. load(): AssetsManager;
  124876. /**
  124877. * Start the loading process as an async operation
  124878. * @return a promise returning the list of failed tasks
  124879. */
  124880. loadAsync(): Promise<void>;
  124881. }
  124882. }
  124883. declare module BABYLON {
  124884. /**
  124885. * Wrapper class for promise with external resolve and reject.
  124886. */
  124887. export class Deferred<T> {
  124888. /**
  124889. * The promise associated with this deferred object.
  124890. */
  124891. readonly promise: Promise<T>;
  124892. private _resolve;
  124893. private _reject;
  124894. /**
  124895. * The resolve method of the promise associated with this deferred object.
  124896. */
  124897. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  124898. /**
  124899. * The reject method of the promise associated with this deferred object.
  124900. */
  124901. readonly reject: (reason?: any) => void;
  124902. /**
  124903. * Constructor for this deferred object.
  124904. */
  124905. constructor();
  124906. }
  124907. }
  124908. declare module BABYLON {
  124909. /**
  124910. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  124911. */
  124912. export class MeshExploder {
  124913. private _centerMesh;
  124914. private _meshes;
  124915. private _meshesOrigins;
  124916. private _toCenterVectors;
  124917. private _scaledDirection;
  124918. private _newPosition;
  124919. private _centerPosition;
  124920. /**
  124921. * Explodes meshes from a center mesh.
  124922. * @param meshes The meshes to explode.
  124923. * @param centerMesh The mesh to be center of explosion.
  124924. */
  124925. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  124926. private _setCenterMesh;
  124927. /**
  124928. * Get class name
  124929. * @returns "MeshExploder"
  124930. */
  124931. getClassName(): string;
  124932. /**
  124933. * "Exploded meshes"
  124934. * @returns Array of meshes with the centerMesh at index 0.
  124935. */
  124936. getMeshes(): Array<Mesh>;
  124937. /**
  124938. * Explodes meshes giving a specific direction
  124939. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  124940. */
  124941. explode(direction?: number): void;
  124942. }
  124943. }
  124944. declare module BABYLON {
  124945. /**
  124946. * Class used to help managing file picking and drag'n'drop
  124947. */
  124948. export class FilesInput {
  124949. /**
  124950. * List of files ready to be loaded
  124951. */
  124952. static readonly FilesToLoad: {
  124953. [key: string]: File;
  124954. };
  124955. /**
  124956. * Callback called when a file is processed
  124957. */
  124958. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  124959. private _engine;
  124960. private _currentScene;
  124961. private _sceneLoadedCallback;
  124962. private _progressCallback;
  124963. private _additionalRenderLoopLogicCallback;
  124964. private _textureLoadingCallback;
  124965. private _startingProcessingFilesCallback;
  124966. private _onReloadCallback;
  124967. private _errorCallback;
  124968. private _elementToMonitor;
  124969. private _sceneFileToLoad;
  124970. private _filesToLoad;
  124971. /**
  124972. * Creates a new FilesInput
  124973. * @param engine defines the rendering engine
  124974. * @param scene defines the hosting scene
  124975. * @param sceneLoadedCallback callback called when scene is loaded
  124976. * @param progressCallback callback called to track progress
  124977. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  124978. * @param textureLoadingCallback callback called when a texture is loading
  124979. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  124980. * @param onReloadCallback callback called when a reload is requested
  124981. * @param errorCallback callback call if an error occurs
  124982. */
  124983. 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);
  124984. private _dragEnterHandler;
  124985. private _dragOverHandler;
  124986. private _dropHandler;
  124987. /**
  124988. * Calls this function to listen to drag'n'drop events on a specific DOM element
  124989. * @param elementToMonitor defines the DOM element to track
  124990. */
  124991. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  124992. /**
  124993. * Release all associated resources
  124994. */
  124995. dispose(): void;
  124996. private renderFunction;
  124997. private drag;
  124998. private drop;
  124999. private _traverseFolder;
  125000. private _processFiles;
  125001. /**
  125002. * Load files from a drop event
  125003. * @param event defines the drop event to use as source
  125004. */
  125005. loadFiles(event: any): void;
  125006. private _processReload;
  125007. /**
  125008. * Reload the current scene from the loaded files
  125009. */
  125010. reload(): void;
  125011. }
  125012. }
  125013. declare module BABYLON {
  125014. /**
  125015. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125017. */
  125018. export class SceneOptimization {
  125019. /**
  125020. * Defines the priority of this optimization (0 by default which means first in the list)
  125021. */
  125022. priority: number;
  125023. /**
  125024. * Gets a string describing the action executed by the current optimization
  125025. * @returns description string
  125026. */
  125027. getDescription(): string;
  125028. /**
  125029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125030. * @param scene defines the current scene where to apply this optimization
  125031. * @param optimizer defines the current optimizer
  125032. * @returns true if everything that can be done was applied
  125033. */
  125034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125035. /**
  125036. * Creates the SceneOptimization object
  125037. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125038. * @param desc defines the description associated with the optimization
  125039. */
  125040. constructor(
  125041. /**
  125042. * Defines the priority of this optimization (0 by default which means first in the list)
  125043. */
  125044. priority?: number);
  125045. }
  125046. /**
  125047. * Defines an optimization used to reduce the size of render target textures
  125048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125049. */
  125050. export class TextureOptimization extends SceneOptimization {
  125051. /**
  125052. * Defines the priority of this optimization (0 by default which means first in the list)
  125053. */
  125054. priority: number;
  125055. /**
  125056. * 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
  125057. */
  125058. maximumSize: number;
  125059. /**
  125060. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125061. */
  125062. step: number;
  125063. /**
  125064. * Gets a string describing the action executed by the current optimization
  125065. * @returns description string
  125066. */
  125067. getDescription(): string;
  125068. /**
  125069. * Creates the TextureOptimization object
  125070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125071. * @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
  125072. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125073. */
  125074. constructor(
  125075. /**
  125076. * Defines the priority of this optimization (0 by default which means first in the list)
  125077. */
  125078. priority?: number,
  125079. /**
  125080. * 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
  125081. */
  125082. maximumSize?: number,
  125083. /**
  125084. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125085. */
  125086. step?: number);
  125087. /**
  125088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125089. * @param scene defines the current scene where to apply this optimization
  125090. * @param optimizer defines the current optimizer
  125091. * @returns true if everything that can be done was applied
  125092. */
  125093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125094. }
  125095. /**
  125096. * Defines an optimization used to increase or decrease the rendering resolution
  125097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125098. */
  125099. export class HardwareScalingOptimization extends SceneOptimization {
  125100. /**
  125101. * Defines the priority of this optimization (0 by default which means first in the list)
  125102. */
  125103. priority: number;
  125104. /**
  125105. * Defines the maximum scale to use (2 by default)
  125106. */
  125107. maximumScale: number;
  125108. /**
  125109. * Defines the step to use between two passes (0.5 by default)
  125110. */
  125111. step: number;
  125112. private _currentScale;
  125113. private _directionOffset;
  125114. /**
  125115. * Gets a string describing the action executed by the current optimization
  125116. * @return description string
  125117. */
  125118. getDescription(): string;
  125119. /**
  125120. * Creates the HardwareScalingOptimization object
  125121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125122. * @param maximumScale defines the maximum scale to use (2 by default)
  125123. * @param step defines the step to use between two passes (0.5 by default)
  125124. */
  125125. constructor(
  125126. /**
  125127. * Defines the priority of this optimization (0 by default which means first in the list)
  125128. */
  125129. priority?: number,
  125130. /**
  125131. * Defines the maximum scale to use (2 by default)
  125132. */
  125133. maximumScale?: number,
  125134. /**
  125135. * Defines the step to use between two passes (0.5 by default)
  125136. */
  125137. step?: number);
  125138. /**
  125139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125140. * @param scene defines the current scene where to apply this optimization
  125141. * @param optimizer defines the current optimizer
  125142. * @returns true if everything that can be done was applied
  125143. */
  125144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125145. }
  125146. /**
  125147. * Defines an optimization used to remove shadows
  125148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125149. */
  125150. export class ShadowsOptimization extends SceneOptimization {
  125151. /**
  125152. * Gets a string describing the action executed by the current optimization
  125153. * @return description string
  125154. */
  125155. getDescription(): string;
  125156. /**
  125157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125158. * @param scene defines the current scene where to apply this optimization
  125159. * @param optimizer defines the current optimizer
  125160. * @returns true if everything that can be done was applied
  125161. */
  125162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125163. }
  125164. /**
  125165. * Defines an optimization used to turn post-processes off
  125166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125167. */
  125168. export class PostProcessesOptimization extends SceneOptimization {
  125169. /**
  125170. * Gets a string describing the action executed by the current optimization
  125171. * @return description string
  125172. */
  125173. getDescription(): string;
  125174. /**
  125175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125176. * @param scene defines the current scene where to apply this optimization
  125177. * @param optimizer defines the current optimizer
  125178. * @returns true if everything that can be done was applied
  125179. */
  125180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125181. }
  125182. /**
  125183. * Defines an optimization used to turn lens flares off
  125184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125185. */
  125186. export class LensFlaresOptimization extends SceneOptimization {
  125187. /**
  125188. * Gets a string describing the action executed by the current optimization
  125189. * @return description string
  125190. */
  125191. getDescription(): string;
  125192. /**
  125193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125194. * @param scene defines the current scene where to apply this optimization
  125195. * @param optimizer defines the current optimizer
  125196. * @returns true if everything that can be done was applied
  125197. */
  125198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125199. }
  125200. /**
  125201. * Defines an optimization based on user defined callback.
  125202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125203. */
  125204. export class CustomOptimization extends SceneOptimization {
  125205. /**
  125206. * Callback called to apply the custom optimization.
  125207. */
  125208. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  125209. /**
  125210. * Callback called to get custom description
  125211. */
  125212. onGetDescription: () => string;
  125213. /**
  125214. * Gets a string describing the action executed by the current optimization
  125215. * @returns description string
  125216. */
  125217. getDescription(): string;
  125218. /**
  125219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125220. * @param scene defines the current scene where to apply this optimization
  125221. * @param optimizer defines the current optimizer
  125222. * @returns true if everything that can be done was applied
  125223. */
  125224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125225. }
  125226. /**
  125227. * Defines an optimization used to turn particles off
  125228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125229. */
  125230. export class ParticlesOptimization extends SceneOptimization {
  125231. /**
  125232. * Gets a string describing the action executed by the current optimization
  125233. * @return description string
  125234. */
  125235. getDescription(): string;
  125236. /**
  125237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125238. * @param scene defines the current scene where to apply this optimization
  125239. * @param optimizer defines the current optimizer
  125240. * @returns true if everything that can be done was applied
  125241. */
  125242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125243. }
  125244. /**
  125245. * Defines an optimization used to turn render targets off
  125246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125247. */
  125248. export class RenderTargetsOptimization extends SceneOptimization {
  125249. /**
  125250. * Gets a string describing the action executed by the current optimization
  125251. * @return description string
  125252. */
  125253. getDescription(): string;
  125254. /**
  125255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125256. * @param scene defines the current scene where to apply this optimization
  125257. * @param optimizer defines the current optimizer
  125258. * @returns true if everything that can be done was applied
  125259. */
  125260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125261. }
  125262. /**
  125263. * Defines an optimization used to merge meshes with compatible materials
  125264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125265. */
  125266. export class MergeMeshesOptimization extends SceneOptimization {
  125267. private static _UpdateSelectionTree;
  125268. /**
  125269. * Gets or sets a boolean which defines if optimization octree has to be updated
  125270. */
  125271. /**
  125272. * Gets or sets a boolean which defines if optimization octree has to be updated
  125273. */
  125274. static UpdateSelectionTree: boolean;
  125275. /**
  125276. * Gets a string describing the action executed by the current optimization
  125277. * @return description string
  125278. */
  125279. getDescription(): string;
  125280. private _canBeMerged;
  125281. /**
  125282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125283. * @param scene defines the current scene where to apply this optimization
  125284. * @param optimizer defines the current optimizer
  125285. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  125286. * @returns true if everything that can be done was applied
  125287. */
  125288. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  125289. }
  125290. /**
  125291. * Defines a list of options used by SceneOptimizer
  125292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125293. */
  125294. export class SceneOptimizerOptions {
  125295. /**
  125296. * Defines the target frame rate to reach (60 by default)
  125297. */
  125298. targetFrameRate: number;
  125299. /**
  125300. * Defines the interval between two checkes (2000ms by default)
  125301. */
  125302. trackerDuration: number;
  125303. /**
  125304. * Gets the list of optimizations to apply
  125305. */
  125306. optimizations: SceneOptimization[];
  125307. /**
  125308. * Creates a new list of options used by SceneOptimizer
  125309. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  125310. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  125311. */
  125312. constructor(
  125313. /**
  125314. * Defines the target frame rate to reach (60 by default)
  125315. */
  125316. targetFrameRate?: number,
  125317. /**
  125318. * Defines the interval between two checkes (2000ms by default)
  125319. */
  125320. trackerDuration?: number);
  125321. /**
  125322. * Add a new optimization
  125323. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  125324. * @returns the current SceneOptimizerOptions
  125325. */
  125326. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  125327. /**
  125328. * Add a new custom optimization
  125329. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  125330. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  125331. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125332. * @returns the current SceneOptimizerOptions
  125333. */
  125334. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  125335. /**
  125336. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  125337. * @param targetFrameRate defines the target frame rate (60 by default)
  125338. * @returns a SceneOptimizerOptions object
  125339. */
  125340. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125341. /**
  125342. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  125343. * @param targetFrameRate defines the target frame rate (60 by default)
  125344. * @returns a SceneOptimizerOptions object
  125345. */
  125346. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125347. /**
  125348. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  125349. * @param targetFrameRate defines the target frame rate (60 by default)
  125350. * @returns a SceneOptimizerOptions object
  125351. */
  125352. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125353. }
  125354. /**
  125355. * Class used to run optimizations in order to reach a target frame rate
  125356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125357. */
  125358. export class SceneOptimizer implements IDisposable {
  125359. private _isRunning;
  125360. private _options;
  125361. private _scene;
  125362. private _currentPriorityLevel;
  125363. private _targetFrameRate;
  125364. private _trackerDuration;
  125365. private _currentFrameRate;
  125366. private _sceneDisposeObserver;
  125367. private _improvementMode;
  125368. /**
  125369. * Defines an observable called when the optimizer reaches the target frame rate
  125370. */
  125371. onSuccessObservable: Observable<SceneOptimizer>;
  125372. /**
  125373. * Defines an observable called when the optimizer enables an optimization
  125374. */
  125375. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  125376. /**
  125377. * Defines an observable called when the optimizer is not able to reach the target frame rate
  125378. */
  125379. onFailureObservable: Observable<SceneOptimizer>;
  125380. /**
  125381. * Gets a boolean indicating if the optimizer is in improvement mode
  125382. */
  125383. readonly isInImprovementMode: boolean;
  125384. /**
  125385. * Gets the current priority level (0 at start)
  125386. */
  125387. readonly currentPriorityLevel: number;
  125388. /**
  125389. * Gets the current frame rate checked by the SceneOptimizer
  125390. */
  125391. readonly currentFrameRate: number;
  125392. /**
  125393. * Gets or sets the current target frame rate (60 by default)
  125394. */
  125395. /**
  125396. * Gets or sets the current target frame rate (60 by default)
  125397. */
  125398. targetFrameRate: number;
  125399. /**
  125400. * Gets or sets the current interval between two checks (every 2000ms by default)
  125401. */
  125402. /**
  125403. * Gets or sets the current interval between two checks (every 2000ms by default)
  125404. */
  125405. trackerDuration: number;
  125406. /**
  125407. * Gets the list of active optimizations
  125408. */
  125409. readonly optimizations: SceneOptimization[];
  125410. /**
  125411. * Creates a new SceneOptimizer
  125412. * @param scene defines the scene to work on
  125413. * @param options defines the options to use with the SceneOptimizer
  125414. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  125415. * @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)
  125416. */
  125417. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  125418. /**
  125419. * Stops the current optimizer
  125420. */
  125421. stop(): void;
  125422. /**
  125423. * Reset the optimizer to initial step (current priority level = 0)
  125424. */
  125425. reset(): void;
  125426. /**
  125427. * Start the optimizer. By default it will try to reach a specific framerate
  125428. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  125429. */
  125430. start(): void;
  125431. private _checkCurrentState;
  125432. /**
  125433. * Release all resources
  125434. */
  125435. dispose(): void;
  125436. /**
  125437. * Helper function to create a SceneOptimizer with one single line of code
  125438. * @param scene defines the scene to work on
  125439. * @param options defines the options to use with the SceneOptimizer
  125440. * @param onSuccess defines a callback to call on success
  125441. * @param onFailure defines a callback to call on failure
  125442. * @returns the new SceneOptimizer object
  125443. */
  125444. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  125445. }
  125446. }
  125447. declare module BABYLON {
  125448. /**
  125449. * Class used to serialize a scene into a string
  125450. */
  125451. export class SceneSerializer {
  125452. /**
  125453. * Clear cache used by a previous serialization
  125454. */
  125455. static ClearCache(): void;
  125456. /**
  125457. * Serialize a scene into a JSON compatible object
  125458. * @param scene defines the scene to serialize
  125459. * @returns a JSON compatible object
  125460. */
  125461. static Serialize(scene: Scene): any;
  125462. /**
  125463. * Serialize a mesh into a JSON compatible object
  125464. * @param toSerialize defines the mesh to serialize
  125465. * @param withParents defines if parents must be serialized as well
  125466. * @param withChildren defines if children must be serialized as well
  125467. * @returns a JSON compatible object
  125468. */
  125469. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  125470. }
  125471. }
  125472. declare module BABYLON {
  125473. /**
  125474. * Class used to host texture specific utilities
  125475. */
  125476. export class TextureTools {
  125477. /**
  125478. * Uses the GPU to create a copy texture rescaled at a given size
  125479. * @param texture Texture to copy from
  125480. * @param width defines the desired width
  125481. * @param height defines the desired height
  125482. * @param useBilinearMode defines if bilinear mode has to be used
  125483. * @return the generated texture
  125484. */
  125485. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  125486. }
  125487. }
  125488. declare module BABYLON {
  125489. /**
  125490. * This represents the different options available for the video capture.
  125491. */
  125492. export interface VideoRecorderOptions {
  125493. /** Defines the mime type of the video. */
  125494. mimeType: string;
  125495. /** Defines the FPS the video should be recorded at. */
  125496. fps: number;
  125497. /** Defines the chunk size for the recording data. */
  125498. recordChunckSize: number;
  125499. /** The audio tracks to attach to the recording. */
  125500. audioTracks?: MediaStreamTrack[];
  125501. }
  125502. /**
  125503. * This can help with recording videos from BabylonJS.
  125504. * This is based on the available WebRTC functionalities of the browser.
  125505. *
  125506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  125507. */
  125508. export class VideoRecorder {
  125509. private static readonly _defaultOptions;
  125510. /**
  125511. * Returns whether or not the VideoRecorder is available in your browser.
  125512. * @param engine Defines the Babylon Engine.
  125513. * @returns true if supported otherwise false.
  125514. */
  125515. static IsSupported(engine: Engine): boolean;
  125516. private readonly _options;
  125517. private _canvas;
  125518. private _mediaRecorder;
  125519. private _recordedChunks;
  125520. private _fileName;
  125521. private _resolve;
  125522. private _reject;
  125523. /**
  125524. * True when a recording is already in progress.
  125525. */
  125526. readonly isRecording: boolean;
  125527. /**
  125528. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  125529. * @param engine Defines the BabylonJS Engine you wish to record.
  125530. * @param options Defines options that can be used to customize the capture.
  125531. */
  125532. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  125533. /**
  125534. * Stops the current recording before the default capture timeout passed in the startRecording function.
  125535. */
  125536. stopRecording(): void;
  125537. /**
  125538. * Starts recording the canvas for a max duration specified in parameters.
  125539. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  125540. * If null no automatic download will start and you can rely on the promise to get the data back.
  125541. * @param maxDuration Defines the maximum recording time in seconds.
  125542. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  125543. * @return A promise callback at the end of the recording with the video data in Blob.
  125544. */
  125545. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  125546. /**
  125547. * Releases internal resources used during the recording.
  125548. */
  125549. dispose(): void;
  125550. private _handleDataAvailable;
  125551. private _handleError;
  125552. private _handleStop;
  125553. }
  125554. }
  125555. declare module BABYLON {
  125556. /**
  125557. * Class containing a set of static utilities functions for screenshots
  125558. */
  125559. export class ScreenshotTools {
  125560. /**
  125561. * Captures a screenshot of the current rendering
  125562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125563. * @param engine defines the rendering engine
  125564. * @param camera defines the source camera
  125565. * @param size This parameter can be set to a single number or to an object with the
  125566. * following (optional) properties: precision, width, height. If a single number is passed,
  125567. * it will be used for both width and height. If an object is passed, the screenshot size
  125568. * will be derived from the parameters. The precision property is a multiplier allowing
  125569. * rendering at a higher or lower resolution
  125570. * @param successCallback defines the callback receives a single parameter which contains the
  125571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125572. * src parameter of an <img> to display it
  125573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125574. * Check your browser for supported MIME types
  125575. */
  125576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  125577. /**
  125578. * Captures a screenshot of the current rendering
  125579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125580. * @param engine defines the rendering engine
  125581. * @param camera defines the source camera
  125582. * @param size This parameter can be set to a single number or to an object with the
  125583. * following (optional) properties: precision, width, height. If a single number is passed,
  125584. * it will be used for both width and height. If an object is passed, the screenshot size
  125585. * will be derived from the parameters. The precision property is a multiplier allowing
  125586. * rendering at a higher or lower resolution
  125587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125588. * Check your browser for supported MIME types
  125589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125590. * to the src parameter of an <img> to display it
  125591. */
  125592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  125593. /**
  125594. * Generates an image screenshot from the specified camera.
  125595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125596. * @param engine The engine to use for rendering
  125597. * @param camera The camera to use for rendering
  125598. * @param size This parameter can be set to a single number or to an object with the
  125599. * following (optional) properties: precision, width, height. If a single number is passed,
  125600. * it will be used for both width and height. If an object is passed, the screenshot size
  125601. * will be derived from the parameters. The precision property is a multiplier allowing
  125602. * rendering at a higher or lower resolution
  125603. * @param successCallback The callback receives a single parameter which contains the
  125604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125605. * src parameter of an <img> to display it
  125606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125607. * Check your browser for supported MIME types
  125608. * @param samples Texture samples (default: 1)
  125609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125610. * @param fileName A name for for the downloaded file.
  125611. */
  125612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  125613. /**
  125614. * Generates an image screenshot from the specified camera.
  125615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125616. * @param engine The engine to use for rendering
  125617. * @param camera The camera to use for rendering
  125618. * @param size This parameter can be set to a single number or to an object with the
  125619. * following (optional) properties: precision, width, height. If a single number is passed,
  125620. * it will be used for both width and height. If an object is passed, the screenshot size
  125621. * will be derived from the parameters. The precision property is a multiplier allowing
  125622. * rendering at a higher or lower resolution
  125623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125624. * Check your browser for supported MIME types
  125625. * @param samples Texture samples (default: 1)
  125626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125627. * @param fileName A name for for the downloaded file.
  125628. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125629. * to the src parameter of an <img> to display it
  125630. */
  125631. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125632. /**
  125633. * Gets height and width for screenshot size
  125634. * @private
  125635. */
  125636. private static _getScreenshotSize;
  125637. }
  125638. }
  125639. declare module BABYLON {
  125640. /**
  125641. * A cursor which tracks a point on a path
  125642. */
  125643. export class PathCursor {
  125644. private path;
  125645. /**
  125646. * Stores path cursor callbacks for when an onchange event is triggered
  125647. */
  125648. private _onchange;
  125649. /**
  125650. * The value of the path cursor
  125651. */
  125652. value: number;
  125653. /**
  125654. * The animation array of the path cursor
  125655. */
  125656. animations: Animation[];
  125657. /**
  125658. * Initializes the path cursor
  125659. * @param path The path to track
  125660. */
  125661. constructor(path: Path2);
  125662. /**
  125663. * Gets the cursor point on the path
  125664. * @returns A point on the path cursor at the cursor location
  125665. */
  125666. getPoint(): Vector3;
  125667. /**
  125668. * Moves the cursor ahead by the step amount
  125669. * @param step The amount to move the cursor forward
  125670. * @returns This path cursor
  125671. */
  125672. moveAhead(step?: number): PathCursor;
  125673. /**
  125674. * Moves the cursor behind by the step amount
  125675. * @param step The amount to move the cursor back
  125676. * @returns This path cursor
  125677. */
  125678. moveBack(step?: number): PathCursor;
  125679. /**
  125680. * Moves the cursor by the step amount
  125681. * If the step amount is greater than one, an exception is thrown
  125682. * @param step The amount to move the cursor
  125683. * @returns This path cursor
  125684. */
  125685. move(step: number): PathCursor;
  125686. /**
  125687. * Ensures that the value is limited between zero and one
  125688. * @returns This path cursor
  125689. */
  125690. private ensureLimits;
  125691. /**
  125692. * Runs onchange callbacks on change (used by the animation engine)
  125693. * @returns This path cursor
  125694. */
  125695. private raiseOnChange;
  125696. /**
  125697. * Executes a function on change
  125698. * @param f A path cursor onchange callback
  125699. * @returns This path cursor
  125700. */
  125701. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125702. }
  125703. }
  125704. declare module BABYLON {
  125705. /** @hidden */
  125706. export var blurPixelShader: {
  125707. name: string;
  125708. shader: string;
  125709. };
  125710. }
  125711. declare module BABYLON {
  125712. /** @hidden */
  125713. export var pointCloudVertexDeclaration: {
  125714. name: string;
  125715. shader: string;
  125716. };
  125717. }
  125718. // Mixins
  125719. interface Window {
  125720. mozIndexedDB: IDBFactory;
  125721. webkitIndexedDB: IDBFactory;
  125722. msIndexedDB: IDBFactory;
  125723. webkitURL: typeof URL;
  125724. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125725. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125726. WebGLRenderingContext: WebGLRenderingContext;
  125727. MSGesture: MSGesture;
  125728. CANNON: any;
  125729. AudioContext: AudioContext;
  125730. webkitAudioContext: AudioContext;
  125731. PointerEvent: any;
  125732. Math: Math;
  125733. Uint8Array: Uint8ArrayConstructor;
  125734. Float32Array: Float32ArrayConstructor;
  125735. mozURL: typeof URL;
  125736. msURL: typeof URL;
  125737. VRFrameData: any; // WebVR, from specs 1.1
  125738. DracoDecoderModule: any;
  125739. setImmediate(handler: (...args: any[]) => void): number;
  125740. }
  125741. interface HTMLCanvasElement {
  125742. requestPointerLock(): void;
  125743. msRequestPointerLock?(): void;
  125744. mozRequestPointerLock?(): void;
  125745. webkitRequestPointerLock?(): void;
  125746. /** Track wether a record is in progress */
  125747. isRecording: boolean;
  125748. /** Capture Stream method defined by some browsers */
  125749. captureStream(fps?: number): MediaStream;
  125750. }
  125751. interface CanvasRenderingContext2D {
  125752. msImageSmoothingEnabled: boolean;
  125753. }
  125754. interface MouseEvent {
  125755. mozMovementX: number;
  125756. mozMovementY: number;
  125757. webkitMovementX: number;
  125758. webkitMovementY: number;
  125759. msMovementX: number;
  125760. msMovementY: number;
  125761. }
  125762. interface Navigator {
  125763. mozGetVRDevices: (any: any) => any;
  125764. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125765. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125766. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125767. webkitGetGamepads(): Gamepad[];
  125768. msGetGamepads(): Gamepad[];
  125769. webkitGamepads(): Gamepad[];
  125770. }
  125771. interface HTMLVideoElement {
  125772. mozSrcObject: any;
  125773. }
  125774. interface Math {
  125775. fround(x: number): number;
  125776. imul(a: number, b: number): number;
  125777. }
  125778. interface WebGLRenderingContext {
  125779. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  125780. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  125781. vertexAttribDivisor(index: number, divisor: number): void;
  125782. createVertexArray(): any;
  125783. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  125784. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  125785. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  125786. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  125787. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  125788. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  125789. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  125790. // Queries
  125791. createQuery(): WebGLQuery;
  125792. deleteQuery(query: WebGLQuery): void;
  125793. beginQuery(target: number, query: WebGLQuery): void;
  125794. endQuery(target: number): void;
  125795. getQueryParameter(query: WebGLQuery, pname: number): any;
  125796. getQuery(target: number, pname: number): any;
  125797. MAX_SAMPLES: number;
  125798. RGBA8: number;
  125799. READ_FRAMEBUFFER: number;
  125800. DRAW_FRAMEBUFFER: number;
  125801. UNIFORM_BUFFER: number;
  125802. HALF_FLOAT_OES: number;
  125803. RGBA16F: number;
  125804. RGBA32F: number;
  125805. R32F: number;
  125806. RG32F: number;
  125807. RGB32F: number;
  125808. R16F: number;
  125809. RG16F: number;
  125810. RGB16F: number;
  125811. RED: number;
  125812. RG: number;
  125813. R8: number;
  125814. RG8: number;
  125815. UNSIGNED_INT_24_8: number;
  125816. DEPTH24_STENCIL8: number;
  125817. /* Multiple Render Targets */
  125818. drawBuffers(buffers: number[]): void;
  125819. readBuffer(src: number): void;
  125820. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  125821. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  125822. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  125823. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  125824. // Occlusion Query
  125825. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  125826. ANY_SAMPLES_PASSED: number;
  125827. QUERY_RESULT_AVAILABLE: number;
  125828. QUERY_RESULT: number;
  125829. }
  125830. interface WebGLProgram {
  125831. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  125832. }
  125833. interface EXT_disjoint_timer_query {
  125834. QUERY_COUNTER_BITS_EXT: number;
  125835. TIME_ELAPSED_EXT: number;
  125836. TIMESTAMP_EXT: number;
  125837. GPU_DISJOINT_EXT: number;
  125838. QUERY_RESULT_EXT: number;
  125839. QUERY_RESULT_AVAILABLE_EXT: number;
  125840. queryCounterEXT(query: WebGLQuery, target: number): void;
  125841. createQueryEXT(): WebGLQuery;
  125842. beginQueryEXT(target: number, query: WebGLQuery): void;
  125843. endQueryEXT(target: number): void;
  125844. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  125845. deleteQueryEXT(query: WebGLQuery): void;
  125846. }
  125847. interface WebGLUniformLocation {
  125848. _currentState: any;
  125849. }
  125850. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  125851. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  125852. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  125853. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125854. interface WebGLRenderingContext {
  125855. readonly RASTERIZER_DISCARD: number;
  125856. readonly DEPTH_COMPONENT24: number;
  125857. readonly TEXTURE_3D: number;
  125858. readonly TEXTURE_2D_ARRAY: number;
  125859. readonly TEXTURE_COMPARE_FUNC: number;
  125860. readonly TEXTURE_COMPARE_MODE: number;
  125861. readonly COMPARE_REF_TO_TEXTURE: number;
  125862. readonly TEXTURE_WRAP_R: number;
  125863. readonly HALF_FLOAT: number;
  125864. readonly RGB8: number;
  125865. readonly RED_INTEGER: number;
  125866. readonly RG_INTEGER: number;
  125867. readonly RGB_INTEGER: number;
  125868. readonly RGBA_INTEGER: number;
  125869. readonly R8_SNORM: number;
  125870. readonly RG8_SNORM: number;
  125871. readonly RGB8_SNORM: number;
  125872. readonly RGBA8_SNORM: number;
  125873. readonly R8I: number;
  125874. readonly RG8I: number;
  125875. readonly RGB8I: number;
  125876. readonly RGBA8I: number;
  125877. readonly R8UI: number;
  125878. readonly RG8UI: number;
  125879. readonly RGB8UI: number;
  125880. readonly RGBA8UI: number;
  125881. readonly R16I: number;
  125882. readonly RG16I: number;
  125883. readonly RGB16I: number;
  125884. readonly RGBA16I: number;
  125885. readonly R16UI: number;
  125886. readonly RG16UI: number;
  125887. readonly RGB16UI: number;
  125888. readonly RGBA16UI: number;
  125889. readonly R32I: number;
  125890. readonly RG32I: number;
  125891. readonly RGB32I: number;
  125892. readonly RGBA32I: number;
  125893. readonly R32UI: number;
  125894. readonly RG32UI: number;
  125895. readonly RGB32UI: number;
  125896. readonly RGBA32UI: number;
  125897. readonly RGB10_A2UI: number;
  125898. readonly R11F_G11F_B10F: number;
  125899. readonly RGB9_E5: number;
  125900. readonly RGB10_A2: number;
  125901. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  125902. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  125903. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  125904. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  125905. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  125906. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  125907. 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;
  125908. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  125909. readonly TRANSFORM_FEEDBACK: number;
  125910. readonly INTERLEAVED_ATTRIBS: number;
  125911. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  125912. createTransformFeedback(): WebGLTransformFeedback;
  125913. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  125914. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  125915. beginTransformFeedback(primitiveMode: number): void;
  125916. endTransformFeedback(): void;
  125917. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  125918. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125919. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125920. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125921. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  125922. }
  125923. interface ImageBitmap {
  125924. readonly width: number;
  125925. readonly height: number;
  125926. close(): void;
  125927. }
  125928. interface WebGLQuery extends WebGLObject {
  125929. }
  125930. declare var WebGLQuery: {
  125931. prototype: WebGLQuery;
  125932. new(): WebGLQuery;
  125933. };
  125934. interface WebGLSampler extends WebGLObject {
  125935. }
  125936. declare var WebGLSampler: {
  125937. prototype: WebGLSampler;
  125938. new(): WebGLSampler;
  125939. };
  125940. interface WebGLSync extends WebGLObject {
  125941. }
  125942. declare var WebGLSync: {
  125943. prototype: WebGLSync;
  125944. new(): WebGLSync;
  125945. };
  125946. interface WebGLTransformFeedback extends WebGLObject {
  125947. }
  125948. declare var WebGLTransformFeedback: {
  125949. prototype: WebGLTransformFeedback;
  125950. new(): WebGLTransformFeedback;
  125951. };
  125952. interface WebGLVertexArrayObject extends WebGLObject {
  125953. }
  125954. declare var WebGLVertexArrayObject: {
  125955. prototype: WebGLVertexArrayObject;
  125956. new(): WebGLVertexArrayObject;
  125957. };
  125958. // Type definitions for WebVR API
  125959. // Project: https://w3c.github.io/webvr/
  125960. // Definitions by: six a <https://github.com/lostfictions>
  125961. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125962. interface VRDisplay extends EventTarget {
  125963. /**
  125964. * Dictionary of capabilities describing the VRDisplay.
  125965. */
  125966. readonly capabilities: VRDisplayCapabilities;
  125967. /**
  125968. * z-depth defining the far plane of the eye view frustum
  125969. * enables mapping of values in the render target depth
  125970. * attachment to scene coordinates. Initially set to 10000.0.
  125971. */
  125972. depthFar: number;
  125973. /**
  125974. * z-depth defining the near plane of the eye view frustum
  125975. * enables mapping of values in the render target depth
  125976. * attachment to scene coordinates. Initially set to 0.01.
  125977. */
  125978. depthNear: number;
  125979. /**
  125980. * An identifier for this distinct VRDisplay. Used as an
  125981. * association point in the Gamepad API.
  125982. */
  125983. readonly displayId: number;
  125984. /**
  125985. * A display name, a user-readable name identifying it.
  125986. */
  125987. readonly displayName: string;
  125988. readonly isConnected: boolean;
  125989. readonly isPresenting: boolean;
  125990. /**
  125991. * If this VRDisplay supports room-scale experiences, the optional
  125992. * stage attribute contains details on the room-scale parameters.
  125993. */
  125994. readonly stageParameters: VRStageParameters | null;
  125995. /**
  125996. * Passing the value returned by `requestAnimationFrame` to
  125997. * `cancelAnimationFrame` will unregister the callback.
  125998. * @param handle Define the hanle of the request to cancel
  125999. */
  126000. cancelAnimationFrame(handle: number): void;
  126001. /**
  126002. * Stops presenting to the VRDisplay.
  126003. * @returns a promise to know when it stopped
  126004. */
  126005. exitPresent(): Promise<void>;
  126006. /**
  126007. * Return the current VREyeParameters for the given eye.
  126008. * @param whichEye Define the eye we want the parameter for
  126009. * @returns the eye parameters
  126010. */
  126011. getEyeParameters(whichEye: string): VREyeParameters;
  126012. /**
  126013. * Populates the passed VRFrameData with the information required to render
  126014. * the current frame.
  126015. * @param frameData Define the data structure to populate
  126016. * @returns true if ok otherwise false
  126017. */
  126018. getFrameData(frameData: VRFrameData): boolean;
  126019. /**
  126020. * Get the layers currently being presented.
  126021. * @returns the list of VR layers
  126022. */
  126023. getLayers(): VRLayer[];
  126024. /**
  126025. * Return a VRPose containing the future predicted pose of the VRDisplay
  126026. * when the current frame will be presented. The value returned will not
  126027. * change until JavaScript has returned control to the browser.
  126028. *
  126029. * The VRPose will contain the position, orientation, velocity,
  126030. * and acceleration of each of these properties.
  126031. * @returns the pose object
  126032. */
  126033. getPose(): VRPose;
  126034. /**
  126035. * Return the current instantaneous pose of the VRDisplay, with no
  126036. * prediction applied.
  126037. * @returns the current instantaneous pose
  126038. */
  126039. getImmediatePose(): VRPose;
  126040. /**
  126041. * The callback passed to `requestAnimationFrame` will be called
  126042. * any time a new frame should be rendered. When the VRDisplay is
  126043. * presenting the callback will be called at the native refresh
  126044. * rate of the HMD. When not presenting this function acts
  126045. * identically to how window.requestAnimationFrame acts. Content should
  126046. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126047. * asynchronously from other displays and at differing refresh rates.
  126048. * @param callback Define the eaction to run next frame
  126049. * @returns the request handle it
  126050. */
  126051. requestAnimationFrame(callback: FrameRequestCallback): number;
  126052. /**
  126053. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126054. * Repeat calls while already presenting will update the VRLayers being displayed.
  126055. * @param layers Define the list of layer to present
  126056. * @returns a promise to know when the request has been fulfilled
  126057. */
  126058. requestPresent(layers: VRLayer[]): Promise<void>;
  126059. /**
  126060. * Reset the pose for this display, treating its current position and
  126061. * orientation as the "origin/zero" values. VRPose.position,
  126062. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126063. * updated when calling resetPose(). This should be called in only
  126064. * sitting-space experiences.
  126065. */
  126066. resetPose(): void;
  126067. /**
  126068. * The VRLayer provided to the VRDisplay will be captured and presented
  126069. * in the HMD. Calling this function has the same effect on the source
  126070. * canvas as any other operation that uses its source image, and canvases
  126071. * created without preserveDrawingBuffer set to true will be cleared.
  126072. * @param pose Define the pose to submit
  126073. */
  126074. submitFrame(pose?: VRPose): void;
  126075. }
  126076. declare var VRDisplay: {
  126077. prototype: VRDisplay;
  126078. new(): VRDisplay;
  126079. };
  126080. interface VRLayer {
  126081. leftBounds?: number[] | Float32Array | null;
  126082. rightBounds?: number[] | Float32Array | null;
  126083. source?: HTMLCanvasElement | null;
  126084. }
  126085. interface VRDisplayCapabilities {
  126086. readonly canPresent: boolean;
  126087. readonly hasExternalDisplay: boolean;
  126088. readonly hasOrientation: boolean;
  126089. readonly hasPosition: boolean;
  126090. readonly maxLayers: number;
  126091. }
  126092. interface VREyeParameters {
  126093. /** @deprecated */
  126094. readonly fieldOfView: VRFieldOfView;
  126095. readonly offset: Float32Array;
  126096. readonly renderHeight: number;
  126097. readonly renderWidth: number;
  126098. }
  126099. interface VRFieldOfView {
  126100. readonly downDegrees: number;
  126101. readonly leftDegrees: number;
  126102. readonly rightDegrees: number;
  126103. readonly upDegrees: number;
  126104. }
  126105. interface VRFrameData {
  126106. readonly leftProjectionMatrix: Float32Array;
  126107. readonly leftViewMatrix: Float32Array;
  126108. readonly pose: VRPose;
  126109. readonly rightProjectionMatrix: Float32Array;
  126110. readonly rightViewMatrix: Float32Array;
  126111. readonly timestamp: number;
  126112. }
  126113. interface VRPose {
  126114. readonly angularAcceleration: Float32Array | null;
  126115. readonly angularVelocity: Float32Array | null;
  126116. readonly linearAcceleration: Float32Array | null;
  126117. readonly linearVelocity: Float32Array | null;
  126118. readonly orientation: Float32Array | null;
  126119. readonly position: Float32Array | null;
  126120. readonly timestamp: number;
  126121. }
  126122. interface VRStageParameters {
  126123. sittingToStandingTransform?: Float32Array;
  126124. sizeX?: number;
  126125. sizeY?: number;
  126126. }
  126127. interface Navigator {
  126128. getVRDisplays(): Promise<VRDisplay[]>;
  126129. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  126130. }
  126131. interface Window {
  126132. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  126133. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  126134. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  126135. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126136. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126137. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  126138. }
  126139. interface Gamepad {
  126140. readonly displayId: number;
  126141. }
  126142. type XRSessionMode =
  126143. | "inline"
  126144. | "immersive-vr"
  126145. | "immersive-ar";
  126146. type XRReferenceSpaceType =
  126147. | "viewer"
  126148. | "local"
  126149. | "local-floor"
  126150. | "bounded-floor"
  126151. | "unbounded";
  126152. type XREnvironmentBlendMode =
  126153. | "opaque"
  126154. | "additive"
  126155. | "alpha-blend";
  126156. type XRVisibilityState =
  126157. | "visible"
  126158. | "visible-blurred"
  126159. | "hidden";
  126160. type XRHandedness =
  126161. | "none"
  126162. | "left"
  126163. | "right";
  126164. type XRTargetRayMode =
  126165. | "gaze"
  126166. | "tracked-pointer"
  126167. | "screen";
  126168. type XREye =
  126169. | "none"
  126170. | "left"
  126171. | "right";
  126172. interface XRSpace extends EventTarget {
  126173. }
  126174. interface XRRenderState {
  126175. depthNear?: number;
  126176. depthFar?: number;
  126177. inlineVerticalFieldOfView?: number;
  126178. baseLayer?: XRWebGLLayer;
  126179. }
  126180. interface XRInputSource {
  126181. handedness: XRHandedness;
  126182. targetRayMode: XRTargetRayMode;
  126183. targetRaySpace: XRSpace;
  126184. gripSpace: XRSpace | undefined;
  126185. gamepad: Gamepad | undefined;
  126186. profiles: Array<string>;
  126187. }
  126188. interface XRSession {
  126189. addEventListener: Function;
  126190. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126191. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  126192. requestAnimationFrame: Function;
  126193. end(): Promise<void>;
  126194. renderState: XRRenderState;
  126195. inputSources: Array<XRInputSource>;
  126196. }
  126197. interface XRReferenceSpace extends XRSpace {
  126198. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  126199. onreset: any;
  126200. }
  126201. interface XRFrame {
  126202. session: XRSession;
  126203. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  126204. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  126205. }
  126206. interface XRViewerPose extends XRPose {
  126207. views: Array<XRView>;
  126208. }
  126209. interface XRPose {
  126210. transform: XRRigidTransform;
  126211. emulatedPosition: boolean;
  126212. }
  126213. declare var XRWebGLLayer: {
  126214. prototype: XRWebGLLayer;
  126215. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  126216. };
  126217. interface XRWebGLLayer {
  126218. framebuffer: WebGLFramebuffer;
  126219. framebufferWidth: number;
  126220. framebufferHeight: number;
  126221. getViewport: Function;
  126222. }
  126223. interface XRRigidTransform {
  126224. position: DOMPointReadOnly;
  126225. orientation: DOMPointReadOnly;
  126226. matrix: Float32Array;
  126227. inverse: XRRigidTransform;
  126228. }
  126229. interface XRView {
  126230. eye: XREye;
  126231. projectionMatrix: Float32Array;
  126232. transform: XRRigidTransform;
  126233. }
  126234. interface XRInputSourceChangeEvent {
  126235. session: XRSession;
  126236. removed: Array<XRInputSource>;
  126237. added: Array<XRInputSource>;
  126238. }